From a55438b642bf6e5252164607940e6e52599d2298 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Sun, 28 Jun 2020 17:31:33 +0200 Subject: [PATCH 1/6] [DOXIA-614] Make Parser::parse(Reader,Sink,String) the default method for modules --- .../maven/doxia/parser/AbstractParser.java | 40 +++++++++----- .../maven/doxia/parser/AbstractXmlParser.java | 52 +++++++------------ .../maven/doxia/parser/Xhtml5BaseParser.java | 4 +- .../maven/doxia/parser/XhtmlBaseParser.java | 4 +- .../maven/doxia/module/fml/FmlParser.java | 4 +- .../doxia/module/markdown/MarkdownParser.java | 2 +- .../maven/doxia/module/xdoc/XdocParser.java | 4 +- .../maven/doxia/module/xhtml/XhtmlParser.java | 4 +- .../doxia/module/xhtml/XhtmlParserTest.java | 1 + .../doxia/module/xhtml5/Xhtml5Parser.java | 4 +- 10 files changed, 61 insertions(+), 58 deletions(-) diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java index 1745585c6..ae8c0a71a 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java @@ -19,14 +19,6 @@ * under the License. */ -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; - -import java.util.Properties; - import org.apache.maven.doxia.logging.Log; import org.apache.maven.doxia.logging.SystemStreamLog; import org.apache.maven.doxia.macro.Macro; @@ -37,6 +29,13 @@ import org.apache.maven.doxia.sink.Sink; import org.codehaus.plexus.component.annotations.Requirement; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.util.Properties; + /** * An abstract base class that defines some convenience methods for parsers. * Provides a macro mechanism to give dynamic functionalities for the parsing. @@ -179,15 +178,32 @@ protected File getBasedir() public void parse( String string, Sink sink ) throws ParseException { - parse( new StringReader( string ), sink ); + this.parse( string, sink, null ); } - + + /** + * {@inheritDoc} + * + * Convenience method to parse an arbitrary string and emit events into the given sink. + * + * @param string A string that provides the source input. + * @param sink A sink that consumes the Doxia events. + * @param reference A string containing the reference to the source of the input string (e.g. filename). + * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed. + * @since 1.9.2 + */ + public void parse( String string, Sink sink, String reference ) + throws ParseException + { + parse( new StringReader( string ), sink, reference ); + } + /** {@inheritDoc} */ @Override - public void parse( Reader source, Sink sink, String reference ) + public void parse( Reader source, Sink sink ) throws ParseException { - parse( source, sink ); + parse( source, sink, null ); } /** diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java index 224c1cf3a..10095d162 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java @@ -19,23 +19,6 @@ * under the License. */ -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.StringReader; -import java.net.URL; -import java.util.Hashtable; -import java.util.LinkedHashMap; -import java.util.Locale; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; @@ -49,18 +32,33 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.doxia.util.HtmlTools; import org.apache.maven.doxia.util.XmlValidator; - import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.MXParser; import org.codehaus.plexus.util.xml.pull.XmlPullParser; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.StringReader; +import java.net.URL; +import java.util.Hashtable; +import java.util.LinkedHashMap; +import java.util.Locale; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * An abstract class that defines some convenience methods for XML parsers. * @@ -100,7 +98,7 @@ public abstract class AbstractXmlParser private boolean validate = false; /** {@inheritDoc} */ - public void parse( Reader source, Sink sink ) + public void parse( Reader source, Sink sink, String reference ) throws ParseException { init(); @@ -153,7 +151,7 @@ public void parse( Reader source, Sink sink ) setSecondParsing( false ); init(); } - + /** * Initializes the parser with custom entities or other options. * @@ -166,18 +164,6 @@ protected void initXmlParser( XmlPullParser parser ) // nop } - /** - * {@inheritDoc} - * - * Convenience method to parse an arbitrary string and emit any xml events into the given sink. - */ - @Override - public void parse( String string, Sink sink ) - throws ParseException - { - super.parse( string, sink ); - } - /** {@inheritDoc} */ @Override public final int getType() diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java index 5dfc75771..dd10f585b 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java @@ -81,14 +81,14 @@ public class Xhtml5BaseParser /** {@inheritDoc} */ @Override - public void parse( Reader source, Sink sink ) + public void parse( Reader source, Sink sink, String reference ) throws ParseException { init(); try { - super.parse( source, sink ); + super.parse( source, sink, reference ); } finally { diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java index 57049e32c..411b045a7 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java @@ -82,14 +82,14 @@ public class XhtmlBaseParser /** {@inheritDoc} */ @Override - public void parse( Reader source, Sink sink ) + public void parse( Reader source, Sink sink, String reference ) throws ParseException { init(); try { - super.parse( source, sink ); + super.parse( source, sink, reference ); } finally { diff --git a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java index 6fc121b04..da334a156 100644 --- a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java +++ b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java @@ -89,7 +89,7 @@ public class FmlParser private Map macroParameters = new HashMap<>(); /** {@inheritDoc} */ - public void parse( Reader source, Sink sink ) + public void parse( Reader source, Sink sink, String reference ) throws ParseException { this.faqs = null; @@ -118,7 +118,7 @@ public void parse( Reader source, Sink sink ) this.faqs = new Faqs(); // this populates faqs - super.parse( tmp, sink ); + super.parse( tmp, sink, reference ); writeFaqs( sink ); } diff --git a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java index 971c35f86..d26558b85 100644 --- a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java +++ b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java @@ -163,7 +163,7 @@ public int getType() /** {@inheritDoc} */ @Override - public void parse( Reader source, Sink sink ) + public void parse( Reader source, Sink sink, String reference ) throws ParseException { try diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java index 6efa2b5cd..e1b81849b 100644 --- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java +++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java @@ -85,7 +85,7 @@ public class XdocParser private boolean hasTitle; /** {@inheritDoc} */ - public void parse( Reader source, Sink sink ) + public void parse( Reader source, Sink sink, String reference ) throws ParseException { this.sourceContent = null; @@ -110,7 +110,7 @@ public void parse( Reader source, Sink sink ) try { - super.parse( new StringReader( sourceContent ), sink ); + super.parse( new StringReader( sourceContent ), sink, reference ); } finally { diff --git a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java index 470fc2f99..fbeeb9a37 100644 --- a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java +++ b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java @@ -333,7 +333,7 @@ protected void init() } /** {@inheritDoc} */ - public void parse( Reader source, Sink sink ) + public void parse( Reader source, Sink sink, String reference ) throws ParseException { this.sourceContent = null; @@ -355,7 +355,7 @@ public void parse( Reader source, Sink sink ) try { - super.parse( new StringReader( sourceContent ), sink ); + super.parse( new StringReader( sourceContent ), sink, reference ); } finally { diff --git a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java index 7820fa733..ac27097ca 100644 --- a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java +++ b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileFilter; +import java.io.StringReader; import java.util.Iterator; import java.util.regex.Pattern; diff --git a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java index 984769b71..e04935550 100644 --- a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java +++ b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java @@ -334,7 +334,7 @@ protected void init() } /** {@inheritDoc} */ - public void parse( Reader source, Sink sink ) + public void parse( Reader source, Sink sink, String reference ) throws ParseException { this.sourceContent = null; @@ -356,7 +356,7 @@ public void parse( Reader source, Sink sink ) try { - super.parse( new StringReader( sourceContent ), sink ); + super.parse( new StringReader( sourceContent ), sink, reference ); } finally { From e8f8c8240d7ccb317bd60c48edd3cdfe91c1cfb0 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Sun, 28 Jun 2020 19:37:58 +0200 Subject: [PATCH 2/6] [DOXIA-614] Support passing source reference to Doxia instance --- .../org/apache/maven/doxia/DefaultDoxia.java | 10 +++- .../java/org/apache/maven/doxia/Doxia.java | 16 ++++++ .../apache/maven/doxia/DefaultDoxiaTest.java | 54 +++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java index f8583e7cd..dae7ec20d 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java @@ -56,12 +56,20 @@ public class DefaultDoxia /** {@inheritDoc} */ public void parse( Reader source, String parserId, Sink sink ) throws ParserNotFoundException, ParseException + { + this.parse( source, parserId, sink, null ); + } + + /** {@inheritDoc} */ + @Override + public void parse( Reader source, String parserId, Sink sink, String reference ) + throws ParserNotFoundException, ParseException { Parser parser = parserManager.getParser( parserId ); parser.enableLogging( new PlexusLoggerWrapper( getLogger() ) ); - parser.parse( source, sink ); + parser.parse( source, sink, reference ); } /** {@inheritDoc} */ diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java index 837bdc28d..5896684e6 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java @@ -52,6 +52,22 @@ public interface Doxia void parse( Reader source, String parserId, Sink sink ) throws ParserNotFoundException, ParseException; + /** + * Parses the given source model using a parser with given id, + * and emits Doxia events into the given sink. + * + * @param source not null reader that provides the source document. + * You could use newReader methods from {@link org.codehaus.plexus.util.ReaderFactory}. + * @param parserId Identifier for the parser to use. + * @param sink A sink that consumes the Doxia events. + * @param reference A string containing the reference to the source of the input string (e.g. filename). + * @throws org.apache.maven.doxia.parser.manager.ParserNotFoundException + * if no parser could be found for the given id. + * @throws org.apache.maven.doxia.parser.ParseException if the model could not be parsed. + */ + void parse( Reader source, String parserId, Sink sink, String reference ) + throws ParserNotFoundException, ParseException; + /** * Return a parser for the given parserId. * diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java new file mode 100644 index 000000000..2075b7fbd --- /dev/null +++ b/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java @@ -0,0 +1,54 @@ +package org.apache.maven.doxia; + +/* + * 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 org.apache.maven.doxia.parser.manager.ParserNotFoundException; +import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; + +public class DefaultDoxiaTest extends PlexusTestCase +{ + + @Test + public void testCreatesDefaultDoxia() + { + final DefaultDoxia defaultDoxia = new DefaultDoxia(); + + assertNotNull( defaultDoxia ); + } + + @Test + public void testFailsWhenParserIdDoesNotExist() throws Exception + { + final String parserId = "a-parser"; + final Doxia doxia = lookup( Doxia.class ); + + try + { + doxia.getParser( parserId ); + fail( "Call should fail with ParserNotFoundException" ); + } + catch ( ParserNotFoundException e ) + { + assertEquals( "Cannot find parser with id = a-parser", e.getMessage() ); + } + } + +} From bca3f5f7b97339f173ffdfdc8dde775918b28e97 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Mon, 29 Jun 2020 19:51:37 +0200 Subject: [PATCH 3/6] [DOXIA-614] Fix Doxia JavaDoc comments --- .../java/org/apache/maven/doxia/Doxia.java | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java index 5896684e6..22018e6b7 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java @@ -41,13 +41,11 @@ public interface Doxia * Parses the given source model using a parser with given id, * and emits Doxia events into the given sink. * - * @param source not null reader that provides the source document. - * You could use newReader methods from {@link org.codehaus.plexus.util.ReaderFactory}. - * @param parserId Identifier for the parser to use. - * @param sink A sink that consumes the Doxia events. - * @throws org.apache.maven.doxia.parser.manager.ParserNotFoundException - * if no parser could be found for the given id. - * @throws org.apache.maven.doxia.parser.ParseException if the model could not be parsed. + * @param source not null reader that provides the source document + * @param parserId identifier for the parser to use + * @param sink a sink that consumes the Doxia events + * @throws ParserNotFoundException if no parser could be found for the given id + * @throws ParseException if the model could not be parsed */ void parse( Reader source, String parserId, Sink sink ) throws ParserNotFoundException, ParseException; @@ -56,14 +54,12 @@ void parse( Reader source, String parserId, Sink sink ) * Parses the given source model using a parser with given id, * and emits Doxia events into the given sink. * - * @param source not null reader that provides the source document. - * You could use newReader methods from {@link org.codehaus.plexus.util.ReaderFactory}. - * @param parserId Identifier for the parser to use. - * @param sink A sink that consumes the Doxia events. - * @param reference A string containing the reference to the source of the input string (e.g. filename). - * @throws org.apache.maven.doxia.parser.manager.ParserNotFoundException - * if no parser could be found for the given id. - * @throws org.apache.maven.doxia.parser.ParseException if the model could not be parsed. + * @param source not null reader that provides the source document + * @param parserId identifier for the parser to use + * @param sink a sink that consumes the Doxia events + * @param reference string containing the reference to the source (e.g. filename) + * @throws ParserNotFoundException if no parser could be found for the given id + * @throws ParseException if the model could not be parsed */ void parse( Reader source, String parserId, Sink sink, String reference ) throws ParserNotFoundException, ParseException; @@ -71,10 +67,9 @@ void parse( Reader source, String parserId, Sink sink, String reference ) /** * Return a parser for the given parserId. * - * @param parserId Identifier for the parser to use. - * @return the parser defining by parserId. - * @throws org.apache.maven.doxia.parser.manager.ParserNotFoundException - * if no parser could be found for the given id. + * @param parserId identifier for the parser to use + * @return the parser defining by parserId + * @throws ParserNotFoundException if no parser could be found for the given id */ Parser getParser( String parserId ) throws ParserNotFoundException; From b33226cebb1ec703a761aae1418a30b1e517f85e Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Tue, 30 Jun 2020 22:19:07 +0200 Subject: [PATCH 4/6] [DOXIA-614] Restore imports order for AbstractParser and AbstractXmlParser --- .../maven/doxia/parser/AbstractParser.java | 15 ++++---- .../maven/doxia/parser/AbstractXmlParser.java | 36 ++++++++++--------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java index ae8c0a71a..7471ff8b1 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java @@ -19,6 +19,14 @@ * under the License. */ +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; + +import java.util.Properties; + import org.apache.maven.doxia.logging.Log; import org.apache.maven.doxia.logging.SystemStreamLog; import org.apache.maven.doxia.macro.Macro; @@ -29,13 +37,6 @@ import org.apache.maven.doxia.sink.Sink; import org.codehaus.plexus.component.annotations.Requirement; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.util.Properties; - /** * An abstract base class that defines some convenience methods for parsers. * Provides a macro mechanism to give dynamic functionalities for the parsing. diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java index 10095d162..c0b1ddb15 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java @@ -19,6 +19,23 @@ * under the License. */ +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.StringReader; +import java.net.URL; +import java.util.Hashtable; +import java.util.LinkedHashMap; +import java.util.Locale; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; @@ -32,33 +49,18 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.doxia.util.HtmlTools; import org.apache.maven.doxia.util.XmlValidator; + import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.MXParser; import org.codehaus.plexus.util.xml.pull.XmlPullParser; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.StringReader; -import java.net.URL; -import java.util.Hashtable; -import java.util.LinkedHashMap; -import java.util.Locale; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * An abstract class that defines some convenience methods for XML parsers. * From 50104e4688bc304e9ede3b7c0cfd006b8b843532 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Tue, 30 Jun 2020 22:33:43 +0200 Subject: [PATCH 5/6] [DOXIA-614] Fix AbstractParser JavaDoc comments --- .../maven/doxia/parser/AbstractParser.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java index 7471ff8b1..b46d6f493 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java @@ -101,7 +101,7 @@ public abstract class AbstractParser /** * {@inheritDoc} * - * @return a int. + * @return a int */ public int getType() { @@ -117,7 +117,7 @@ public void setEmitComments( boolean emitComments ) /** *

isEmitComments.

* - * @return a boolean. + * @return a boolean */ public boolean isEmitComments() { @@ -127,11 +127,11 @@ public boolean isEmitComments() /** * Execute a macro on the given sink. * - * @param macroId An id to lookup the macro. - * @param request The corresponding MacroRequest. - * @param sink The sink to receive the events. - * @throws org.apache.maven.doxia.macro.MacroExecutionException if an error occurred during execution. - * @throws org.apache.maven.doxia.macro.manager.MacroNotFoundException if the macro could not be found. + * @param macroId an id to lookup the macro + * @param request the corresponding MacroRequest + * @param sink the sink to receive the events + * @throws org.apache.maven.doxia.macro.MacroExecutionException if an error occurred during execution + * @throws org.apache.maven.doxia.macro.manager.MacroNotFoundException if the macro could not be found */ // Made public right now because of the structure of the APT parser and // all its inner classes. @@ -148,7 +148,7 @@ public void executeMacro( String macroId, MacroRequest request, Sink sink ) /** * Returns the current base directory. * - * @return The base directory. + * @return the base directory * @deprecated this does not work in multi-module builds, see DOXIA-373 */ protected File getBasedir() @@ -171,9 +171,9 @@ protected File getBasedir() * * Convenience method to parse an arbitrary string and emit events into the given sink. * - * @param string A string that provides the source input. - * @param sink A sink that consumes the Doxia events. - * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed. + * @param string a string that provides the source input + * @param sink a sink that consumes the Doxia events + * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed * @since 1.1 */ public void parse( String string, Sink sink ) @@ -187,10 +187,10 @@ public void parse( String string, Sink sink ) * * Convenience method to parse an arbitrary string and emit events into the given sink. * - * @param string A string that provides the source input. - * @param sink A sink that consumes the Doxia events. - * @param reference A string containing the reference to the source of the input string (e.g. filename). - * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed. + * @param string a string that provides the source input + * @param sink a sink that consumes the Doxia events + * @param reference a string containing the reference to the source of the input string (e.g. filename) + * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed * @since 1.9.2 */ public void parse( String string, Sink sink, String reference ) @@ -210,7 +210,7 @@ public void parse( Reader source, Sink sink ) /** * Set secondParsing to true, if we need a second parsing. * - * @param second True for second parsing. + * @param second true for second parsing */ public void setSecondParsing( boolean second ) { @@ -220,7 +220,7 @@ public void setSecondParsing( boolean second ) /** * Indicates if we are currently parsing a second time. * - * @return true if we are currently parsing a second time. + * @return true if we are currently parsing a second time * @since 1.1 */ protected boolean isSecondParsing() @@ -254,7 +254,7 @@ protected Log getLog() /** * Gets the current {@link MacroManager}. * - * @return The current {@link MacroManager}. + * @return the current {@link MacroManager} * @since 1.1 */ protected MacroManager getMacroManager() @@ -277,7 +277,7 @@ protected void init() /** * The current Doxia version. * - * @return the current Doxia version as a String. + * @return the current Doxia version as a String * @since 1.2 */ protected static String doxiaVersion() From 6c076bade257a59a9ea6dabe94c55d8bc8b1cdec Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Tue, 30 Jun 2020 22:35:50 +0200 Subject: [PATCH 6/6] [DOXIA-614] Improve Doxia::getParser return JavaDoc --- doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java index 22018e6b7..17d392075 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java @@ -68,7 +68,7 @@ void parse( Reader source, String parserId, Sink sink, String reference ) * Return a parser for the given parserId. * * @param parserId identifier for the parser to use - * @return the parser defining by parserId + * @return the parser identified by parserId * @throws ParserNotFoundException if no parser could be found for the given id */ Parser getParser( String parserId )