You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by vs...@apache.org on 2009/08/24 13:59:25 UTC
svn commit: r807164 - in /maven/doxia/doxia/trunk/doxia-core/src:
main/java/org/apache/maven/doxia/index/
main/java/org/apache/maven/doxia/parser/
main/java/org/apache/maven/doxia/sink/ test/java/org/apache/maven/doxia/sink/
Author: vsiveton
Date: Mon Aug 24 11:59:25 2009
New Revision: 807164
URL: http://svn.apache.org/viewvc?rev=807164&view=rev
Log:
DOXIA-364: Guarantee the state of sinks and parsers impl
o add init() method in AbstractSink/AbstractParser and implement it
Modified:
maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java
maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractSink.java
maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java
Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java?rev=807164&r1=807163&r2=807164&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java Mon Aug 24 11:59:25 2009
@@ -68,7 +68,7 @@
private String title;
/** The stack. */
- private Stack stack = new Stack();
+ private final Stack stack;
/**
* Default constructor.
@@ -77,7 +77,10 @@
*/
public IndexingSink( IndexEntry sectionEntry )
{
+ stack = new Stack();
stack.push( sectionEntry );
+
+ init();
}
/**
@@ -242,4 +245,19 @@
{
return (IndexEntry) stack.peek();
}
+
+ /** {@inheritDoc} */
+ public void close()
+ {
+ super.close();
+
+ init();
+ }
+
+ /** {@inheritDoc} */
+ protected void init()
+ {
+ this.type = 0;
+ this.title = null;
+ }
}
Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java?rev=807164&r1=807163&r2=807164&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java Mon Aug 24 11:59:25 2009
@@ -166,4 +166,16 @@
{
return macroManager;
}
+
+ /**
+ * Initialize the parser. This is called first by
+ * {@link #parse(java.io.Reader, org.apache.maven.doxia.sink.Sink)} and can be used
+ * to set the parser into a clear state so it can be re-used.
+ *
+ * @since 1.1.2
+ */
+ protected void init()
+ {
+ // nop
+ }
}
Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java?rev=807164&r1=807163&r2=807164&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java Mon Aug 24 11:59:25 2009
@@ -164,6 +164,9 @@
{
throw new ParseException( "Macro execution failed: " + ex.getMessage(), ex );
}
+
+ setSecondParsing( false );
+ init();
}
/**
@@ -210,18 +213,6 @@
}
/**
- * Initialize the parser. This is called first by
- * {@link #parse(java.io.Reader, org.apache.maven.doxia.sink.Sink)} and can be used
- * to set the parser into a clear state so it can be re-used.
- *
- * @since 1.1.1
- */
- protected void init()
- {
- // default: empty
- }
-
- /**
* Parse the model from the XmlPullParser into the given sink.
*
* @param parser A parser, not null.
Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java?rev=807164&r1=807163&r2=807164&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java Mon Aug 24 11:59:25 2009
@@ -83,6 +83,8 @@
public void parse( Reader source, Sink sink )
throws ParseException
{
+ init();
+
try
{
super.parse( source, sink );
@@ -90,6 +92,9 @@
finally
{
logWarnings();
+
+ setSecondParsing( false );
+ init();
}
}
@@ -693,6 +698,25 @@
return id;
}
+ /** {@inheritDoc} */
+ protected void init()
+ {
+ super.init();
+
+ this.scriptBlock = false;
+ this.isLink = false;
+ this.isAnchor = false;
+ this.orderedListDepth = 0;
+ this.sectionLevel = 0;
+ this.inVerbatim = false;
+ this.inFigure = false;
+ while( this.decoration.getAttributeNames().hasMoreElements() )
+ {
+ this.decoration.removeAttribute( this.decoration.getAttributeNames().nextElement() );
+ }
+ this.warnMessages = null;
+ }
+
private void handleAEnd( Sink sink )
{
if ( isLink )
Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractSink.java?rev=807164&r1=807163&r2=807164&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractSink.java Mon Aug 24 11:59:25 2009
@@ -100,4 +100,15 @@
return buffer.toString();
}
+
+ /**
+ * This is called in {@link #head()} or in {@link #close()}, and can be used
+ * to set the sink into a clear state so it can be re-used.
+ *
+ * @since 1.1.2
+ */
+ protected void init()
+ {
+ // nop
+ }
}
Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java?rev=807164&r1=807163&r2=807164&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java Mon Aug 24 11:59:25 2009
@@ -59,7 +59,7 @@
// ----------------------------------------------------------------------
/** The PrintWriter to write the result. */
- private PrintWriter writer;
+ private final PrintWriter writer;
/** Used to collect text events mainly for the head events. */
private StringBuffer textBuffer = new StringBuffer();
@@ -149,6 +149,8 @@
this.tableCaptionWriterStack = new LinkedList();
this.tableCaptionXMLWriterStack = new LinkedList();
this.tableCaptionStack = new LinkedList();
+
+ init();
}
// ----------------------------------------------------------------------
@@ -248,9 +250,19 @@
/**
* Reset all variables.
+ *
+ * @deprecated since 1.1.2, use {@link #init()} instead of.
*/
protected void resetState()
{
+ init();
+ }
+
+ /** {@inheritDoc} */
+ protected void init()
+ {
+ super.init();
+
resetTextBuffer();
this.headFlag = false;
@@ -263,6 +275,18 @@
this.tableCaptionWriterStack.clear();
this.tableCaptionXMLWriterStack.clear();
this.tableCaptionStack.clear();
+
+ this.headFlag = false;
+ this.figureCaptionFlag = false;
+ this.paragraphFlag = false;
+ this.verbatimFlag = false;
+ this.evenTableRow = true;
+ this.tableAttributes = null;
+ this.legacyFigure = false;
+ this.legacyFigureCaption = false;
+ this.inFigure = false;
+ this.tableRows = false;
+ this.warnMessages = null;
}
/**
@@ -1937,7 +1961,7 @@
this.warnMessages = null;
}
- resetState();
+ init();
}
// ----------------------------------------------------------------------
Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java?rev=807164&r1=807163&r2=807164&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java Mon Aug 24 11:59:25 2009
@@ -34,449 +34,549 @@
public class WellformednessCheckingSink
extends AbstractSink
{
- private Stack elements = new Stack();
+ private final Stack elements = new Stack();
- private List errors = new LinkedList();
+ private final List errors = new LinkedList();
+ /** {@inheritDoc} */
public void head()
{
startElement( "head" );
}
+ /** {@inheritDoc} */
public void head_()
{
checkWellformedness( "head" );
}
+ /** {@inheritDoc} */
public void body()
{
startElement( "body" );
}
+ /** {@inheritDoc} */
public void body_()
{
checkWellformedness( "body" );
}
+ /** {@inheritDoc} */
public void section1()
{
startElement( "section1" );
}
+ /** {@inheritDoc} */
public void section1_()
{
checkWellformedness( "section1" );
}
+ /** {@inheritDoc} */
public void section2()
{
startElement( "section2" );
}
+ /** {@inheritDoc} */
public void section2_()
{
checkWellformedness( "section2" );
}
+ /** {@inheritDoc} */
public void section3()
{
startElement( "section3" );
}
+ /** {@inheritDoc} */
public void section3_()
{
checkWellformedness( "section3" );
}
+ /** {@inheritDoc} */
public void section4()
{
startElement( "section4" );
}
+ /** {@inheritDoc} */
public void section4_()
{
checkWellformedness( "section4" );
}
+ /** {@inheritDoc} */
public void section5()
{
startElement( "section5" );
}
+ /** {@inheritDoc} */
public void section5_()
{
checkWellformedness( "section5" );
}
+ /** {@inheritDoc} */
public void list()
{
startElement( "list" );
}
+ /** {@inheritDoc} */
public void list_()
{
checkWellformedness( "list" );
}
+ /** {@inheritDoc} */
public void listItem()
{
startElement( "listItem" );
}
+ /** {@inheritDoc} */
public void listItem_()
{
checkWellformedness( "listItem" );
}
+ /** {@inheritDoc} */
public void numberedList( int numbering )
{
startElement( "numberedList" );
}
+ /** {@inheritDoc} */
public void numberedList_()
{
checkWellformedness( "numberedList" );
}
+ /** {@inheritDoc} */
public void numberedListItem()
{
startElement( "numberedListItem" );
}
+ /** {@inheritDoc} */
public void numberedListItem_()
{
checkWellformedness( "numberedListItem" );
}
+ /** {@inheritDoc} */
public void definitionList()
{
startElement( "definitionList" );
}
+ /** {@inheritDoc} */
public void definitionList_()
{
checkWellformedness( "definitionList" );
}
+ /** {@inheritDoc} */
public void definitionListItem()
{
startElement( "definitionListItem" );
}
+ /** {@inheritDoc} */
public void definitionListItem_()
{
checkWellformedness( "definitionListItem" );
}
+ /** {@inheritDoc} */
public void definition()
{
startElement( "definition" );
}
+ /** {@inheritDoc} */
public void definition_()
{
checkWellformedness( "definition" );
}
+ /** {@inheritDoc} */
public void figure()
{
startElement( "figure" );
}
+ /** {@inheritDoc} */
public void figure_()
{
checkWellformedness( "figure" );
}
+ /** {@inheritDoc} */
public void table()
{
startElement( "table" );
}
+ /** {@inheritDoc} */
public void table_()
{
checkWellformedness( "table" );
}
+ /** {@inheritDoc} */
public void tableRows( int[] justification, boolean grid )
{
startElement( "tableRows" );
}
+ /** {@inheritDoc} */
public void tableRows_()
{
checkWellformedness( "tableRows" );
}
+ /** {@inheritDoc} */
public void tableRow()
{
startElement( "tableRow" );
}
+ /** {@inheritDoc} */
public void tableRow_()
{
checkWellformedness( "tableRow" );
}
+ /** {@inheritDoc} */
public void title()
{
startElement( "title" );
}
+ /** {@inheritDoc} */
public void title_()
{
checkWellformedness( "title" );
}
+ /** {@inheritDoc} */
public void author()
{
startElement( "author" );
}
+ /** {@inheritDoc} */
public void author_()
{
checkWellformedness( "author" );
}
+ /** {@inheritDoc} */
public void date()
{
startElement( "date" );
}
+ /** {@inheritDoc} */
public void date_()
{
checkWellformedness( "date" );
}
+ /** {@inheritDoc} */
public void sectionTitle()
{
startElement( "sectionTitle" );
}
+ /** {@inheritDoc} */
public void sectionTitle_()
{
checkWellformedness( "sectionTitle" );
}
+ /** {@inheritDoc} */
public void sectionTitle1()
{
startElement( "sectionTitle1" );
}
+ /** {@inheritDoc} */
public void sectionTitle1_()
{
checkWellformedness( "sectionTitle1" );
}
+ /** {@inheritDoc} */
public void sectionTitle2()
{
startElement( "sectionTitle2" );
}
+ /** {@inheritDoc} */
public void sectionTitle2_()
{
checkWellformedness( "sectionTitle2" );
}
+ /** {@inheritDoc} */
public void sectionTitle3()
{
startElement( "sectionTitle3" );
}
+ /** {@inheritDoc} */
public void sectionTitle3_()
{
checkWellformedness( "sectionTitle3" );
}
+ /** {@inheritDoc} */
public void sectionTitle4()
{
startElement( "sectionTitle4" );
}
+ /** {@inheritDoc} */
public void sectionTitle4_()
{
checkWellformedness( "sectionTitle4" );
}
+ /** {@inheritDoc} */
public void sectionTitle5()
{
startElement( "sectionTitle5" );
}
+ /** {@inheritDoc} */
public void sectionTitle5_()
{
checkWellformedness( "sectionTitle5" );
}
+ /** {@inheritDoc} */
public void paragraph()
{
startElement( "paragraph" );
}
+ /** {@inheritDoc} */
public void paragraph_()
{
checkWellformedness( "paragraph" );
}
+ /** {@inheritDoc} */
public void verbatim( boolean boxed )
{
startElement( "verbatim" );
}
+ /** {@inheritDoc} */
public void verbatim_()
{
checkWellformedness( "verbatim" );
}
+ /** {@inheritDoc} */
public void definedTerm()
{
startElement( "definedTerm" );
}
+ /** {@inheritDoc} */
public void definedTerm_()
{
checkWellformedness( "definedTerm" );
}
+ /** {@inheritDoc} */
public void figureCaption()
{
startElement( "figureCaption" );
}
+ /** {@inheritDoc} */
public void figureCaption_()
{
checkWellformedness( "figureCaption" );
}
+ /** {@inheritDoc} */
public void tableCell()
{
startElement( "tableCell" );
}
+ /** {@inheritDoc} */
public void tableCell( String width )
{
startElement( "tableCell" );
}
+ /** {@inheritDoc} */
public void tableCell_()
{
checkWellformedness( "tableCell" );
}
+ /** {@inheritDoc} */
public void tableHeaderCell()
{
startElement( "tableHeaderCell" );
}
+ /** {@inheritDoc} */
public void tableHeaderCell( String width )
{
startElement( "tableHeaderCell" );
}
+ /** {@inheritDoc} */
public void tableHeaderCell_()
{
checkWellformedness( "tableHeaderCell" );
}
+ /** {@inheritDoc} */
public void tableCaption()
{
startElement( "tableCaption" );
}
+ /** {@inheritDoc} */
public void tableCaption_()
{
checkWellformedness( "tableCaption" );
}
+ /** {@inheritDoc} */
public void figureGraphics( String name )
{
+ // nop
}
+ /** {@inheritDoc} */
public void horizontalRule()
{
+ // nop
}
+ /** {@inheritDoc} */
public void pageBreak()
{
+ // nop
}
+ /** {@inheritDoc} */
public void anchor( String name )
{
startElement( "anchor" );
}
+ /** {@inheritDoc} */
public void anchor_()
{
checkWellformedness( "anchor" );
}
+ /** {@inheritDoc} */
public void link( String name )
{
startElement( "link" );
}
+ /** {@inheritDoc} */
public void link_()
{
checkWellformedness( "link" );
}
+ /** {@inheritDoc} */
public void italic()
{
startElement( "italic" );
}
+ /** {@inheritDoc} */
public void italic_()
{
checkWellformedness( "italic" );
}
+ /** {@inheritDoc} */
public void bold()
{
startElement( "bold" );
}
+ /** {@inheritDoc} */
public void bold_()
{
checkWellformedness( "bold" );
}
+ /** {@inheritDoc} */
public void monospaced()
{
startElement( "monospaced" );
}
+ /** {@inheritDoc} */
public void monospaced_()
{
checkWellformedness( "monospaced" );
}
+ /** {@inheritDoc} */
public void lineBreak()
{
+ // nop
}
+ /** {@inheritDoc} */
public void nonBreakingSpace()
{
+ // nop
}
+ /** {@inheritDoc} */
public void text( String text )
{
+ // nop
}
+ /** {@inheritDoc} */
public void rawText( String text )
{
+ // nop
}
/** {@inheritDoc} */
public void comment( String comment )
{
+ // nop
}
+ /** {@inheritDoc} */
public void flush()
{
+ // nop
}
+ /** {@inheritDoc} */
public void close()
{
+ this.elements.clear();
+ this.errors.clear();
}
/**