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 * @since 1.0 36 */ 37 @Component( role = SinkFactory.class, hint = "itext" ) 38 public class ITextSinkFactory 39 extends AbstractTextSinkFactory 40 { 41 /** {@inheritDoc} */ 42 protected Sink createSink( Writer writer, String encoding ) 43 { 44 return new ITextSink( writer, encoding ); 45 } 46 47 /** 48 * createSink. 49 * 50 * @param writer a {@link java.io.Writer} object. 51 * @return a {@link org.apache.maven.doxia.sink.Sink} object. 52 */ 53 public Sink createSink( Writer writer ) 54 { 55 // TODO: should this method be deprecated? 56 return createSink( writer, WriterFactory.UTF_8 ); 57 } 58 59 /** 60 * Create a <code>Sink</code> into a PrettyPrintXMLWriter. 61 * 62 * @param xmlWriter not null XML writer to write the result. 63 * @return a <code>Sink</code> instance. 64 */ 65 public Sink createSink( PrettyPrintXMLWriter xmlWriter ) 66 { 67 if ( xmlWriter == null ) 68 { 69 throw new IllegalArgumentException( "xmlWriter could not be null." ); 70 } 71 72 return new ITextSink( xmlWriter ); 73 } 74 }