    001/*
    002 * Copyright (c) 2007-2017 Xplenty, 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
    021package cascading.tap.local;
    022
    023import java.io.IOException;
    024import java.io.OutputStream;
    025import java.util.Properties;
    026
    027import cascading.flow.FlowProcess;
    028import cascading.scheme.Scheme;
    029import cascading.tap.SinkMode;
    030import cascading.tap.SinkTap;
    031import cascading.tuple.TupleEntryCollector;
    032import cascading.tuple.TupleEntrySchemeCollector;
    033
    034/** Class StdOutTap provides a local mode tap for writing data to the {@code stdout} stream. */
    035public class StdOutTap extends SinkTap<Properties, OutputStream>
    036  {
    037  public StdOutTap( Scheme<Properties, ?, OutputStream, ?, ?> scheme )
    038    {
    039    super( scheme, SinkMode.UPDATE );
    040    }
    041
    042  @Override
    043  public String getIdentifier()
    044    {
    045    return "stdOut";
    046    }
    047
    048  @Override
    049  public TupleEntryCollector openForWrite( FlowProcess<? extends Properties> flowProcess, OutputStream output ) throws IOException
    050    {
    051    return new TupleEntrySchemeCollector<Properties, OutputStream>( flowProcess, getScheme(), System.out );
    052    }
    053
    054  @Override
    055  public boolean createResource( Properties conf ) throws IOException
    056    {
    057    return true;
    058    }
    059
    060  @Override
    061  public boolean deleteResource( Properties conf ) throws IOException
    062    {
    063    return false;
    064    }
    065
    066  @Override
    067  public boolean resourceExists( Properties conf ) throws IOException
    068    {
    069    return true;
    070    }
    071
    072  @Override
    073  public long getModifiedTime( Properties conf ) throws IOException
    074    {
    075    return 0;
    076    }
    077  }