Author: vsiveton
Date: Sat May 30 13:55:40 2009
New Revision: 780266
URL: http://svn.apache.org/viewvc?rev=780266&view=rev
Log:
o reduced warning log message for some parser/skin.
Modified:
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/XhtmlBaseSink.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java
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=780266&r1=780265&r2=780266&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
Sat May 30 13:55:40 2009
@@ -20,7 +20,9 @@
*/
import java.io.Reader;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@@ -73,8 +75,9 @@
/** Decoration properties, eg for texts. */
private final SinkEventAttributeSet decoration = new
SinkEventAttributeSet();
- /** Used to add warn message when links are modified. */
- private Set modifiedLinks;
+ /** Map of warn messages with a String as key to describe the error type
and a Set as value.
+ * Using to reduce warn messages. */
+ private Map warnMessages;
/** {...@inheritdoc} */
public void parse( Reader source, Sink sink )
@@ -82,17 +85,23 @@
{
super.parse( source, sink );
- if ( getLog().isWarnEnabled() )
+ if ( getLog().isWarnEnabled() && this.warnMessages != null &&
!isSecondParsing() )
{
- if ( this.modifiedLinks != null )
+ for ( Iterator it = this.warnMessages.entrySet().iterator();
it.hasNext(); )
{
- for ( Iterator it = this.modifiedLinks.iterator();
it.hasNext(); )
+ Map.Entry entry = (Map.Entry) it.next();
+
+ Set set = (Set) entry.getValue();
+
+ for ( Iterator it2 = set.iterator(); it2.hasNext(); )
{
- getLog().warn( it.next().toString() );
- }
+ String msg = (String) it2.next();
- this.modifiedLinks = null;
+ getLog().warn( msg );
+ }
}
+
+ this.warnMessages = null;
}
}
@@ -686,7 +695,9 @@
if ( !DoxiaUtils.isValidId( id ) )
{
String linkAnchor = DoxiaUtils.encodeId( id, true );
- addModifiedLinkMessage( id, linkAnchor );
+
+ String msg = "Modified invalid link: '" + id + "' to '" +
linkAnchor + "'";
+ logMessage( "modifiedLink", msg );
return linkAnchor;
}
@@ -723,7 +734,8 @@
{
href = href.substring( 0, hashIndex ) + "#" +
DoxiaUtils.encodeId( hash, true );
- addModifiedLinkMessage( hash, href );
+ String msg = "Modified invalid link: '" + hash + "' to '"
+ href + "'";
+ logMessage( "modifiedLink", msg );
}
}
sink.link( href, attribs );
@@ -921,14 +933,35 @@
sink.tableRows( justif, grid );
}
- private void addModifiedLinkMessage( String hash, String linkAnchor )
+ /**
+ * If debug mode is enabled, log the <code>msg</code> as is, otherwise add
unique msg in <code>warnMessages</code>.
+ *
+ * @param key not null
+ * @param msg not null
+ * @see #parse(Reader, Sink)
+ * @since 1.1.1
+ */
+ private void logMessage( String key, String msg )
{
- if ( modifiedLinks == null )
+ msg = "[XHTML Parser] " + msg;
+ if ( getLog().isDebugEnabled() )
{
- modifiedLinks = new TreeSet();
+ getLog().debug( msg );
+
+ return;
}
- String msg = "[Xhtml Parser] Modified invalid link: '" + hash + "' to
'" + linkAnchor + "'";
- modifiedLinks.add( msg );
+ if ( warnMessages == null )
+ {
+ warnMessages = new HashMap();
+ }
+
+ Set set = (Set) warnMessages.get( key );
+ if ( set == null )
+ {
+ set = new TreeSet();
+ }
+ set.add( msg );
+ warnMessages.put( key, set );
}
}
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=780266&r1=780265&r2=780266&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
Sat May 30 13:55:40 2009
@@ -22,6 +22,11 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.html.HTML.Attribute;
@@ -111,6 +116,10 @@
* */
private boolean tableRows = false;
+ /** Map of warn messages with a String as key to describe the error type
and a Set as value.
+ * Using to reduce warn messages. */
+ private Map warnMessages;
+
// ----------------------------------------------------------------------
// Constructor
// ----------------------------------------------------------------------
@@ -1443,7 +1452,8 @@
{
id = DoxiaUtils.encodeId( name, true );
- getLog().warn( "[Xhtml Sink] Modified invalid anchor name: '" +
name + "' to '" + id + "'" );
+ String msg = "Modified invalid anchor name: '" + name + "' to '" +
id + "'";
+ logMessage( "modifiedLink", msg );
}
MutableAttributeSet att = new SinkEventAttributeSet();
@@ -1778,7 +1788,8 @@
{
if ( requiredParams == null || !( requiredParams[0] instanceof Integer
) )
{
- getLog().warn( "Missing type information for unknown event: " +
name + ", ignoring!" );
+ String msg = "No type information for unknown event: '" + name +
"', ignoring!";
+ logMessage( "noTypeInfo", msg );
return;
}
@@ -1803,7 +1814,8 @@
if ( tag == null )
{
- getLog().warn( "No HTML tag found for unknown Sink event: " + name
+ ", ignoring!" );
+ String msg = "No HTML tag found for unknown event: '" + name + "',
ignoring!";
+ logMessage( "noHtmlTag", msg );
}
else
{
@@ -1821,7 +1833,8 @@
}
else
{
- getLog().warn( "No type information for unknown Sink event: "
+ name + ", ignoring!" );
+ String msg = "No type information for unknown event: '" + name
+ "', ignoring!";
+ logMessage( "noTypeInfo", msg );
}
}
}
@@ -1838,6 +1851,25 @@
writer.write( tempWriter.toString() );
tempWriter = new StringWriter();
writer.close();
+
+ if ( getLog().isWarnEnabled() && this.warnMessages != null )
+ {
+ for ( Iterator it = this.warnMessages.entrySet().iterator();
it.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+
+ Set set = (Set) entry.getValue();
+
+ for ( Iterator it2 = set.iterator(); it2.hasNext(); )
+ {
+ String msg = (String) it2.next();
+
+ getLog().warn( msg );
+ }
+ }
+
+ this.warnMessages = null;
+ }
}
// ----------------------------------------------------------------------
@@ -1897,4 +1929,35 @@
tempWriter.write( unifyEOLs( text ) );
}
+ /**
+ * If debug mode is enabled, log the <code>msg</code> as is, otherwise add
unique msg in <code>warnMessages</code>.
+ *
+ * @param key not null
+ * @param msg not null
+ * @see #close()
+ * @since 1.1.1
+ */
+ private void logMessage( String key, String msg )
+ {
+ msg = "[XHTML Sink] " + msg;
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( msg );
+
+ return;
+ }
+
+ if ( warnMessages == null )
+ {
+ warnMessages = new HashMap();
+ }
+
+ Set set = (Set) warnMessages.get( key );
+ if ( set == null )
+ {
+ set = new TreeSet();
+ }
+ set.add( msg );
+ warnMessages.put( key, set );
+ }
}
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java?rev=780266&r1=780265&r2=780266&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
Sat May 30 13:55:40 2009
@@ -163,11 +163,9 @@
/** a line of AptSource. */
protected String line;
- /** Used to add warn message when links are ambiguous. */
- private Set ambiguousLinks;
-
- /** Used to add warn message when links are modified. */
- private Set modifiedLinks;
+ /** Map of warn messages with a String as key to describe the error type
and a Set as value.
+ * Using to reduce warn messages. */
+ protected Map warnMessages;
private static final int NUMBER_OF_SPACES = 85;
@@ -231,26 +229,23 @@
throw new AptParseException( ape.getMessage(), ape,
getSourceName(), getSourceLineNumber(), -1 );
}
- if ( getLog().isWarnEnabled() )
+ if ( getLog().isWarnEnabled() && this.warnMessages != null &&
!isSecondParsing() )
{
- if ( this.ambiguousLinks != null )
+ for ( Iterator it = this.warnMessages.entrySet().iterator();
it.hasNext(); )
{
- for ( Iterator it = this.ambiguousLinks.iterator();
it.hasNext(); )
- {
- getLog().warn( it.next().toString() );
- }
+ Map.Entry entry = (Map.Entry) it.next();
- this.ambiguousLinks = null;
- }
- if ( this.modifiedLinks != null )
- {
- for ( Iterator it = this.modifiedLinks.iterator();
it.hasNext(); )
+ Set set = (Set) entry.getValue();
+
+ for ( Iterator it2 = set.iterator(); it2.hasNext(); )
{
- getLog().warn( it.next().toString() );
- }
+ String msg = (String) it2.next();
- this.modifiedLinks = null;
+ getLog().warn( msg );
+ }
}
+
+ this.warnMessages = null;
}
}
@@ -483,7 +478,8 @@
if ( hash.endsWith( ".html" ) &&
!hash.startsWith( "./" ) )
{
- addAmbiguousLinkMessage( hash );
+ String msg = "Ambiguous link: '" + hash +
"'. If this is a local link, prepend \"./\"!";
+ logMessage( "ambiguousLink", msg );
}
if ( !DoxiaUtils.isValidId( hash ) )
@@ -492,7 +488,8 @@
linkAnchor.substring( 0, hashIndex ) +
"#"
+ DoxiaUtils.encodeId( hash, true
);
- addModifiedLinkMessage( hash, linkAnchor );
+ String msg = "Modified invalid link: '" +
hash + "' to '" + linkAnchor + "'";
+ logMessage( "modifiedLink", msg );
}
}
@@ -1584,32 +1581,35 @@
}
/**
- * @param hash not null
+ * If debug mode is enabled, log the <code>msg</code> as is, otherwise add
unique msg in <code>warnMessages</code>.
+ *
+ * @param key not null
+ * @param msg not null
+ * @see #parse(Reader, Sink)
+ * @since 1.1.1
*/
- private void addAmbiguousLinkMessage( String hash )
+ private void logMessage( String key, String msg )
{
- if ( ambiguousLinks == null )
+ msg = "[APT Parser] " + msg;
+ if ( getLog().isDebugEnabled() )
{
- ambiguousLinks = new TreeSet();
- }
+ getLog().debug( msg );
- String msg = "[Apt Parser] Ambiguous link: '" + hash + "'. If this is
a local link, prepend \"./\"!";
- ambiguousLinks.add( msg );
- }
+ return;
+ }
- /**
- * @param hash not null
- * @param linkAnchor not null
- */
- private void addModifiedLinkMessage( String hash, String linkAnchor )
- {
- if ( modifiedLinks == null )
+ if ( warnMessages == null )
{
- modifiedLinks = new TreeSet();
+ warnMessages = new HashMap();
}
- String msg = "[Apt Parser] Modified invalid link: '" + hash + "' to '"
+ linkAnchor + "'";
- modifiedLinks.add( msg );
+ Set set = (Set) warnMessages.get( key );
+ if ( set == null )
+ {
+ set = new TreeSet();
+ }
+ set.add( msg );
+ warnMessages.put( key, set );
}
// -----------------------------------------------------------------------
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java?rev=780266&r1=780265&r2=780266&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java
Sat May 30 13:55:40 2009
@@ -22,8 +22,13 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
+import java.util.TreeSet;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
@@ -145,6 +150,10 @@
private String encoding;
+ /** Map of warn messages with a String as key to describe the error type
and a Set as value.
+ * Using to reduce warn messages. */
+ private Map warnMessages;
+
/**
* Constructor, initialize the Writer.
*
@@ -1397,7 +1406,8 @@
{
id = DoxiaUtils.encodeId( name, true );
- getLog().warn( "[Docbook Sink] Modified invalid anchor name: '" +
name + "' to '" + id + "'" );
+ String msg = "Modified invalid anchor name: '" + name + "' to '" +
id + "'";
+ logMessage( "modifiedLink", msg );
}
MutableAttributeSet att = new SimpleAttributeSet();
@@ -1544,9 +1554,8 @@
comment = StringUtils.replace( comment, "--", "- -" );
}
- getLog().warn(
- "[Docbook Sink] Modified invalid comment: '" +
originalComment + "' to '" + comment
- + "'" );
+ String msg = "Modified invalid comment: '" + originalComment + "'
to '" + comment + "'";
+ logMessage( "modifiedComment", msg );
}
StringBuffer buffer = new StringBuffer( comment.length() + 9 );
@@ -1566,7 +1575,8 @@
*/
public void unknown( String name, Object[] requiredParams,
SinkEventAttributes attributes )
{
- getLog().warn( "Unknown Sink event in DocBookSink: " + name + ",
ignoring!" );
+ String msg = "Unknown Sink event: '" + name + "', ignoring!";
+ logMessage( "unknownEvent", msg );
}
// -----------------------------------------------------------------------
@@ -1622,6 +1632,25 @@
public void close()
{
out.close();
+
+ if ( getLog().isWarnEnabled() && this.warnMessages != null )
+ {
+ for ( Iterator it = this.warnMessages.entrySet().iterator();
it.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+
+ Set set = (Set) entry.getValue();
+
+ for ( Iterator it2 = set.iterator(); it2.hasNext(); )
+ {
+ String msg = (String) it2.next();
+
+ getLog().warn( msg );
+ }
+ }
+
+ this.warnMessages = null;
+ }
}
/** {...@inheritdoc} */
@@ -1640,4 +1669,36 @@
{
this.skip = skip;
}
+
+ /**
+ * If debug mode is enabled, log the <code>msg</code> as is, otherwise add
unique msg in <code>warnMessages</code>.
+ *
+ * @param key not null
+ * @param msg not null
+ * @see #close()
+ * @since 1.1.1
+ */
+ private void logMessage( String key, String msg )
+ {
+ msg = "[Docbook Sink] " + msg;
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( msg );
+
+ return;
+ }
+
+ if ( warnMessages == null )
+ {
+ warnMessages = new HashMap();
+ }
+
+ Set set = (Set) warnMessages.get( key );
+ if ( set == null )
+ {
+ set = new TreeSet();
+ }
+ set.add( msg );
+ warnMessages.put( key, set );
+ }
}
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java?rev=780266&r1=780265&r2=780266&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
Sat May 30 13:55:40 2009
@@ -21,7 +21,11 @@
import java.io.IOException;
import java.io.Reader;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
import javax.swing.text.html.HTML.Attribute;
@@ -71,6 +75,9 @@
/** Used to collect text events. */
private StringBuffer buffer;
+ /** Map of warn messages with a String as key to describe the error type
and a Set as value.
+ * Using to reduce warn messages. */
+ private Map warnMessages;
/** {...@inheritdoc} */
public void parse( Reader source, Sink sink )
@@ -80,6 +87,25 @@
super.parse( source, sink );
writeFaqs( sink );
+
+ if ( getLog().isWarnEnabled() && this.warnMessages != null &&
!isSecondParsing() )
+ {
+ for ( Iterator it = this.warnMessages.entrySet().iterator();
it.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+
+ Set set = (Set) entry.getValue();
+
+ for ( Iterator it2 = set.iterator(); it2.hasNext(); )
+ {
+ String msg = (String) it2.next();
+
+ getLog().warn( msg );
+ }
+ }
+
+ this.warnMessages = null;
+ }
}
/** {...@inheritdoc} */
@@ -122,9 +148,12 @@
}
else if ( !DoxiaUtils.isValidId( currentPart.getId() ) )
{
- getLog().warn( "Modified invalid id: " + currentPart.getId() );
+ String linkAnchor = DoxiaUtils.encodeId( currentPart.getId(),
true );
- currentPart.setId( DoxiaUtils.encodeId( currentPart.getId(),
true ) );
+ String msg = "Modified invalid link: '" + currentPart.getId()
+ "' to '" + linkAnchor + "'";
+ logMessage( "modifiedLink", msg );
+
+ currentPart.setId( linkAnchor );
}
}
else if ( parser.getName().equals( TITLE.toString() ) )
@@ -157,9 +186,12 @@
}
else if ( !DoxiaUtils.isValidId( currentFaq.getId() ) )
{
- getLog().warn( "Modified invalid id: " + currentFaq.getId() );
+ String linkAnchor = DoxiaUtils.encodeId( currentPart.getId(),
true );
+
+ String msg = "Modified invalid link: '" + currentPart.getId()
+ "' to '" + linkAnchor + "'";
+ logMessage( "modifiedLink", msg );
- currentFaq.setId( DoxiaUtils.encodeId( currentFaq.getId(),
true ) );
+ currentFaq.setId( linkAnchor );
}
}
if ( parser.getName().equals( QUESTION_TAG.toString() ) )
@@ -502,4 +534,35 @@
sink.paragraph_();
}
+ /**
+ * If debug mode is enabled, log the <code>msg</code> as is, otherwise add
unique msg in <code>warnMessages</code>.
+ *
+ * @param key not null
+ * @param msg not null
+ * @see #parse(Reader, Sink)
+ * @since 1.1.1
+ */
+ private void logMessage( String key, String msg )
+ {
+ msg = "[FML Parser] " + msg;
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( msg );
+
+ return;
+ }
+
+ if ( warnMessages == null )
+ {
+ warnMessages = new HashMap();
+ }
+
+ Set set = (Set) warnMessages.get( key );
+ if ( set == null )
+ {
+ set = new TreeSet();
+ }
+ set.add( msg );
+ warnMessages.put( key, set );
+ }
}
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java?rev=780266&r1=780265&r2=780266&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java
Sat May 30 13:55:40 2009
@@ -327,7 +327,8 @@
{
anchor = DoxiaUtils.encodeId( name, true );
- getLog().warn( "[FO Sink] Modified invalid anchor name: " + name );
+ String msg = "Modified invalid anchor name: '" + name + "' to '" +
anchor + "'";
+ logMessage( "modifiedLink", msg );
}
anchor = "#" + anchor;
@@ -368,9 +369,11 @@
if ( !DoxiaUtils.isValidId( anchor ) )
{
+ String tmp = anchor;
anchor = DoxiaUtils.encodeId( anchor, true );
- getLog().warn( "[FO Sink] Modified invalid link name: " + name
);
+ String msg = "Modified invalid anchor name: '" + tmp + "' to
'" + anchor + "'";
+ logMessage( "modifiedLink", msg );
}
if ( docName != null )
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java?rev=780266&r1=780265&r2=780266&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
Sat May 30 13:55:40 2009
@@ -23,7 +23,12 @@
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
+import java.util.TreeSet;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.html.HTML.Attribute;
@@ -93,6 +98,10 @@
private String languageId;
+ /** Map of warn messages with a String as key to describe the error type
and a Set as value.
+ * Using to reduce warn messages. */
+ protected Map warnMessages;
+
/**
* Constructor, initialize the Writer.
*
@@ -1133,7 +1142,8 @@
{
anchor = DoxiaUtils.encodeId( name, true );
- getLog().warn( "[FO Sink] Modified invalid anchor name: '" + name
+ "' to '" + anchor + "'" );
+ String msg = "Modified invalid anchor name: '" + name + "' to '" +
anchor + "'";
+ logMessage( "modifiedLink", msg );
}
anchor = "#" + name;
@@ -1174,7 +1184,8 @@
{
anchor = DoxiaUtils.encodeId( anchor, true );
- getLog().warn( "[FO Sink] Modified invalid anchor name: '" +
name + "' to '" + anchor + "'" );
+ String msg = "Modified invalid anchor name: '" + name + "' to
'" + anchor + "'";
+ logMessage( "modifiedLink", msg );
}
anchor = "#" + anchor;
@@ -1305,6 +1316,25 @@
{
getLog().debug( e );
}
+
+ if ( getLog().isWarnEnabled() && this.warnMessages != null )
+ {
+ for ( Iterator it = this.warnMessages.entrySet().iterator();
it.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+
+ Set set = (Set) entry.getValue();
+
+ for ( Iterator it2 = set.iterator(); it2.hasNext(); )
+ {
+ String msg = (String) it2.next();
+
+ getLog().warn( msg );
+ }
+ }
+
+ this.warnMessages = null;
+ }
}
/**
@@ -1315,7 +1345,8 @@
*/
public void unknown( String name, Object[] requiredParams,
SinkEventAttributes attributes )
{
- getLog().warn( "Unknown Sink event in FoSink: " + name + ", ignoring!"
);
+ String msg = "Unknown Sink event: '" + name + "', ignoring!";
+ logMessage( "unknownEvent", msg );
}
/** {...@inheritdoc} */
@@ -1331,7 +1362,8 @@
comment = StringUtils.replace( comment, "--", "- -" );
}
- getLog().warn( "[FO Sink] Modified invalid comment: '" +
originalComment + "' to '" + comment + "'" );
+ String msg = "Modified invalid comment: '" + originalComment + "'
to '" + comment + "'";
+ logMessage( "modifyComment", msg );
}
StringBuffer buf = new StringBuffer( comment.length() + 9 );
@@ -1658,4 +1690,36 @@
{
// do nothing, overridden by AggregateSink
}
+
+ /**
+ * If debug mode is enabled, log the <code>msg</code> as is, otherwise add
unique msg in <code>warnMessages</code>.
+ *
+ * @param key not null
+ * @param msg not null
+ * @see #close()
+ * @since 1.1.1
+ */
+ protected void logMessage( String key, String msg )
+ {
+ msg = "[FO Sink] " + msg;
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( msg );
+
+ return;
+ }
+
+ if ( warnMessages == null )
+ {
+ warnMessages = new HashMap();
+ }
+
+ Set set = (Set) warnMessages.get( key );
+ if ( set == null )
+ {
+ set = new TreeSet();
+ }
+ set.add( msg );
+ warnMessages.put( key, set );
+ }
}
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java?rev=780266&r1=780265&r2=780266&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
Sat May 30 13:55:40 2009
@@ -30,7 +30,12 @@
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkAdapter;
@@ -103,6 +108,10 @@
private String tableCaption = null;
+ /** Map of warn messages with a String as key to describe the error type
and a Set as value.
+ * Using to reduce warn messages. */
+ private Map warnMessages;
+
/**
* <p>Constructor for ITextSink.</p>
*
@@ -172,6 +181,25 @@
public void close()
{
IOUtil.close( writer );
+
+ if ( getLog().isWarnEnabled() && this.warnMessages != null )
+ {
+ for ( Iterator it = this.warnMessages.entrySet().iterator();
it.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+
+ Set set = (Set) entry.getValue();
+
+ for ( Iterator it2 = set.iterator(); it2.hasNext(); )
+ {
+ String msg = (String) it2.next();
+
+ getLog().warn( msg );
+ }
+ }
+
+ this.warnMessages = null;
+ }
}
/** {...@inheritdoc} */
@@ -1181,8 +1209,11 @@
if ( urlName == null )
{
- getLog().warn( "No image " + name + " found in the class loader.
Try to call setClassLoader(ClassLoader)"
- + " before." );
+ String msg =
+ "No image '" + name
+ + "' found in the class loader. Try to call
setClassLoader(ClassLoader) before.";
+ logMessage( "imageNotFound", msg );
+
return;
}
@@ -1316,7 +1347,8 @@
{
id = DoxiaUtils.encodeId( name, true );
- getLog().warn( "Modified invalid anchor name: " + name );
+ String msg = "Modified invalid link: '" + name + "' to '" + id +
"'";
+ logMessage( "modifiedLink", msg );
}
writeStartElement( ElementTags.ANCHOR );
@@ -1500,7 +1532,8 @@
*/
public void unknown( String name, Object[] requiredParams,
SinkEventAttributes attributes )
{
- getLog().warn( "Unknown Sink event in ITextSink: " + name + ",
ignoring!" );
+ String msg = "Unknown Sink event: '" + name + "', ignoring!";
+ logMessage( "unknownEvent", msg );
}
/**
@@ -1648,4 +1681,36 @@
writeAddAttribute( ElementTags.RED, fontColorRed );
// writeAddAttribute( ElementTags.LOCALDESTINATION, localDestination );
}
+
+ /**
+ * If debug mode is enabled, log the <code>msg</code> as is, otherwise add
unique msg in <code>warnMessages</code>.
+ *
+ * @param key not null
+ * @param msg not null
+ * @see #close()
+ * @since 1.1.1
+ */
+ private void logMessage( String key, String msg )
+ {
+ msg = "[iText Sink] " + msg;
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( msg );
+
+ return;
+ }
+
+ if ( warnMessages == null )
+ {
+ warnMessages = new HashMap();
+ }
+
+ Set set = (Set) warnMessages.get( key );
+ if ( set == null )
+ {
+ set = new TreeSet();
+ }
+ set.add( msg );
+ warnMessages.put( key, set );
+ }
}
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java?rev=780266&r1=780265&r2=780266&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java
Sat May 30 13:55:40 2009
@@ -29,8 +29,13 @@
import java.io.PrintWriter;
import java.io.Writer;
+import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
+import java.util.TreeSet;
import java.util.Vector;
import org.apache.maven.doxia.sink.Sink;
@@ -210,6 +215,10 @@
protected OutputStream stream; // for raw image data
+ /** Map of warn messages with a String as key to describe the error type
and a Set as value.
+ * Using to reduce warn messages. */
+ private Map warnMessages;
+
// -----------------------------------------------------------------------
/**
@@ -1188,8 +1197,11 @@
if ( !source.toLowerCase().endsWith( ".ppm" ) )
{
// TODO support more image types!
- getLog().warn( "Unsupported image type for image file: '" + source
+ "'.");
- getLog().warn( "Only PPM image type is currently supported.");
+ String msg =
+ "Unsupported image type for image file: '" + source + "'. Only
PPM image type is "
+ + "currently supported.";
+ logMessage( "unsupportedImage", msg );
+
return;
}
@@ -1592,7 +1604,8 @@
*/
public void unknown( String name, Object[] requiredParams,
SinkEventAttributes attributes )
{
- getLog().warn( "Unknown Sink event in RtfSink: " + name + ",
ignoring!" );
+ String msg = "Unknown Sink event: '" + name + "', ignoring!";
+ logMessage( "unknownEvent", msg );
}
private static String normalize( String s )
@@ -1716,6 +1729,57 @@
public void close()
{
writer.close();
+
+ if ( getLog().isWarnEnabled() && this.warnMessages != null )
+ {
+ for ( Iterator it = this.warnMessages.entrySet().iterator();
it.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+
+ Set set = (Set) entry.getValue();
+
+ for ( Iterator it2 = set.iterator(); it2.hasNext(); )
+ {
+ String msg = (String) it2.next();
+
+ getLog().warn( msg );
+ }
+ }
+
+ this.warnMessages = null;
+ }
+ }
+
+ /**
+ * If debug mode is enabled, log the <code>msg</code> as is, otherwise add
unique msg in <code>warnMessages</code>.
+ *
+ * @param key not null
+ * @param msg not null
+ * @see #close()
+ * @since 1.1.1
+ */
+ private void logMessage( String key, String msg )
+ {
+ msg = "[RTF Sink] " + msg;
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( msg );
+
+ return;
+ }
+
+ if ( warnMessages == null )
+ {
+ warnMessages = new HashMap();
+ }
+
+ Set set = (Set) warnMessages.get( key );
+ if ( set == null )
+ {
+ set = new TreeSet();
+ }
+ set.add( msg );
+ warnMessages.put( key, set );
}
// -----------------------------------------------------------------------