This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch DOXIA-632 in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
commit d6c3baa625b48db6f2df3670c5d1f86b5a2b2eab Author: Michael Osipov <[email protected]> AuthorDate: Fri Dec 31 01:22:37 2021 +0100 [DOXIA-632] Remove remaining deprecated code This closes #81 --- .../org/apache/maven/doxia/macro/MacroRequest.java | 13 - .../apache/maven/doxia/parser/ParseException.java | 30 - .../doxia/parser/module/AbstractParserModule.java | 17 - .../doxia/sink/impl/AbstractBinarySinkFactory.java | 79 - .../maven/doxia/sink/impl/RandomAccessSink.java | 2669 ++++++++++---------- .../apache/maven/doxia/sink/impl/SinkAdapter.java | 38 +- .../maven/doxia/sink/impl/Xhtml5BaseSink.java | 50 - .../maven/doxia/sink/impl/XhtmlBaseSink.java | 51 - .../org/apache/maven/doxia/util/DoxiaUtils.java | 16 - .../apache/maven/doxia/macro/EchoMacroTest.java | 7 +- .../doxia/macro/snippet/SnippetMacroTest.java | 7 +- .../apache/maven/doxia/macro/toc/TocMacroTest.java | 14 +- .../maven/doxia/sink/impl/SinkAdapterTest.java | 14 - .../doxia/sink/impl/SinkEventTestingSink.java | 18 - .../org/apache/maven/doxia/sink/impl/TextSink.java | 20 +- .../sink/impl/WellformednessCheckingSink.java | 20 +- .../maven/doxia/sink/impl/Xhtml5BaseSinkTest.java | 2 +- .../maven/doxia/sink/impl/XhtmlBaseSinkTest.java | 2 +- .../org/apache/maven/doxia/module/apt/AptSink.java | 24 +- .../apache/maven/doxia/module/apt/AptUtils.java | 53 - .../maven/doxia/module/apt/AptUtilsTest.java | 21 - .../apache/maven/doxia/module/xdoc/XdocSink.java | 10 - .../maven/doxia/module/xdoc/XmlWriterXdocSink.java | 86 - .../doxia/module/xdoc/XmlWriterXdocSinkTest.java | 115 - .../java/org/apache/maven/doxia/sink/Sink.java | 24 - .../main/java/org/codehaus/doxia/sink/Sink.java | 31 - 26 files changed, 1356 insertions(+), 2075 deletions(-) diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroRequest.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroRequest.java index d83ca19..4544f69 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroRequest.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroRequest.java @@ -44,19 +44,6 @@ public class MacroRequest private Map<String, Object> parameters; /** - * Constructor. - * - * @param param A map of parameters. - * @param base The current base directory. - * @deprecated prefer other constructor - */ - public MacroRequest( Map<String, Object> param, File base ) - { - this.parameters = param; - this.basedir = base; - } - - /** * <p>Constructor for MacroRequest.</p> * * @param sourceContent a {@link java.lang.String} object. diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/ParseException.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/ParseException.java index 96d1ea9..1db3051 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/ParseException.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/ParseException.java @@ -105,19 +105,6 @@ public class ParseException } /** - * Constructs a new exception with the specified cause. The error message is - * (cause == null ? null : cause.toString() ). - * - * @param e the cause. This can be retrieved later by the <code>Throwable.getCause()</code> method. - * (A null value is permitted, and indicates that the cause is nonexistent or unknown.) - * @deprecated Using {@link #ParseException(Exception, int, int)} to specify the line and column number. - */ - public ParseException( Exception e ) - { - this( e, null, null, -1, -1 ); - } - - /** * Constructs a new exception with the specified cause, line number and column number. The error message is * (cause == null ? null : cause.toString() ). * @@ -136,23 +123,6 @@ public class ParseException /** * Construct a new <code>ParseException</code> with the specified cause, - * filename and linenumber. - * - * @param e the cause. This can be retrieved later by the <code>Throwable.getCause()</code> method. - * (A null value is permitted, and indicates that the cause is nonexistent or unknown.) - * @param file Name of a file that couldn't be parsed. - * This can later be retrieved by the getFileName() method. - * @param line The line number where the parsing failed. - * This can later be retrieved by the getLineNumber() method. - * @deprecated Using {@link #ParseException(Exception, String, int, int)} to specify the column number. - */ - public ParseException( Exception e, String file, int line ) - { - this( e, null, file, line, -1 ); - } - - /** - * Construct a new <code>ParseException</code> with the specified cause, * filename, line number and column number. * * @param e the cause. This can be retrieved later by the <code>Throwable.getCause()</code> method. diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/module/AbstractParserModule.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/module/AbstractParserModule.java index 1cb37ad..e231206 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/module/AbstractParserModule.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/module/AbstractParserModule.java @@ -69,23 +69,6 @@ public abstract class AbstractParserModule * <p>Constructor for AbstractParserModule.</p> * * @param sourceDirectory not null - * @param extension not null - * @param parserId not null - * @since 1.1.1 - * @deprecated can cause confusion with constructor with multiple extensions - */ - protected AbstractParserModule( String sourceDirectory, String extension, String parserId ) - { - super(); - this.sourceDirectory = sourceDirectory; - this.extensions = new String[] { extension }; - this.parserId = parserId; - } - - /** - * <p>Constructor for AbstractParserModule.</p> - * - * @param sourceDirectory not null * @param parserId not null (usually equals sourceDirectory) * @param extensions not null * @since 1.7 diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractBinarySinkFactory.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractBinarySinkFactory.java deleted file mode 100644 index 2485c86..0000000 --- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractBinarySinkFactory.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.maven.doxia.sink.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.sink.SinkFactory; -import org.codehaus.plexus.util.WriterFactory; - -/** - * An abstract <code>SinkFactory</code> for binary output. - * - * @author <a href="mailto:[email protected]">Hervé Boutemy</a> - * @since 1.1 - */ -public abstract class AbstractBinarySinkFactory - implements SinkFactory -{ - /** {@inheritDoc} */ - public Sink createSink( File outputDir, String outputName ) - throws IOException - { - return createSink( outputDir, outputName, WriterFactory.UTF_8 ); - } - - /** {@inheritDoc} */ - public Sink createSink( File outputDir, String outputName, String encoding ) - throws IOException - { - if ( outputDir == null ) - { - throw new IllegalArgumentException( "outputDir cannot be null." ); - } - - if ( !outputDir.exists() ) - { - outputDir.mkdirs(); - } - else - { - if ( !outputDir.isDirectory() ) - { - throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a directory." ); - } - } - - OutputStream out = new FileOutputStream( new File( outputDir, outputName ) ); - - return createSink( out, encoding ); - } - - /** {@inheritDoc} */ - public Sink createSink( OutputStream out ) - throws IOException - { - return createSink( out, WriterFactory.UTF_8 ); - } -} diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/RandomAccessSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/RandomAccessSink.java index 85665b2..3cbd943 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/RandomAccessSink.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/RandomAccessSink.java @@ -1,1345 +1,1324 @@ -package org.apache.maven.doxia.sink.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.sink.SinkEventAttributes; -import org.apache.maven.doxia.sink.SinkFactory; - -/** - * The RandomAccessSink provides the ability to create a {@link Sink} with hooks. - * A page can be prepared by first creating its structure and specifying the positions of these hooks. - * After specifying the structure, the page can be filled with content from one or more models. - * These hooks can prevent you to have to loop over the model multiple times to build the page as desired. - * - * @author Robert Scholte - * @since 1.3 - */ -public class RandomAccessSink - implements Sink -{ - private SinkFactory sinkFactory; - - private String encoding; - - private OutputStream coreOutputStream; - - private Sink coreSink; - - private List<Sink> sinks = new ArrayList<>(); - - private List<ByteArrayOutputStream> outputStreams = new ArrayList<>(); - - private Sink currentSink; - - /** - * <p>Constructor for RandomAccessSink.</p> - * - * @param sinkFactory a {@link org.apache.maven.doxia.sink.SinkFactory} object. - * @param stream a {@link java.io.OutputStream} object. - * @throws java.io.IOException if any. - */ - public RandomAccessSink( SinkFactory sinkFactory, OutputStream stream ) - throws IOException - { - this.sinkFactory = sinkFactory; - this.coreOutputStream = stream; - this.currentSink = sinkFactory.createSink( stream ); - this.coreSink = this.currentSink; - } - - /** - * <p>Constructor for RandomAccessSink.</p> - * - * @param sinkFactory a {@link org.apache.maven.doxia.sink.SinkFactory} object. - * @param stream a {@link java.io.OutputStream} object. - * @param encoding a {@link java.lang.String} object. - * @throws java.io.IOException if any. - */ - public RandomAccessSink( SinkFactory sinkFactory, OutputStream stream, String encoding ) - throws IOException - { - this.sinkFactory = sinkFactory; - this.coreOutputStream = stream; - this.encoding = encoding; - this.currentSink = sinkFactory.createSink( stream, encoding ); - this.coreSink = this.currentSink; - } - - /** - * <p>Constructor for RandomAccessSink.</p> - * - * @param sinkFactory a {@link org.apache.maven.doxia.sink.SinkFactory} object. - * @param outputDirectory a {@link java.io.File} object. - * @param outputName a {@link java.lang.String} object. - * @throws java.io.IOException if any. - */ - public RandomAccessSink( SinkFactory sinkFactory, File outputDirectory, String outputName ) - throws IOException - { - this.sinkFactory = sinkFactory; - this.coreOutputStream = new FileOutputStream( new File( outputDirectory, outputName ) ); - this.currentSink = sinkFactory.createSink( coreOutputStream ); - this.coreSink = this.currentSink; - } - - /** - * <p>Constructor for RandomAccessSink.</p> - * - * @param sinkFactory a {@link org.apache.maven.doxia.sink.SinkFactory} object. - * @param outputDirectory a {@link java.io.File} object. - * @param outputName a {@link java.lang.String} object. - * @param encoding a {@link java.lang.String} object. - * @throws java.io.IOException if any. - */ - public RandomAccessSink( SinkFactory sinkFactory, File outputDirectory, String outputName, String encoding ) - throws IOException - { - this.sinkFactory = sinkFactory; - this.coreOutputStream = new FileOutputStream( new File( outputDirectory, outputName ) ); - this.encoding = encoding; - this.currentSink = sinkFactory.createSink( coreOutputStream, encoding ); - this.coreSink = this.currentSink; - } - - /** {@inheritDoc} */ - @Override - public void address() - { - currentSink.address(); - } - - /** {@inheritDoc} */ - @Override - public void address( SinkEventAttributes attributes ) - { - currentSink.address( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void address_() - { - currentSink.address_(); - } - - /** - * By calling this method a sink reference is added at the current position. You can write to both the new sink - * reference and the original sink. After flushing all sinks will be flushed in the right order. - * - * @return a subsink reference you can write to - */ - public Sink addSinkHook() - { - Sink subSink = null; - try - { - ByteArrayOutputStream subOut = new ByteArrayOutputStream(); - ByteArrayOutputStream newOut = new ByteArrayOutputStream(); - - outputStreams.add( subOut ); - outputStreams.add( newOut ); - - if ( encoding != null ) - { - subSink = sinkFactory.createSink( subOut, encoding ); - currentSink = sinkFactory.createSink( newOut, encoding ); - } - else - { - subSink = sinkFactory.createSink( subOut ); - currentSink = sinkFactory.createSink( newOut ); - } - sinks.add( subSink ); - sinks.add( currentSink ); - } - catch ( IOException e ) - { - // IOException can only be caused by our own ByteArrayOutputStream - } - return subSink; - } - - /** {@inheritDoc} */ - @Override - public void anchor( String name ) - { - currentSink.anchor( name ); - } - - /** {@inheritDoc} */ - @Override - public void anchor( String name, SinkEventAttributes attributes ) - { - currentSink.anchor( name, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void anchor_() - { - currentSink.anchor_(); - } - - /** {@inheritDoc} */ - @Override - public void article() - { - currentSink.article(); - } - - /** {@inheritDoc} */ - @Override - public void article( SinkEventAttributes attributes ) - { - currentSink.article( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void article_() - { - currentSink.article_(); - } - - /** {@inheritDoc} */ - @Override - public void author() - { - currentSink.author(); - } - - /** {@inheritDoc} */ - @Override - public void author( SinkEventAttributes attributes ) - { - currentSink.author( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void author_() - { - currentSink.author_(); - } - - /** {@inheritDoc} */ - @Override - public void blockquote() - { - currentSink.blockquote(); - } - - /** {@inheritDoc} */ - @Override - public void blockquote( SinkEventAttributes attributes ) - { - currentSink.blockquote( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void blockquote_() - { - currentSink.blockquote_(); - } - - /** {@inheritDoc} */ - @Override - public void body() - { - currentSink.body(); - } - - /** {@inheritDoc} */ - @Override - public void body( SinkEventAttributes attributes ) - { - currentSink.body( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void body_() - { - currentSink.body_(); - } - - /** {@inheritDoc} */ - @Override - public void bold() - { - currentSink.bold(); - } - - /** {@inheritDoc} */ - @Override - public void bold_() - { - currentSink.bold_(); - } - - /** - * Close all sinks - */ - public void close() - { - for ( Sink sink : sinks ) - { - // sink is responsible for closing it's stream - sink.close(); - } - coreSink.close(); - } - - /** {@inheritDoc} */ - @Override - public void comment( String comment ) - { - currentSink.comment( comment ); - } - - /** {@inheritDoc} */ - @Override - public void content() - { - currentSink.content(); - } - - /** {@inheritDoc} */ - @Override - public void content( SinkEventAttributes attributes ) - { - currentSink.content( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void content_() - { - currentSink.content_(); - } - - /** {@inheritDoc} */ - @Override - public void data( String value ) - { - currentSink.data( value ); - } - - /** {@inheritDoc} */ - @Override - public void data( String value, SinkEventAttributes attributes ) - { - currentSink.data( value, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void data_() - { - currentSink.data_(); - } - - /** {@inheritDoc} */ - @Override - public void date() - { - currentSink.date(); - } - - /** {@inheritDoc} */ - @Override - public void date( SinkEventAttributes attributes ) - { - currentSink.date( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void date_() - { - currentSink.date_(); - } - - /** {@inheritDoc} */ - @Override - public void definedTerm() - { - currentSink.definedTerm(); - } - - /** {@inheritDoc} */ - @Override - public void definedTerm( SinkEventAttributes attributes ) - { - currentSink.definedTerm( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void definedTerm_() - { - currentSink.definedTerm_(); - } - - /** {@inheritDoc} */ - @Override - public void definition() - { - currentSink.definition(); - } - - /** {@inheritDoc} */ - @Override - public void definition( SinkEventAttributes attributes ) - { - currentSink.definition( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void definitionList() - { - currentSink.definitionList(); - } - - /** {@inheritDoc} */ - @Override - public void definitionList( SinkEventAttributes attributes ) - { - currentSink.definitionList( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void definitionListItem() - { - currentSink.definitionListItem(); - } - - /** {@inheritDoc} */ - @Override - public void definitionListItem( SinkEventAttributes attributes ) - { - currentSink.definitionListItem( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void definitionListItem_() - { - currentSink.definitionListItem_(); - } - - /** {@inheritDoc} */ - @Override - public void definitionList_() - { - currentSink.definitionList_(); - } - - /** {@inheritDoc} */ - @Override - public void definition_() - { - currentSink.definition_(); - } - - /** {@inheritDoc} */ - @Override - public void division() - { - currentSink.division(); - } - - /** {@inheritDoc} */ - @Override - public void division( SinkEventAttributes attributes ) - { - currentSink.division( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void division_() - { - currentSink.division_(); - } - - /** {@inheritDoc} */ - @Override - public void figure() - { - currentSink.figure(); - } - - /** {@inheritDoc} */ - @Override - public void figure( SinkEventAttributes attributes ) - { - currentSink.figure( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void figureCaption() - { - currentSink.figureCaption(); - } - - /** {@inheritDoc} */ - @Override - public void figureCaption( SinkEventAttributes attributes ) - { - currentSink.figureCaption( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void figureCaption_() - { - currentSink.figureCaption_(); - } - - /** {@inheritDoc} */ - @Override - public void figureGraphics( String name ) - { - currentSink.figureGraphics( name ); - } - - /** {@inheritDoc} */ - @Override - public void figureGraphics( String src, SinkEventAttributes attributes ) - { - currentSink.figureGraphics( src, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void figure_() - { - currentSink.figure_(); - } - - /** - * Flush all sinks - */ - public void flush() - { - for ( int i = 0; i < sinks.size(); i++ ) - { - // first flush to get complete buffer - // sink is responsible for flushing it's stream - Sink sink = sinks.get( i ); - sink.flush(); - - ByteArrayOutputStream stream = outputStreams.get( i ); - try - { - coreOutputStream.write( stream.toByteArray() ); - } - catch ( IOException e ) - { - // @todo - } - } - coreSink.flush(); - } - - /** {@inheritDoc} */ - @Override - public void footer() - { - currentSink.footer(); - } - - /** {@inheritDoc} */ - @Override - public void footer( SinkEventAttributes attributes ) - { - currentSink.footer( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void footer_() - { - currentSink.footer_(); - } - - /** {@inheritDoc} */ - @Override - public void head() - { - currentSink.head(); - } - - /** {@inheritDoc} */ - @Override - public void head( SinkEventAttributes attributes ) - { - currentSink.head( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void head_() - { - currentSink.head_(); - } - - /** {@inheritDoc} */ - @Override - public void header() - { - currentSink.header(); - } - - /** {@inheritDoc} */ - @Override - public void header( SinkEventAttributes attributes ) - { - currentSink.header( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void header_() - { - currentSink.header_(); - } - - /** {@inheritDoc} */ - @Override - public void horizontalRule() - { - currentSink.horizontalRule(); - } - - /** {@inheritDoc} */ - @Override - public void horizontalRule( SinkEventAttributes attributes ) - { - currentSink.horizontalRule( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void inline() - { - currentSink.inline(); - } - - /** {@inheritDoc} */ - @Override - public void inline( SinkEventAttributes attributes ) - { - currentSink.inline( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void inline_() - { - currentSink.inline_(); - } - - /** {@inheritDoc} */ - @Override - public void italic() - { - currentSink.italic(); - } - - /** {@inheritDoc} */ - @Override - public void italic_() - { - currentSink.italic_(); - } - - /** {@inheritDoc} */ - @Override - public void lineBreak() - { - currentSink.lineBreak(); - } - - /** {@inheritDoc} */ - @Override - public void lineBreak( SinkEventAttributes attributes ) - { - currentSink.lineBreak( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void lineBreakOpportunity() - { - currentSink.lineBreakOpportunity(); - } - - /** {@inheritDoc} */ - @Override - public void lineBreakOpportunity( SinkEventAttributes attributes ) - { - currentSink.lineBreakOpportunity( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void link( String name ) - { - currentSink.link( name ); - } - - /** {@inheritDoc} */ - @Override - public void link( String name, SinkEventAttributes attributes ) - { - currentSink.link( name, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void link_() - { - currentSink.link_(); - } - - /** {@inheritDoc} */ - @Override - public void list() - { - currentSink.list(); - } - - /** {@inheritDoc} */ - @Override - public void list( SinkEventAttributes attributes ) - { - currentSink.list( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void listItem() - { - currentSink.listItem(); - } - - /** {@inheritDoc} */ - @Override - public void listItem( SinkEventAttributes attributes ) - { - currentSink.listItem( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void listItem_() - { - currentSink.listItem_(); - } - - /** {@inheritDoc} */ - @Override - public void list_() - { - currentSink.list_(); - } - - /** {@inheritDoc} */ - @Override - public void monospaced() - { - currentSink.monospaced(); - } - - /** {@inheritDoc} */ - @Override - public void monospaced_() - { - currentSink.monospaced_(); - } - - /** {@inheritDoc} */ - @Override - public void navigation() - { - currentSink.navigation(); - } - - /** {@inheritDoc} */ - @Override - public void navigation( SinkEventAttributes attributes ) - { - currentSink.navigation( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void navigation_() - { - currentSink.navigation_(); - } - - /** {@inheritDoc} */ - @Override - public void nonBreakingSpace() - { - currentSink.nonBreakingSpace(); - } - - /** {@inheritDoc} */ - @Override - public void numberedList( int numbering ) - { - currentSink.numberedList( numbering ); - } - - /** {@inheritDoc} */ - @Override - public void numberedList( int numbering, SinkEventAttributes attributes ) - { - currentSink.numberedList( numbering, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void numberedListItem() - { - currentSink.numberedListItem(); - } - - /** {@inheritDoc} */ - @Override - public void numberedListItem( SinkEventAttributes attributes ) - { - currentSink.numberedListItem( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void numberedListItem_() - { - currentSink.numberedListItem_(); - } - - /** {@inheritDoc} */ - @Override - public void numberedList_() - { - currentSink.numberedList_(); - } - - /** {@inheritDoc} */ - @Override - public void pageBreak() - { - currentSink.pageBreak(); - } - - /** {@inheritDoc} */ - @Override - public void paragraph() - { - currentSink.paragraph(); - } - - /** {@inheritDoc} */ - @Override - public void paragraph( SinkEventAttributes attributes ) - { - currentSink.paragraph( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void paragraph_() - { - currentSink.paragraph_(); - } - - /** {@inheritDoc} */ - @Override - public void rawText( String text ) - { - currentSink.rawText( text ); - } - - /** {@inheritDoc} */ - @Override - public void section( int level, SinkEventAttributes attributes ) - { - currentSink.section( level, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void section1() - { - currentSink.section1(); - } - - /** {@inheritDoc} */ - @Override - public void section1_() - { - currentSink.section1_(); - } - - /** {@inheritDoc} */ - @Override - public void section2() - { - currentSink.section2(); - } - - /** {@inheritDoc} */ - @Override - public void section2_() - { - currentSink.section2_(); - } - - /** {@inheritDoc} */ - @Override - public void section3() - { - currentSink.section3(); - } - - /** {@inheritDoc} */ - @Override - public void section3_() - { - currentSink.section3_(); - } - - /** {@inheritDoc} */ - @Override - public void section4() - { - currentSink.section4(); - } - - /** {@inheritDoc} */ - @Override - public void section4_() - { - currentSink.section4_(); - } - - /** {@inheritDoc} */ - @Override - public void section5() - { - currentSink.section5(); - } - - /** {@inheritDoc} */ - @Override - public void section5_() - { - currentSink.section5_(); - } - - /** {@inheritDoc} */ - @Override - public void section6() - { - currentSink.section5(); - } - - /** {@inheritDoc} */ - @Override - public void section6_() - { - currentSink.section5_(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle() - { - currentSink.sectionTitle(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle( int level, SinkEventAttributes attributes ) - { - currentSink.sectionTitle( level, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle1() - { - currentSink.sectionTitle1(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle1_() - { - currentSink.sectionTitle1_(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle2() - { - currentSink.sectionTitle2(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle2_() - { - currentSink.sectionTitle2_(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle3() - { - currentSink.sectionTitle3(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle3_() - { - currentSink.sectionTitle3_(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle4() - { - currentSink.sectionTitle4(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle4_() - { - currentSink.sectionTitle4_(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle5() - { - currentSink.sectionTitle5(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle5_() - { - currentSink.sectionTitle5_(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle6() - { - currentSink.sectionTitle5(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle6_() - { - currentSink.sectionTitle5_(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle_() - { - currentSink.sectionTitle_(); - } - - /** {@inheritDoc} */ - @Override - public void sectionTitle_( int level ) - { - currentSink.sectionTitle_( level ); - } - - /** {@inheritDoc} */ - @Override - public void section_( int level ) - { - currentSink.section_( level ); - } - - /** {@inheritDoc} */ - @Override - public void sidebar() - { - currentSink.sidebar(); - } - - /** {@inheritDoc} */ - @Override - public void sidebar( SinkEventAttributes attributes ) - { - currentSink.sidebar( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void sidebar_() - { - currentSink.sidebar_(); - } - - /** {@inheritDoc} */ - @Override - public void table() - { - currentSink.table(); - } - - /** {@inheritDoc} */ - @Override - public void table( SinkEventAttributes attributes ) - { - currentSink.table( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void tableCaption() - { - currentSink.tableCaption(); - } - - /** {@inheritDoc} */ - @Override - public void tableCaption( SinkEventAttributes attributes ) - { - currentSink.tableCaption( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void tableCaption_() - { - currentSink.tableCaption_(); - } - - /** {@inheritDoc} */ - @Override - public void tableCell() - { - currentSink.tableCell(); - } - - /** {@inheritDoc} */ - @Override - public void tableCell( String width ) - { - currentSink.tableCell( width ); - } - - /** {@inheritDoc} */ - @Override - public void tableCell( SinkEventAttributes attributes ) - { - currentSink.tableCell( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void tableCell_() - { - currentSink.tableCell_(); - } - - /** {@inheritDoc} */ - @Override - public void tableHeaderCell() - { - currentSink.tableHeaderCell(); - } - - /** {@inheritDoc} */ - @Override - public void tableHeaderCell( String width ) - { - currentSink.tableHeaderCell( width ); - } - - /** {@inheritDoc} */ - @Override - public void tableHeaderCell( SinkEventAttributes attributes ) - { - currentSink.tableHeaderCell( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void tableHeaderCell_() - { - currentSink.tableHeaderCell_(); - } - - /** {@inheritDoc} */ - @Override - public void tableRow() - { - currentSink.tableRow(); - } - - /** {@inheritDoc} */ - @Override - public void tableRow( SinkEventAttributes attributes ) - { - currentSink.tableRow( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void tableRow_() - { - currentSink.tableRow_(); - } - - /** {@inheritDoc} */ - @Override - public void tableRows( int[] justification, boolean grid ) - { - currentSink.tableRows( justification, grid ); - } - - /** {@inheritDoc} */ - @Override - public void tableRows_() - { - currentSink.tableRows_(); - } - - /** {@inheritDoc} */ - @Override - public void table_() - { - currentSink.table_(); - } - - /** {@inheritDoc} */ - @Override - public void text( String text ) - { - currentSink.text( text ); - } - - /** {@inheritDoc} */ - @Override - public void text( String text, SinkEventAttributes attributes ) - { - currentSink.text( text, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void time( String datetime ) - { - currentSink.time( datetime ); - } - - /** {@inheritDoc} */ - @Override - public void time( String datetime, SinkEventAttributes attributes ) - { - currentSink.time( datetime, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void time_() - { - currentSink.time_(); - } - - /** {@inheritDoc} */ - @Override - public void title() - { - currentSink.title(); - } - - /** {@inheritDoc} */ - @Override - public void title( SinkEventAttributes attributes ) - { - currentSink.title( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void title_() - { - currentSink.title_(); - } - - /** {@inheritDoc} */ - @Override - public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes ) - { - currentSink.unknown( name, requiredParams, attributes ); - } - - /** {@inheritDoc} */ - @Override - public void verbatim( boolean boxed ) - { - currentSink.verbatim( boxed ); - } - - /** {@inheritDoc} */ - @Override - public void verbatim( SinkEventAttributes attributes ) - { - currentSink.verbatim( attributes ); - } - - /** {@inheritDoc} */ - @Override - public void verbatim_() - { - currentSink.verbatim_(); - } -} +package org.apache.maven.doxia.sink.impl; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.doxia.sink.SinkEventAttributes; +import org.apache.maven.doxia.sink.SinkFactory; + +/** + * The RandomAccessSink provides the ability to create a {@link Sink} with hooks. + * A page can be prepared by first creating its structure and specifying the positions of these hooks. + * After specifying the structure, the page can be filled with content from one or more models. + * These hooks can prevent you to have to loop over the model multiple times to build the page as desired. + * + * @author Robert Scholte + * @since 1.3 + */ +public class RandomAccessSink + implements Sink +{ + private SinkFactory sinkFactory; + + private String encoding; + + private OutputStream coreOutputStream; + + private Sink coreSink; + + private List<Sink> sinks = new ArrayList<>(); + + private List<ByteArrayOutputStream> outputStreams = new ArrayList<>(); + + private Sink currentSink; + + /** + * <p>Constructor for RandomAccessSink.</p> + * + * @param sinkFactory a {@link org.apache.maven.doxia.sink.SinkFactory} object. + * @param stream a {@link java.io.OutputStream} object. + * @throws java.io.IOException if any. + */ + public RandomAccessSink( SinkFactory sinkFactory, OutputStream stream ) + throws IOException + { + this.sinkFactory = sinkFactory; + this.coreOutputStream = stream; + this.currentSink = sinkFactory.createSink( stream ); + this.coreSink = this.currentSink; + } + + /** + * <p>Constructor for RandomAccessSink.</p> + * + * @param sinkFactory a {@link org.apache.maven.doxia.sink.SinkFactory} object. + * @param stream a {@link java.io.OutputStream} object. + * @param encoding a {@link java.lang.String} object. + * @throws java.io.IOException if any. + */ + public RandomAccessSink( SinkFactory sinkFactory, OutputStream stream, String encoding ) + throws IOException + { + this.sinkFactory = sinkFactory; + this.coreOutputStream = stream; + this.encoding = encoding; + this.currentSink = sinkFactory.createSink( stream, encoding ); + this.coreSink = this.currentSink; + } + + /** + * <p>Constructor for RandomAccessSink.</p> + * + * @param sinkFactory a {@link org.apache.maven.doxia.sink.SinkFactory} object. + * @param outputDirectory a {@link java.io.File} object. + * @param outputName a {@link java.lang.String} object. + * @throws java.io.IOException if any. + */ + public RandomAccessSink( SinkFactory sinkFactory, File outputDirectory, String outputName ) + throws IOException + { + this.sinkFactory = sinkFactory; + this.coreOutputStream = new FileOutputStream( new File( outputDirectory, outputName ) ); + this.currentSink = sinkFactory.createSink( coreOutputStream ); + this.coreSink = this.currentSink; + } + + /** + * <p>Constructor for RandomAccessSink.</p> + * + * @param sinkFactory a {@link org.apache.maven.doxia.sink.SinkFactory} object. + * @param outputDirectory a {@link java.io.File} object. + * @param outputName a {@link java.lang.String} object. + * @param encoding a {@link java.lang.String} object. + * @throws java.io.IOException if any. + */ + public RandomAccessSink( SinkFactory sinkFactory, File outputDirectory, String outputName, String encoding ) + throws IOException + { + this.sinkFactory = sinkFactory; + this.coreOutputStream = new FileOutputStream( new File( outputDirectory, outputName ) ); + this.encoding = encoding; + this.currentSink = sinkFactory.createSink( coreOutputStream, encoding ); + this.coreSink = this.currentSink; + } + + /** {@inheritDoc} */ + @Override + public void address() + { + currentSink.address(); + } + + /** {@inheritDoc} */ + @Override + public void address( SinkEventAttributes attributes ) + { + currentSink.address( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void address_() + { + currentSink.address_(); + } + + /** + * By calling this method a sink reference is added at the current position. You can write to both the new sink + * reference and the original sink. After flushing all sinks will be flushed in the right order. + * + * @return a subsink reference you can write to + */ + public Sink addSinkHook() + { + Sink subSink = null; + try + { + ByteArrayOutputStream subOut = new ByteArrayOutputStream(); + ByteArrayOutputStream newOut = new ByteArrayOutputStream(); + + outputStreams.add( subOut ); + outputStreams.add( newOut ); + + if ( encoding != null ) + { + subSink = sinkFactory.createSink( subOut, encoding ); + currentSink = sinkFactory.createSink( newOut, encoding ); + } + else + { + subSink = sinkFactory.createSink( subOut ); + currentSink = sinkFactory.createSink( newOut ); + } + sinks.add( subSink ); + sinks.add( currentSink ); + } + catch ( IOException e ) + { + // IOException can only be caused by our own ByteArrayOutputStream + } + return subSink; + } + + /** {@inheritDoc} */ + @Override + public void anchor( String name ) + { + currentSink.anchor( name ); + } + + /** {@inheritDoc} */ + @Override + public void anchor( String name, SinkEventAttributes attributes ) + { + currentSink.anchor( name, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void anchor_() + { + currentSink.anchor_(); + } + + /** {@inheritDoc} */ + @Override + public void article() + { + currentSink.article(); + } + + /** {@inheritDoc} */ + @Override + public void article( SinkEventAttributes attributes ) + { + currentSink.article( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void article_() + { + currentSink.article_(); + } + + /** {@inheritDoc} */ + @Override + public void author() + { + currentSink.author(); + } + + /** {@inheritDoc} */ + @Override + public void author( SinkEventAttributes attributes ) + { + currentSink.author( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void author_() + { + currentSink.author_(); + } + + /** {@inheritDoc} */ + @Override + public void blockquote() + { + currentSink.blockquote(); + } + + /** {@inheritDoc} */ + @Override + public void blockquote( SinkEventAttributes attributes ) + { + currentSink.blockquote( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void blockquote_() + { + currentSink.blockquote_(); + } + + /** {@inheritDoc} */ + @Override + public void body() + { + currentSink.body(); + } + + /** {@inheritDoc} */ + @Override + public void body( SinkEventAttributes attributes ) + { + currentSink.body( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void body_() + { + currentSink.body_(); + } + + /** {@inheritDoc} */ + @Override + public void bold() + { + currentSink.bold(); + } + + /** {@inheritDoc} */ + @Override + public void bold_() + { + currentSink.bold_(); + } + + /** + * Close all sinks + */ + public void close() + { + for ( Sink sink : sinks ) + { + // sink is responsible for closing it's stream + sink.close(); + } + coreSink.close(); + } + + /** {@inheritDoc} */ + @Override + public void comment( String comment ) + { + currentSink.comment( comment ); + } + + /** {@inheritDoc} */ + @Override + public void content() + { + currentSink.content(); + } + + /** {@inheritDoc} */ + @Override + public void content( SinkEventAttributes attributes ) + { + currentSink.content( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void content_() + { + currentSink.content_(); + } + + /** {@inheritDoc} */ + @Override + public void data( String value ) + { + currentSink.data( value ); + } + + /** {@inheritDoc} */ + @Override + public void data( String value, SinkEventAttributes attributes ) + { + currentSink.data( value, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void data_() + { + currentSink.data_(); + } + + /** {@inheritDoc} */ + @Override + public void date() + { + currentSink.date(); + } + + /** {@inheritDoc} */ + @Override + public void date( SinkEventAttributes attributes ) + { + currentSink.date( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void date_() + { + currentSink.date_(); + } + + /** {@inheritDoc} */ + @Override + public void definedTerm() + { + currentSink.definedTerm(); + } + + /** {@inheritDoc} */ + @Override + public void definedTerm( SinkEventAttributes attributes ) + { + currentSink.definedTerm( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void definedTerm_() + { + currentSink.definedTerm_(); + } + + /** {@inheritDoc} */ + @Override + public void definition() + { + currentSink.definition(); + } + + /** {@inheritDoc} */ + @Override + public void definition( SinkEventAttributes attributes ) + { + currentSink.definition( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void definitionList() + { + currentSink.definitionList(); + } + + /** {@inheritDoc} */ + @Override + public void definitionList( SinkEventAttributes attributes ) + { + currentSink.definitionList( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void definitionListItem() + { + currentSink.definitionListItem(); + } + + /** {@inheritDoc} */ + @Override + public void definitionListItem( SinkEventAttributes attributes ) + { + currentSink.definitionListItem( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void definitionListItem_() + { + currentSink.definitionListItem_(); + } + + /** {@inheritDoc} */ + @Override + public void definitionList_() + { + currentSink.definitionList_(); + } + + /** {@inheritDoc} */ + @Override + public void definition_() + { + currentSink.definition_(); + } + + /** {@inheritDoc} */ + @Override + public void division() + { + currentSink.division(); + } + + /** {@inheritDoc} */ + @Override + public void division( SinkEventAttributes attributes ) + { + currentSink.division( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void division_() + { + currentSink.division_(); + } + + /** {@inheritDoc} */ + @Override + public void figure() + { + currentSink.figure(); + } + + /** {@inheritDoc} */ + @Override + public void figure( SinkEventAttributes attributes ) + { + currentSink.figure( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void figureCaption() + { + currentSink.figureCaption(); + } + + /** {@inheritDoc} */ + @Override + public void figureCaption( SinkEventAttributes attributes ) + { + currentSink.figureCaption( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void figureCaption_() + { + currentSink.figureCaption_(); + } + + /** {@inheritDoc} */ + @Override + public void figureGraphics( String name ) + { + currentSink.figureGraphics( name ); + } + + /** {@inheritDoc} */ + @Override + public void figureGraphics( String src, SinkEventAttributes attributes ) + { + currentSink.figureGraphics( src, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void figure_() + { + currentSink.figure_(); + } + + /** + * Flush all sinks + */ + public void flush() + { + for ( int i = 0; i < sinks.size(); i++ ) + { + // first flush to get complete buffer + // sink is responsible for flushing it's stream + Sink sink = sinks.get( i ); + sink.flush(); + + ByteArrayOutputStream stream = outputStreams.get( i ); + try + { + coreOutputStream.write( stream.toByteArray() ); + } + catch ( IOException e ) + { + // @todo + } + } + coreSink.flush(); + } + + /** {@inheritDoc} */ + @Override + public void footer() + { + currentSink.footer(); + } + + /** {@inheritDoc} */ + @Override + public void footer( SinkEventAttributes attributes ) + { + currentSink.footer( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void footer_() + { + currentSink.footer_(); + } + + /** {@inheritDoc} */ + @Override + public void head() + { + currentSink.head(); + } + + /** {@inheritDoc} */ + @Override + public void head( SinkEventAttributes attributes ) + { + currentSink.head( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void head_() + { + currentSink.head_(); + } + + /** {@inheritDoc} */ + @Override + public void header() + { + currentSink.header(); + } + + /** {@inheritDoc} */ + @Override + public void header( SinkEventAttributes attributes ) + { + currentSink.header( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void header_() + { + currentSink.header_(); + } + + /** {@inheritDoc} */ + @Override + public void horizontalRule() + { + currentSink.horizontalRule(); + } + + /** {@inheritDoc} */ + @Override + public void horizontalRule( SinkEventAttributes attributes ) + { + currentSink.horizontalRule( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void inline() + { + currentSink.inline(); + } + + /** {@inheritDoc} */ + @Override + public void inline( SinkEventAttributes attributes ) + { + currentSink.inline( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void inline_() + { + currentSink.inline_(); + } + + /** {@inheritDoc} */ + @Override + public void italic() + { + currentSink.italic(); + } + + /** {@inheritDoc} */ + @Override + public void italic_() + { + currentSink.italic_(); + } + + /** {@inheritDoc} */ + @Override + public void lineBreak() + { + currentSink.lineBreak(); + } + + /** {@inheritDoc} */ + @Override + public void lineBreak( SinkEventAttributes attributes ) + { + currentSink.lineBreak( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void lineBreakOpportunity() + { + currentSink.lineBreakOpportunity(); + } + + /** {@inheritDoc} */ + @Override + public void lineBreakOpportunity( SinkEventAttributes attributes ) + { + currentSink.lineBreakOpportunity( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void link( String name ) + { + currentSink.link( name ); + } + + /** {@inheritDoc} */ + @Override + public void link( String name, SinkEventAttributes attributes ) + { + currentSink.link( name, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void link_() + { + currentSink.link_(); + } + + /** {@inheritDoc} */ + @Override + public void list() + { + currentSink.list(); + } + + /** {@inheritDoc} */ + @Override + public void list( SinkEventAttributes attributes ) + { + currentSink.list( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void listItem() + { + currentSink.listItem(); + } + + /** {@inheritDoc} */ + @Override + public void listItem( SinkEventAttributes attributes ) + { + currentSink.listItem( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void listItem_() + { + currentSink.listItem_(); + } + + /** {@inheritDoc} */ + @Override + public void list_() + { + currentSink.list_(); + } + + /** {@inheritDoc} */ + @Override + public void monospaced() + { + currentSink.monospaced(); + } + + /** {@inheritDoc} */ + @Override + public void monospaced_() + { + currentSink.monospaced_(); + } + + /** {@inheritDoc} */ + @Override + public void navigation() + { + currentSink.navigation(); + } + + /** {@inheritDoc} */ + @Override + public void navigation( SinkEventAttributes attributes ) + { + currentSink.navigation( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void navigation_() + { + currentSink.navigation_(); + } + + /** {@inheritDoc} */ + @Override + public void nonBreakingSpace() + { + currentSink.nonBreakingSpace(); + } + + /** {@inheritDoc} */ + @Override + public void numberedList( int numbering ) + { + currentSink.numberedList( numbering ); + } + + /** {@inheritDoc} */ + @Override + public void numberedList( int numbering, SinkEventAttributes attributes ) + { + currentSink.numberedList( numbering, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void numberedListItem() + { + currentSink.numberedListItem(); + } + + /** {@inheritDoc} */ + @Override + public void numberedListItem( SinkEventAttributes attributes ) + { + currentSink.numberedListItem( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void numberedListItem_() + { + currentSink.numberedListItem_(); + } + + /** {@inheritDoc} */ + @Override + public void numberedList_() + { + currentSink.numberedList_(); + } + + /** {@inheritDoc} */ + @Override + public void pageBreak() + { + currentSink.pageBreak(); + } + + /** {@inheritDoc} */ + @Override + public void paragraph() + { + currentSink.paragraph(); + } + + /** {@inheritDoc} */ + @Override + public void paragraph( SinkEventAttributes attributes ) + { + currentSink.paragraph( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void paragraph_() + { + currentSink.paragraph_(); + } + + /** {@inheritDoc} */ + @Override + public void rawText( String text ) + { + currentSink.rawText( text ); + } + + /** {@inheritDoc} */ + @Override + public void section( int level, SinkEventAttributes attributes ) + { + currentSink.section( level, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void section1() + { + currentSink.section1(); + } + + /** {@inheritDoc} */ + @Override + public void section1_() + { + currentSink.section1_(); + } + + /** {@inheritDoc} */ + @Override + public void section2() + { + currentSink.section2(); + } + + /** {@inheritDoc} */ + @Override + public void section2_() + { + currentSink.section2_(); + } + + /** {@inheritDoc} */ + @Override + public void section3() + { + currentSink.section3(); + } + + /** {@inheritDoc} */ + @Override + public void section3_() + { + currentSink.section3_(); + } + + /** {@inheritDoc} */ + @Override + public void section4() + { + currentSink.section4(); + } + + /** {@inheritDoc} */ + @Override + public void section4_() + { + currentSink.section4_(); + } + + /** {@inheritDoc} */ + @Override + public void section5() + { + currentSink.section5(); + } + + /** {@inheritDoc} */ + @Override + public void section5_() + { + currentSink.section5_(); + } + + /** {@inheritDoc} */ + @Override + public void section6() + { + currentSink.section5(); + } + + /** {@inheritDoc} */ + @Override + public void section6_() + { + currentSink.section5_(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle() + { + currentSink.sectionTitle(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle( int level, SinkEventAttributes attributes ) + { + currentSink.sectionTitle( level, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle1() + { + currentSink.sectionTitle1(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle1_() + { + currentSink.sectionTitle1_(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle2() + { + currentSink.sectionTitle2(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle2_() + { + currentSink.sectionTitle2_(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle3() + { + currentSink.sectionTitle3(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle3_() + { + currentSink.sectionTitle3_(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle4() + { + currentSink.sectionTitle4(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle4_() + { + currentSink.sectionTitle4_(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle5() + { + currentSink.sectionTitle5(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle5_() + { + currentSink.sectionTitle5_(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle6() + { + currentSink.sectionTitle5(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle6_() + { + currentSink.sectionTitle5_(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle_() + { + currentSink.sectionTitle_(); + } + + /** {@inheritDoc} */ + @Override + public void sectionTitle_( int level ) + { + currentSink.sectionTitle_( level ); + } + + /** {@inheritDoc} */ + @Override + public void section_( int level ) + { + currentSink.section_( level ); + } + + /** {@inheritDoc} */ + @Override + public void sidebar() + { + currentSink.sidebar(); + } + + /** {@inheritDoc} */ + @Override + public void sidebar( SinkEventAttributes attributes ) + { + currentSink.sidebar( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void sidebar_() + { + currentSink.sidebar_(); + } + + /** {@inheritDoc} */ + @Override + public void table() + { + currentSink.table(); + } + + /** {@inheritDoc} */ + @Override + public void table( SinkEventAttributes attributes ) + { + currentSink.table( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void tableCaption() + { + currentSink.tableCaption(); + } + + /** {@inheritDoc} */ + @Override + public void tableCaption( SinkEventAttributes attributes ) + { + currentSink.tableCaption( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void tableCaption_() + { + currentSink.tableCaption_(); + } + + /** {@inheritDoc} */ + @Override + public void tableCell() + { + currentSink.tableCell(); + } + + /** {@inheritDoc} */ + @Override + public void tableCell( SinkEventAttributes attributes ) + { + currentSink.tableCell( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void tableCell_() + { + currentSink.tableCell_(); + } + + /** {@inheritDoc} */ + @Override + public void tableHeaderCell() + { + currentSink.tableHeaderCell(); + } + + /** {@inheritDoc} */ + @Override + public void tableHeaderCell( SinkEventAttributes attributes ) + { + currentSink.tableHeaderCell( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void tableHeaderCell_() + { + currentSink.tableHeaderCell_(); + } + + /** {@inheritDoc} */ + @Override + public void tableRow() + { + currentSink.tableRow(); + } + + /** {@inheritDoc} */ + @Override + public void tableRow( SinkEventAttributes attributes ) + { + currentSink.tableRow( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void tableRow_() + { + currentSink.tableRow_(); + } + + /** {@inheritDoc} */ + @Override + public void tableRows( int[] justification, boolean grid ) + { + currentSink.tableRows( justification, grid ); + } + + /** {@inheritDoc} */ + @Override + public void tableRows_() + { + currentSink.tableRows_(); + } + + /** {@inheritDoc} */ + @Override + public void table_() + { + currentSink.table_(); + } + + /** {@inheritDoc} */ + @Override + public void text( String text ) + { + currentSink.text( text ); + } + + /** {@inheritDoc} */ + @Override + public void text( String text, SinkEventAttributes attributes ) + { + currentSink.text( text, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void time( String datetime ) + { + currentSink.time( datetime ); + } + + /** {@inheritDoc} */ + @Override + public void time( String datetime, SinkEventAttributes attributes ) + { + currentSink.time( datetime, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void time_() + { + currentSink.time_(); + } + + /** {@inheritDoc} */ + @Override + public void title() + { + currentSink.title(); + } + + /** {@inheritDoc} */ + @Override + public void title( SinkEventAttributes attributes ) + { + currentSink.title( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void title_() + { + currentSink.title_(); + } + + /** {@inheritDoc} */ + @Override + public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes ) + { + currentSink.unknown( name, requiredParams, attributes ); + } + + /** {@inheritDoc} */ + @Override + public void verbatim( SinkEventAttributes attributes ) + { + currentSink.verbatim( attributes ); + } + + /** {@inheritDoc} */ + @Override + public void verbatim_() + { + currentSink.verbatim_(); + } +} diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/SinkAdapter.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/SinkAdapter.java index b2c04c9..692970f 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/SinkAdapter.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/SinkAdapter.java @@ -19,8 +19,6 @@ package org.apache.maven.doxia.sink.impl; * under the License. */ -import javax.swing.text.MutableAttributeSet; - import org.apache.maven.doxia.sink.SinkEventAttributes; /** @@ -172,14 +170,14 @@ public class SinkAdapter { // nop } - + /** {@inheritDoc} */ @Override public void section6() { // nop } - + /** {@inheritDoc} */ @Override public void section6_() @@ -609,13 +607,6 @@ public class SinkAdapter /** {@inheritDoc} */ @Override - public void verbatim( boolean boxed ) - { - // nop - } - - /** {@inheritDoc} */ - @Override public void verbatim_() { // nop @@ -658,13 +649,6 @@ public class SinkAdapter /** {@inheritDoc} */ @Override - public void tableCell( String width ) - { - // nop - } - - /** {@inheritDoc} */ - @Override public void tableCell_() { // nop @@ -679,13 +663,6 @@ public class SinkAdapter /** {@inheritDoc} */ @Override - public void tableHeaderCell( String width ) - { - // nop - } - - /** {@inheritDoc} */ - @Override public void tableHeaderCell_() { // nop @@ -1204,16 +1181,7 @@ public class SinkAdapter @Override public void verbatim( SinkEventAttributes attributes ) { - MutableAttributeSet atts = SinkUtils.filterAttributes( attributes, SinkUtils.SINK_VERBATIM_ATTRIBUTES ); - - boolean boxed = false; - - if ( atts != null && atts.isDefined( SinkEventAttributes.DECORATION ) ) - { - boxed = "boxed".equals( atts.getAttribute( SinkEventAttributes.DECORATION ).toString() ); - } - - verbatim( boxed ); + // nop } /** {@inheritDoc} */ diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java index dbf2884..36f944e 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java @@ -240,16 +240,6 @@ public class Xhtml5BaseSink return Integer.parseInt( this.cellCountStack.getLast().toString() ); } - /** - * Reset all variables. - * - * @deprecated since 1.1.2, use {@link #init()} instead of. - */ - protected void resetState() - { - init(); - } - /** {@inheritDoc} */ @Override protected void init() @@ -1300,26 +1290,6 @@ public class Xhtml5BaseSink * @see javax.swing.text.html.HTML.Tag#PRE */ @Override - public void verbatim( boolean boxed ) - { - if ( boxed ) - { - verbatim( SinkEventAttributeSet.BOXED ); - } - else - { - verbatim( null ); - } - } - - /** - * The default class style for boxed is <code>source</code>. - * - * {@inheritDoc} - * @see javax.swing.text.html.HTML.Tag#DIV - * @see javax.swing.text.html.HTML.Tag#PRE - */ - @Override public void verbatim( SinkEventAttributes attributes ) { if ( paragraphFlag ) @@ -1612,26 +1582,6 @@ public class Xhtml5BaseSink /** {@inheritDoc} */ @Override - public void tableCell( String width ) - { - MutableAttributeSet att = new SinkEventAttributeSet(); - att.addAttribute( Attribute.WIDTH, width ); - - tableCell( false, att ); - } - - /** {@inheritDoc} */ - @Override - public void tableHeaderCell( String width ) - { - MutableAttributeSet att = new SinkEventAttributeSet(); - att.addAttribute( Attribute.WIDTH, width ); - - tableCell( true, att ); - } - - /** {@inheritDoc} */ - @Override public void tableCell( SinkEventAttributes attributes ) { tableCell( false, attributes ); diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSink.java index 2dd6cb2..f3d595b 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSink.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSink.java @@ -28,7 +28,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Stack; import javax.swing.text.MutableAttributeSet; @@ -253,16 +252,6 @@ public class XhtmlBaseSink return Integer.parseInt( this.cellCountStack.getLast().toString() ); } - /** - * Reset all variables. - * - * @deprecated since 1.1.2, use {@link #init()} instead of. - */ - protected void resetState() - { - init(); - } - /** {@inheritDoc} */ @Override protected void init() @@ -1178,26 +1167,6 @@ public class XhtmlBaseSink * @see javax.swing.text.html.HTML.Tag#PRE */ @Override - public void verbatim( boolean boxed ) - { - if ( boxed ) - { - verbatim( SinkEventAttributeSet.BOXED ); - } - else - { - verbatim( null ); - } - } - - /** - * The default class style for boxed is <code>source</code>. - * - * {@inheritDoc} - * @see javax.swing.text.html.HTML.Tag#DIV - * @see javax.swing.text.html.HTML.Tag#PRE - */ - @Override public void verbatim( SinkEventAttributes attributes ) { if ( paragraphFlag ) @@ -1490,26 +1459,6 @@ public class XhtmlBaseSink /** {@inheritDoc} */ @Override - public void tableCell( String width ) - { - MutableAttributeSet att = new SinkEventAttributeSet(); - att.addAttribute( Attribute.WIDTH, width ); - - tableCell( false, att ); - } - - /** {@inheritDoc} */ - @Override - public void tableHeaderCell( String width ) - { - MutableAttributeSet att = new SinkEventAttributeSet(); - att.addAttribute( Attribute.WIDTH, width ); - - tableCell( true, att ); - } - - /** {@inheritDoc} */ - @Override public void tableCell( SinkEventAttributes attributes ) { tableCell( false, attributes ); diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/util/DoxiaUtils.java b/doxia-core/src/main/java/org/apache/maven/doxia/util/DoxiaUtils.java index ede7ee3..2c51b06 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/util/DoxiaUtils.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/util/DoxiaUtils.java @@ -49,8 +49,6 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; */ public class DoxiaUtils { - private static final int MINUS_ONE = 0xFF; - /** * Checks if the given string corresponds to an internal link, * ie it is a link to an anchor within the same document. @@ -252,20 +250,6 @@ public class DoxiaUtils } /** - * Convert a byte to it's hexadecimal equivalent. - * - * @param b the byte value. - * @return the result of Integer.toHexString( b & 0xFF ). - * @since 1.1.1 - * @deprecated Use {@code String.format( "%02X", bytes[j] )} - */ - @Deprecated - public static String byteToHex( final byte b ) - { - return Integer.toHexString( b & MINUS_ONE ); - } - - /** * Determines if the specified text is a valid id according to the rules * laid out in {@link #encodeId(String)}. * diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java index 2082704..5098069 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.apache.maven.doxia.parser.XhtmlBaseParser; import org.apache.maven.doxia.sink.impl.SinkEventElement; import org.apache.maven.doxia.sink.impl.SinkEventTestingSink; @@ -47,11 +48,11 @@ public class EchoMacroTest { final Map<String,Object> macroParameters = new HashMap<>(); macroParameters.put( "paramName", "paramValue" ); - macroParameters.put( "parser", "parserValue" ); - macroParameters.put( "sourceContent", "sourceContentValue" ); + + XhtmlBaseParser parser = new XhtmlBaseParser(); SinkEventTestingSink sink = new SinkEventTestingSink(); - MacroRequest request = new MacroRequest( macroParameters, new File( "." ) ); + MacroRequest request = new MacroRequest( null, parser, macroParameters, new File( "." ) ); new EchoMacro().execute( sink, request ); diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java index a6b6c37..d1f8926 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java @@ -26,6 +26,7 @@ import java.util.Map; import org.apache.maven.doxia.macro.MacroExecutionException; import org.apache.maven.doxia.macro.MacroRequest; +import org.apache.maven.doxia.parser.XhtmlBaseParser; import org.apache.maven.doxia.sink.impl.SinkEventElement; import org.apache.maven.doxia.sink.impl.SinkEventTestingSink; import org.codehaus.plexus.PlexusTestCase; @@ -121,7 +122,7 @@ public class SnippetMacroTest // no need to verify the absence of the first and second snippets if tests above were successful assertThat( snippet, CoreMatchers.containsString( "Этот сниппет в формате Unicode (UTF-8)" ) ); - + // again // Shouldn't work because no snippet called "first" exists, only "firstId" macroParameters.put( "id", "first" ); @@ -161,9 +162,11 @@ public class SnippetMacroTest { File basedir = new File( getBasedir() ); + XhtmlBaseParser parser = new XhtmlBaseParser(); + SinkEventTestingSink sink = new SinkEventTestingSink(); - MacroRequest request = new MacroRequest( macroParameters, basedir ); + MacroRequest request = new MacroRequest( null, parser, macroParameters, basedir ); SnippetMacro macro = new SnippetMacro(); macro.execute( sink, request ); diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java index d124f2f..2cb1d9a 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java @@ -56,17 +56,14 @@ public class TocMacroTest String sourceContent = "<div><h2>h21</h2><h2>h22</h2><h3>h3</h3><h4>h4</h4><h2>h23</h2></div>"; XhtmlBaseParser parser = new XhtmlBaseParser(); - parser.setSecondParsing( true ); Map<String, Object> macroParameters = new HashMap<>(); - macroParameters.put( "parser", parser ); - macroParameters.put( "sourceContent", sourceContent ); macroParameters.put( "section", "sec1" ); File basedir = new File( "" ); SinkEventTestingSink sink = new SinkEventTestingSink(); - MacroRequest request = new MacroRequest( macroParameters, basedir ); + MacroRequest request = new MacroRequest( sourceContent, parser, macroParameters, basedir ); TocMacro macro = new TocMacro(); macro.execute( sink, request ); @@ -107,8 +104,6 @@ public class TocMacroTest // test parameters parser = new XhtmlBaseParser(); - parser.setSecondParsing( true ); - macroParameters.put( "parser", parser ); macroParameters.put( "section", "2" ); macroParameters.put( "fromDepth", "1" ); macroParameters.put( "toDepth", "2" ); @@ -116,7 +111,7 @@ public class TocMacroTest macroParameters.put( "id", "myId" ); sink.reset(); - request = new MacroRequest( macroParameters, basedir ); + request = new MacroRequest( sourceContent, parser, macroParameters, basedir ); macro.execute( sink, request ); it = sink.getEventList().iterator(); @@ -158,18 +153,15 @@ public class TocMacroTest "<div><h2>h<b>21</b></h2><h2>h<i>22</i></h2><h3>h<tt>3</tt></h3><h4>h4</h4><h2>h23</h2></div>"; XhtmlBaseParser parser = new XhtmlBaseParser(); - parser.setSecondParsing( true ); Map<String, Object> macroParameters = new HashMap<>(); - macroParameters.put( "parser", parser ); - macroParameters.put( "sourceContent", sourceContent ); macroParameters.put( "section", "sec1" ); File basedir = new File( "" ); StringWriter out = new StringWriter(); XhtmlBaseSink sink = new XhtmlBaseSink( out ); - MacroRequest request = new MacroRequest( macroParameters, basedir ); + MacroRequest request = new MacroRequest( sourceContent, parser, macroParameters, basedir ); TocMacro macro = new TocMacro(); macro.execute( sink, request ); diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkAdapterTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkAdapterTest.java index 24f4ca9..9f28fa7 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkAdapterTest.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkAdapterTest.java @@ -494,7 +494,6 @@ public class SinkAdapterTest public void testVerbatim() { instance.verbatim( null ); - instance.verbatim( false ); instance.verbatim_(); } @@ -528,23 +527,10 @@ public class SinkAdapterTest { instance.tableCell(); instance.tableCell( (SinkEventAttributes) null ); - instance.tableCell( (String) null ); instance.tableCell_(); } /** - * Test of tableHeaderCell method, of class SinkAdapter. - */ - @Test - public void testTableHeaderCell() - { - instance.tableHeaderCell(); - instance.tableHeaderCell( (SinkEventAttributes) null ); - instance.tableHeaderCell( (String) null ); - instance.tableHeaderCell_(); - } - - /** * Test of tableCaption method, of class SinkAdapter. */ @Test diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventTestingSink.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventTestingSink.java index ed25e5e..726e98d 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventTestingSink.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventTestingSink.java @@ -551,12 +551,6 @@ public class SinkEventTestingSink } @Override - public void verbatim( boolean boxed ) - { - addEvent( "verbatim", new Object[] { boxed } ); - } - - @Override public void verbatim_() { addEvent( "verbatim_" ); @@ -593,12 +587,6 @@ public class SinkEventTestingSink } @Override - public void tableCell( String width ) - { - addEvent( "tableCell", new Object[] {width} ); - } - - @Override public void tableCell_() { addEvent( "tableCell_" ); @@ -611,12 +599,6 @@ public class SinkEventTestingSink } @Override - public void tableHeaderCell( String width ) - { - addEvent( "tableHeaderCell", new Object[] {width} ); - } - - @Override public void tableHeaderCell_() { addEvent( "tableHeaderCell_" ); diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java index 620bdca..97585a5 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java @@ -542,12 +542,6 @@ public class TextSink } @Override - public void verbatim( boolean boxed ) - { - write( "begin:verbatim, boxed: " + boxed ); - } - - @Override public void verbatim_() { writeln( "end:verbatim" ); @@ -584,12 +578,6 @@ public class TextSink } @Override - public void tableCell( String width ) - { - write( "begin:tableCell, width: " + width ); - } - - @Override public void tableCell_() { writeln( "end:tableCell" ); @@ -602,12 +590,6 @@ public class TextSink } @Override - public void tableHeaderCell( String width ) - { - write( "begin:tableHeaderCell, width: " + width ); - } - - @Override public void tableHeaderCell_() { writeln( "end:tableHeaderCell" ); @@ -1010,7 +992,7 @@ public class TextSink attributes.getAttribute( SinkEventAttributes.DECORATION ).toString() ); } - verbatim( boxed ); + write( "begin:verbatim, boxed: " + boxed ); } @Override diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/WellformednessCheckingSink.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/WellformednessCheckingSink.java index 4791778..1f2bba1 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/WellformednessCheckingSink.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/WellformednessCheckingSink.java @@ -534,12 +534,6 @@ public class WellformednessCheckingSink } @Override - public void verbatim( boolean boxed ) - { - startElement( "verbatim" ); - } - - @Override public void verbatim_() { checkWellformedness( "verbatim" ); @@ -576,12 +570,6 @@ public class WellformednessCheckingSink } @Override - public void tableCell( String width ) - { - startElement( "tableCell" ); - } - - @Override public void tableCell_() { checkWellformedness( "tableCell" ); @@ -594,12 +582,6 @@ public class WellformednessCheckingSink } @Override - public void tableHeaderCell( String width ) - { - startElement( "tableHeaderCell" ); - } - - @Override public void tableHeaderCell_() { checkWellformedness( "tableHeaderCell" ); @@ -1045,7 +1027,7 @@ public class WellformednessCheckingSink @Override public void verbatim( SinkEventAttributes attributes ) { - verbatim( false ); + startElement( "verbatim" ); } @Override diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java index 6e1652e..3913825 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java @@ -964,7 +964,7 @@ public class Xhtml5BaseSinkTest { sink = new Xhtml5BaseSink( writer ); - sink.verbatim( true ); + sink.verbatim( SinkEventAttributeSet.BOXED ); sink.verbatim_(); } finally diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSinkTest.java index 9e498e2..838ea0d 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSinkTest.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSinkTest.java @@ -582,7 +582,7 @@ public class XhtmlBaseSinkTest { sink = new XhtmlBaseSink( writer ); - sink.verbatim( true ); + sink.verbatim( SinkEventAttributeSet.BOXED ); sink.verbatim_(); } finally diff --git a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java index c44281e..c263fb9 100644 --- a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java +++ b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java @@ -25,9 +25,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Stack; +import javax.swing.text.MutableAttributeSet; + import org.apache.maven.doxia.sink.SinkEventAttributes; import org.apache.maven.doxia.sink.impl.AbstractTextSink; import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; +import org.apache.maven.doxia.sink.impl.SinkUtils; import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -152,16 +155,6 @@ public class AptSink } /** - * Reset all variables. - * - * @deprecated since 1.1.2, use {@link #init()} instead of. - */ - protected void resetState() - { - init(); - } - - /** * {@inheritDoc} */ protected void init() @@ -634,8 +627,17 @@ public class AptSink } /** {@inheritDoc} */ - public void verbatim( boolean boxed ) + public void verbatim( SinkEventAttributes attributes ) { + MutableAttributeSet atts = SinkUtils.filterAttributes( attributes, SinkUtils.SINK_VERBATIM_ATTRIBUTES ); + + boolean boxed = false; + + if ( atts != null && atts.isDefined( SinkEventAttributes.DECORATION ) ) + { + boxed = "boxed".equals( atts.getAttribute( SinkEventAttributes.DECORATION ).toString() ); + } + verbatimFlag = true; this.isBoxed = boxed; write( EOL ); diff --git a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptUtils.java b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptUtils.java index 80d7c29..901d145 100644 --- a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptUtils.java +++ b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptUtils.java @@ -31,31 +31,6 @@ public class AptUtils { /** - * Replace all characters in a text. - * - * <pre> - * AptTools.encodeFragment( null ) = null - * AptTools.encodeFragment( "" ) = "" - * AptTools.encodeFragment( "http://www.google.com" ) = "httpwwwgooglecom" - * </pre> - * - * @param text the String to check, may be null. - * @return the text with only letter and digit, null if null String input. - * @deprecated This method was used for the original apt format, which - * removed all non alphanumeric characters from anchors. - * Use {@link #encodeAnchor(String)} instead. - */ - public static String encodeFragment( String text ) - { - if ( text == null ) - { - return null; - } - - return linkToKey( text ); - } - - /** * Checks if the given string corresponds to an external URI, * ie is not a link within the same document nor a link to another * document within the same site. This forwards to @@ -104,34 +79,6 @@ public class AptUtils } /** - * Transforms the given text such that it can be used as a link. - * All non-LetterOrDigit characters are removed and the remaining - * characters are transformed to lower-case. - * - * @param text The text to transform. - * @return The text with all non-LetterOrDigit characters removed. - * @deprecated This method was used for the original apt format, which - * removed all non alphanumeric characters from anchors. - * Use {@link #encodeAnchor(String)} instead. - */ - public static String linkToKey( String text ) - { - int length = text.length(); - StringBuilder buffer = new StringBuilder( length ); - - for ( int i = 0; i < length; ++i ) - { - char c = text.charAt( i ); - if ( Character.isLetterOrDigit( c ) ) - { - buffer.append( Character.toLowerCase( c ) ); - } - } - - return buffer.toString(); - } - - /** * Construct a valid anchor. This is a simplified version of * {@link org.apache.maven.doxia.util.DoxiaUtils#encodeId(String)} * to ensure the anchor is a valid Doxia id. diff --git a/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptUtilsTest.java b/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptUtilsTest.java index 571e582..4f6e330 100644 --- a/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptUtilsTest.java +++ b/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptUtilsTest.java @@ -132,25 +132,4 @@ public class AptUtilsTest assertNull( AptUtils.encodeAnchor( null ) ); assertEquals( "a123_:_.-aBc", AptUtils.encodeAnchor( " 12!3 :_.&-a)Bc " ) ); } - - /** - * Test of encodeFragment method, of class AptUtils. - */ - @SuppressWarnings( "deprecation" ) - @Test - public void testEncodeFragment() - { - assertNull( AptUtils.encodeFragment( null ) ); - assertEquals( "abc0d", AptUtils.encodeFragment( "a B&c0)D" ) ); - } - - /** - * Test of linkToKey method, of class AptUtils. - */ - @SuppressWarnings( "deprecation" ) - @Test - public void testLinkToKey() - { - assertEquals( "abc56au", AptUtils.linkToKey( "aB$%C56 a&\\/'U" ) ); - } } diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java index 3c8f334..96d85a9 100644 --- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java +++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java @@ -534,14 +534,4 @@ public class XdocSink // // ---------------------------------------------------------------------- - /** - * Write text to output, preserving white space. - * - * @param text The text to write. - * @deprecated use write(String) - */ - protected void markup( String text ) - { - write( text ); - } } diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XmlWriterXdocSink.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XmlWriterXdocSink.java deleted file mode 100644 index 674ee30..0000000 --- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XmlWriterXdocSink.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.doxia.module.xdoc; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; - -import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; -import org.codehaus.plexus.util.xml.XMLWriter; -import org.codehaus.plexus.util.xml.XmlUtil; - -/** - * A Doxia Sink which produces an xdoc document. - * - * @author juan <a href="mailto:[email protected]">James Taylor</a> - * @author Juan F. Codagnone (replaced println with XmlWriterXdocSink) - * @deprecated Since 1.1, this sink is not more supported. If you are looking for a <code>Sink</code> which produces - * pretty formatted XML, you could use the {@link XdocSink#XdocSink(java.io.Writer)} as usual and reformat the - * <code>Sink</code> content produced with {@link XmlUtil#prettyFormat(java.io.Reader, java.io.Writer)}. - */ -public class XmlWriterXdocSink - extends XdocSink -{ - /** Writer used by Xdoc */ - private StringWriter xdocWriter; - - private XMLWriter xmlWriter; - - private XmlWriterXdocSink( StringWriter out, String encoding ) - { - super( out, encoding ); - this.xdocWriter = out; - this.xmlWriter = new PrettyPrintXMLWriter( out ); - } - - /** - * <p>Constructor for XmlWriterXdocSink.</p> - * - * @param out the wanted XML Writer. - * @deprecated since 1.1 - */ - public XmlWriterXdocSink( XMLWriter out ) - { - this( new StringWriter(), "UTF-8" ); - this.xmlWriter = out; - } - - /** - * {@inheritDoc} - */ - public void close() - { - super.close(); - - String xdocContent = xdocWriter.toString(); - StringWriter formattedContent = new StringWriter(); - try - { - XmlUtil.prettyFormat( new StringReader( xdocContent ), formattedContent ); - } - catch ( IOException e ) - { - formattedContent = new StringWriter(); - formattedContent.write( xdocContent ); - } - xmlWriter.writeMarkup( formattedContent.toString() ); - } -} diff --git a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XmlWriterXdocSinkTest.java b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XmlWriterXdocSinkTest.java deleted file mode 100644 index 774642f..0000000 --- a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XmlWriterXdocSinkTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.apache.maven.doxia.module.xdoc; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.Writer; - -import org.apache.maven.doxia.sink.Sink; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; -import org.codehaus.plexus.util.xml.XmlUtil; - -/** - * @author <a href="mailto:[email protected]">Vincent Siveton</a> - * @since 1.1 - */ -public class XmlWriterXdocSinkTest - extends XdocSinkTest -{ - private static final String DEFAULT_INDENT = StringUtils.repeat( " ", XmlUtil.DEFAULT_INDENTATION_SIZE ); - - /** {@inheritDoc} */ - protected Sink createSink( Writer writer ) - { - return new XmlWriterXdocSink( new PrettyPrintXMLWriter( writer ) ); - } - - /** {@inheritDoc} */ - protected String getSection1Block( String title ) - { - return "<section name=\"" + title + "\"/>"; - } - - /** {@inheritDoc} */ - protected String getSection2Block( String title ) - { - return "<subsection name=\"" + title + "\"/>"; - } - - /** {@inheritDoc} */ - protected String getListBlock( String item ) - { - return "<ul>" + XmlUtil.DEFAULT_LINE_SEPARATOR + DEFAULT_INDENT + "<li>" + item + "</li>" - + XmlUtil.DEFAULT_LINE_SEPARATOR + "</ul>"; - } - - /** {@inheritDoc} */ - protected String getNumberedListBlock( String item ) - { - return "<ol style=\"list-style-type: lower-roman\">" + XmlUtil.DEFAULT_LINE_SEPARATOR + DEFAULT_INDENT - + "<li>" + item + "</li>" + XmlUtil.DEFAULT_LINE_SEPARATOR + "</ol>"; - } - - /** {@inheritDoc} */ - protected String getDefinitionListBlock( String definum, String definition ) - { - return "<dl>" + XmlUtil.DEFAULT_LINE_SEPARATOR + DEFAULT_INDENT + "<dt>" + definum + "</dt>" - + XmlUtil.DEFAULT_LINE_SEPARATOR + DEFAULT_INDENT + "<dd>" + definition + "</dd>" - + XmlUtil.DEFAULT_LINE_SEPARATOR + "</dl>"; - } - - /** {@inheritDoc} */ - protected String getFigureBlock( String source, String caption ) - { - String figureBlock = "<img src=\"" + source + "\""; - if ( caption != null ) - { - figureBlock += " alt=\"" + caption + "\""; - } - else //@todo fix DOXIA-361 - { - figureBlock += " alt=\"\""; - } - figureBlock += "/>"; - return figureBlock; - } - - /** {@inheritDoc} */ - protected String getTableBlock( String cell, String caption ) - { - return "<table border=\"0\">" + XmlUtil.DEFAULT_LINE_SEPARATOR + DEFAULT_INDENT - + "<caption>" + caption + "</caption>" + XmlUtil.DEFAULT_LINE_SEPARATOR + DEFAULT_INDENT - + "<tr valign=\"top\">" + XmlUtil.DEFAULT_LINE_SEPARATOR + DEFAULT_INDENT + DEFAULT_INDENT - + "<td>" + cell + "</td>" + XmlUtil.DEFAULT_LINE_SEPARATOR + DEFAULT_INDENT + "</tr>" - + XmlUtil.DEFAULT_LINE_SEPARATOR + "</table>"; - } - - /** {@inheritDoc} */ - protected String getHorizontalRuleBlock() - { - return "<hr/>"; - } - - /** {@inheritDoc} */ - protected String getLineBreakBlock() - { - return "<br/>"; - } -} diff --git a/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java b/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java index b5c4e5e..b790bad 100644 --- a/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java +++ b/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java @@ -1124,14 +1124,6 @@ public interface Sink void tableCell(); /** - * Starts a cell element which defines a cell that contains data. - * - * @param width the size of the cell. - * @deprecated Use #tableCell(SinkEventAttributes) instead. - */ - void tableCell( String width ); - - /** * Starts a table cell. * * <p> @@ -1164,14 +1156,6 @@ public interface Sink void tableHeaderCell(); /** - * Starts a cell element which defines a cell that contains header information. - * - * @param width the size of the header cell. - * @deprecated Use #tableHeaderCell(SinkEventAttributes) instead. - */ - void tableHeaderCell( String width ); - - /** * Starts a table header cell. * * <p> @@ -1368,14 +1352,6 @@ public interface Sink void division_(); /** - * Starts an element which indicates that whitespace in the enclosed text has semantic relevance. - * - * @param boxed true to add a box, false otherwise - * @deprecated Use #verbatim(SinkEventAttributes) instead. - */ - void verbatim( boolean boxed ); - - /** * Starts a verbatim block, ie a block where whitespace has semantic relevance. * * <p> diff --git a/doxia-sink-api/src/main/java/org/codehaus/doxia/sink/Sink.java b/doxia-sink-api/src/main/java/org/codehaus/doxia/sink/Sink.java deleted file mode 100644 index 0fe64cf..0000000 --- a/doxia-sink-api/src/main/java/org/codehaus/doxia/sink/Sink.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.doxia.sink; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Generic document processing interface. - * - * @deprecated use {@link org.apache.maven.doxia.sink.Sink} instead (since 1.0-alpha-6). - */ -public interface Sink - extends org.apache.maven.doxia.sink.Sink -{ - // nop -}
