001package org.apache.maven.doxia.sink;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  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,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.File;
023import java.io.IOException;
024import java.io.OutputStream;
025
026/**
027 * A factory that creates a <code>Sink</code> object.
028 *
029 * @author <a href="kenney@apache.org">Kenney Westerhof</a>
030 * @since 1.0-alpha-9
031 */
032public interface SinkFactory
033{
034    /** The Plexus SinkFactory Role. */
035    String ROLE = SinkFactory.class.getName();
036
037    /**
038     * Create a <code>Sink</code> into a file.
039     *
040     * @param outputDir the not-null output dir.
041     * @param outputName the not-null output name.
042     * @return a <code>Sink</code> instance with a file as output.
043     * @throws java.io.IOException if any.
044     */
045    Sink createSink( File outputDir, String outputName )
046        throws IOException;
047
048    /**
049     * Create a <code>Sink</code> into a file using a specified encoding.
050     *
051     * @param outputDir the not-null output dir.
052     * @param outputName the not-null output name.
053     * @param encoding the output encoding.
054     * @return a <code>Sink</code> instance with a file as output and using specified encoding.
055     * @see #createSink(File, String)
056     * @since 1.1
057     * @throws java.io.IOException if any.
058     */
059    Sink createSink( File outputDir, String outputName, String encoding )
060        throws IOException;
061
062    /**
063     * Create a <code>Sink</code> into an OutputStream.
064     *
065     * @param out not null OutputStream to write the result.
066     * @return a <code>Sink</code> instance.
067     * @since 1.1
068     * @throws java.io.IOException if any.
069     */
070    Sink createSink( OutputStream out )
071        throws IOException;
072
073    /**
074     * Create a <code>Sink</code> into an OutputStream using a specified encoding.
075     *
076     * @param out not null OutputStream to write the result.
077     * @param encoding the output encoding.
078     * @return a <code>Sink</code> instance using specified encoding.
079     * @since 1.1
080     * @throws java.io.IOException if any.
081     */
082    Sink createSink( OutputStream out, String encoding )
083        throws IOException;
084}