001 /* 002 * Copyright (c) 2007-2014 Concurrent, Inc. All Rights Reserved. 003 * 004 * Project and contact information: http://www.cascading.org/ 005 * 006 * This file is part of the Cascading project. 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020 021 package cascading.tap; 022 023 import java.io.IOException; 024 025 import cascading.flow.FlowProcess; 026 import cascading.scheme.Scheme; 027 import cascading.tuple.Fields; 028 import cascading.tuple.TupleEntryCollector; 029 030 /** 031 * Class SourceTap is an optional base class for source only Taps. 032 * <p/> 033 * Some {@link Tap} instances may only be sources (as opposed 034 * to being a sink). These types should subclass SourceTap for convenience or 035 * set {@link #isSink()} to {@code false} in a custom Tap sub-class. 036 */ 037 public abstract class SourceTap<Config, Input> extends Tap<Config, Input, Void> 038 { 039 protected SourceTap() 040 { 041 } 042 043 protected SourceTap( Scheme<Config, Input, ?, ?, ?> scheme ) 044 { 045 super( (Scheme<Config, Input, Void, ?, ?>) scheme ); 046 } 047 048 @Override 049 public Fields getSinkFields() 050 { 051 throw new UnsupportedOperationException( "unable to sink tuple streams via a SourceTap instance" ); 052 } 053 054 @Override 055 public final boolean isSink() 056 { 057 return false; 058 } 059 060 @Override 061 public boolean deleteResource( Config conf ) throws IOException 062 { 063 throw new UnsupportedOperationException( "unable to delete files via a SourceTap instance" ); 064 } 065 066 @Override 067 public void sinkConfInit( FlowProcess<Config> flowProcess, Config conf ) 068 { 069 throw new UnsupportedOperationException( "unable to source tuple streams via a SourceTap instance" ); 070 } 071 072 @Override 073 public boolean createResource( Config conf ) throws IOException 074 { 075 throw new UnsupportedOperationException( "unable to make dirs via a SourceTap instance" ); 076 } 077 078 @Override 079 public boolean commitResource( Config conf ) throws IOException 080 { 081 throw new UnsupportedOperationException( "unable to commit resource via a SourceTap instance" ); 082 } 083 084 @Override 085 public boolean rollbackResource( Config conf ) throws IOException 086 { 087 throw new UnsupportedOperationException( "unable to rollback resource via a SourceTap instance" ); 088 } 089 090 @Override 091 public TupleEntryCollector openForWrite( FlowProcess<Config> flowProcess, Void output ) throws IOException 092 { 093 throw new UnsupportedOperationException( "unable to open for write via a SourceTap instance" ); 094 } 095 }