View Javadoc
1   package org.apache.maven.doxia.module.itext;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.Writer;
23  
24  import org.apache.maven.doxia.sink.Sink;
25  import org.apache.maven.doxia.sink.SinkFactory;
26  import org.apache.maven.doxia.sink.impl.AbstractTextSinkFactory;
27  import org.codehaus.plexus.component.annotations.Component;
28  import org.codehaus.plexus.util.WriterFactory;
29  import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
30  
31  /**
32   * IText implementation of the Sink factory.
33   *
34   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
35   * @version $Id: ITextSinkFactory.java 1726411 2016-01-23 16:34:09Z hboutemy $
36   * @since 1.0
37   */
38  @Component( role = SinkFactory.class, hint = "itext" )
39  public class ITextSinkFactory
40      extends AbstractTextSinkFactory
41  {
42      /** {@inheritDoc} */
43      protected Sink createSink( Writer writer, String encoding )
44      {
45          return new ITextSink( writer, encoding );
46      }
47  
48      /**
49       * createSink.
50       *
51       * @param writer a {@link java.io.Writer} object.
52       * @return a {@link org.apache.maven.doxia.sink.Sink} object.
53       */
54      public Sink createSink( Writer writer )
55      {
56          // TODO: should this method be deprecated?
57          return createSink( writer, WriterFactory.UTF_8 );
58      }
59  
60      /**
61       * Create a <code>Sink</code> into a PrettyPrintXMLWriter.
62       *
63       * @param xmlWriter not null XML writer to write the result.
64       * @return a <code>Sink</code> instance.
65       */
66      public Sink createSink( PrettyPrintXMLWriter xmlWriter )
67      {
68          if ( xmlWriter == null )
69          {
70              throw new IllegalArgumentException( "xmlWriter could not be null." );
71          }
72  
73          return new ITextSink( xmlWriter );
74      }
75  }