maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r628378 - in /maven/doxia/doxia/trunk/doxia-modules: doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/ doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/ doxia-module-fo/src/main/java/org/apache/maven/doxia/mo...
Date Sat, 16 Feb 2008 21:12:17 GMT
Author: ltheussl
Date: Sat Feb 16 13:12:16 2008
New Revision: 628378

URL: http://svn.apache.org/viewvc?rev=628378&view=rev
Log:
Clean up some log and error handling

Modified:
    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-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.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/FoConfiguration.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-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java

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=628378&r1=628377&r2=628378&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 Feb 16 13:12:16 2008
@@ -168,6 +168,7 @@
             this.source = new AptReaderSource( new StringReader( sourceContent ) );
 
             this.sink = sink;
+            sink.enableLogging( getLog() );
 
             blockFileName = null;
 
@@ -989,7 +990,7 @@
      * @param sink the sink to receive the events.
      * @throws AptParseException if something goes wrong.
      */
-    private static void doTraverseText( String text,
+    private void doTraverseText( String text,
                                         int begin,
                                         int end,
                                         Sink sink )
@@ -1056,7 +1057,10 @@
                                     }
                                     catch ( NumberFormatException e )
                                     {
-                                        // TODO: log
+                                        if ( getLog().isDebugEnabled() )
+                                        {
+                                            getLog().debug( "Not a number: " + text.substring(
i + 2, i + 4 ) );
+                                        }
                                     }
 
                                     i += 3;
@@ -1080,7 +1084,10 @@
                                     }
                                     catch ( NumberFormatException e )
                                     {
-                                        // TODO: log
+                                        if ( getLog().isDebugEnabled() )
+                                        {
+                                            getLog().debug( "Not a number: " + text.substring(
i + 2, i + 6 ) );
+                                        }
                                     }
 
                                     i += 5;
@@ -1110,7 +1117,10 @@
                                     }
                                     catch ( NumberFormatException e )
                                     {
-                                        // TODO: log
+                                        if ( getLog().isDebugEnabled() )
+                                        {
+                                            getLog().debug( "Not a number: " + text.substring(
i + 1, i + 1 + octalChars ) );
+                                        }
                                     }
 
                                     i += octalChars;
@@ -1363,7 +1373,7 @@
      * @return String
      * @throws AptParseException if something goes wrong.
      */
-    private static String getTraversedLink( String text,
+    private String getTraversedLink( String text,
                                             int begin,
                                             int end )
         throws AptParseException
@@ -1400,7 +1410,7 @@
      * @return String
      * @throws AptParseException if something goes wrong.
      */
-    private static String getTraversedAnchor( String text,
+    private String getTraversedAnchor( String text,
                                               int begin,
                                               int end )
         throws AptParseException
@@ -1435,7 +1445,7 @@
      * @return String
      * @throws AptParseException if something goes wrong.
      */
-    private static String doGetTraversedLink( String text,
+    private String doGetTraversedLink( String text,
                                               int begin,
                                               int end )
         throws AptParseException
@@ -1603,7 +1613,7 @@
                                      int end )
             throws AptParseException
         {
-            AptParser.doTraverseText( text, begin, end, AptParser.this.sink );
+            AptParser.this.doTraverseText( text, begin, end, AptParser.this.sink );
         }
 
         /**
@@ -1787,7 +1797,7 @@
                         AptParser.this.sink.lineBreak();
                     }
 
-                    AptParser.doTraverseText( line, 0, lineLength, AptParser.this.sink );
+                    AptParser.this.doTraverseText( line, 0, lineLength, AptParser.this.sink
);
                 }
             }
 
@@ -2348,7 +2358,7 @@
             if ( captionIndex >= 0 )
             {
                 AptParser.this.sink.tableCaption();
-                AptParser.doTraverseText( text, captionIndex, textLength, AptParser.this.sink
);
+                AptParser.this.doTraverseText( text, captionIndex, textLength, AptParser.this.sink
);
                 AptParser.this.sink.tableCaption_();
             }
 
@@ -2450,7 +2460,7 @@
                     }
                     if ( cell.length() > 0 )
                     {
-                        AptParser.doTraverseText( cell.toString(), 0, cell.length(), AptParser.this.sink
);
+                        AptParser.this.doTraverseText( cell.toString(), 0, cell.length(),
AptParser.this.sink );
                         cell.setLength( 0 );
                     }
                     if ( headers[i] )

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.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/FmlContentParser.java?rev=628378&r1=628377&r2=628378&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java
Sat Feb 16 13:12:16 2008
@@ -41,13 +41,25 @@
     protected void handleStartTag( XmlPullParser parser, Sink sink )
         throws XmlPullParserException, MacroExecutionException
     {
-        if ( parser.getName().equals( SOURCE_TAG.toString() ) )
+        if ( parser.getName().equals( QUESTION_TAG.toString() )
+            || parser.getName().equals( ANSWER_TAG.toString() ) )
+        {
+            // ignore
+        }
+        else if ( parser.getName().equals( SOURCE_TAG.toString() ) )
         {
             sink.verbatim( true );
         }
         else if ( !baseStartTag( parser, sink ) )
         {
-            // TODO: log( "Unrecognized start tag!" );
+            if ( getLog().isWarnEnabled() )
+            {
+                String position = "[" + parser.getLineNumber() + ":"
+                    + parser.getColumnNumber() + "]";
+                String tag = "<" + parser.getName() + ">";
+
+                getLog().warn( "Unrecognized fml tag: " + tag + " at " + position );
+            }
         }
     }
 
@@ -61,7 +73,7 @@
         }
         else if ( !baseEndTag( parser, sink ) )
         {
-            // TODO: log( "Unrecognized end tag!" );
+            // unrecognized tag is already logged in StartTag
         }
     }
 }

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=628378&r1=628377&r2=628378&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 Feb 16 13:12:16 2008
@@ -289,6 +289,7 @@
         throws IOException, XmlPullParserException, ParseException
     {
         FmlContentParser xdocParser = new FmlContentParser();
+        xdocParser.enableLogging( getLog() );
 
         sink.head();
         sink.title();

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=628378&r1=628377&r2=628378&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 Feb 16 13:12:16 2008
@@ -126,7 +126,7 @@
 
         if ( docName == null )
         {
-            // TODO: log.warn( "No document root specified, local links will not be resolved
correctly!" )
+            getLog().warn( "No document root specified, local links will not be resolved
correctly!" );
         }
         else
         {
@@ -196,7 +196,7 @@
     {
         if ( StringUtils.isEmpty( name ) )
         {
-            // TODO log this behavior
+            getLog().warn( "Empty document reference, links will not be resolved correctly!"
);
             return "";
         }
 

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.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/FoConfiguration.java?rev=628378&r1=628377&r2=628378&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java
Sat Feb 16 13:12:16 2008
@@ -65,7 +65,8 @@
         }
         catch ( ConfigurationException cex )
         {
-            throw new RuntimeException( cex ); // TODO
+            // this should not happen
+            throw new RuntimeException( cex );
         }
 
         this.sets = config.getList( "xsl:attribute-set[@name]" );

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=628378&r1=628377&r2=628378&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 Feb 16 13:12:16 2008
@@ -901,7 +901,7 @@
         }
         catch ( IOException e )
         {
-            // TODO: log
+            getLog().debug( e );
         }
     }
 
@@ -914,7 +914,7 @@
         }
         catch ( IOException e )
         {
-            // TODO: log
+            getLog().debug( e );
         }
     }
 
@@ -1053,11 +1053,11 @@
     {
         try
         {
-            out.write( text );
+            out.write( unifyEOLs( text ) );
         }
         catch ( IOException e )
         {
-            // TODO: log
+            getLog().debug( e );
         }
     }
 

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java?rev=628378&r1=628377&r2=628378&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java
Sat Feb 16 13:12:16 2008
@@ -86,7 +86,9 @@
      */
     public LatexSink( Writer out )
     {
-        this( out, defaultSinkCommands(), defaultPreamble() );
+        this.out = new LineBreaker( out );
+        this.sinkCommands = defaultSinkCommands();
+        this.preamble = defaultPreamble();
     }
 
     /**
@@ -1108,7 +1110,7 @@
      * @throws java.io.IOException if the resource file cannot be read.
      * @return InputStream
      */
-    public static InputStream getDefaultSinkCommands()
+    private static InputStream getDefaultSinkCommands()
         throws IOException
     {
         return LatexSink.class.getResource( "default_sink_commands.tex" ).openStream();
@@ -1120,7 +1122,7 @@
      * @return InputStream
      * @throws java.io.IOException if the resource file cannot be read.
      */
-    public static InputStream getDefaultPreamble()
+    private static InputStream getDefaultPreamble()
         throws IOException
     {
         return LatexSink.class.getResource( "default_preamble.tex" ).openStream();
@@ -1131,7 +1133,7 @@
      *
      * @return String.
      */
-    public static String defaultSinkCommands()
+    protected String defaultSinkCommands()
     {
         String commands = "";
 
@@ -1141,7 +1143,11 @@
         }
         catch ( IOException ioe )
         {
-            // TODO: log
+            // this should not happen
+            getLog().warn( "Could not read default LaTeX commands, the generated LaTeX file
will not compile!" );
+            getLog().debug( ioe );
+
+            return "";
         }
 
         return commands;
@@ -1152,7 +1158,7 @@
      *
      * @return String.
      */
-    public static String defaultPreamble()
+    protected String defaultPreamble()
     {
         String preamble = "";
 
@@ -1162,7 +1168,11 @@
         }
         catch ( IOException ioe )
         {
-            // TODO: log
+            // this should not happen
+            getLog().warn( "Could not read default LaTeX preamble, the generated LaTeX file
will not compile!" );
+            getLog().debug( ioe );
+
+            return "";
         }
 
         return preamble;

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java?rev=628378&r1=628377&r2=628378&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java
Sat Feb 16 13:12:16 2008
@@ -65,9 +65,9 @@
     /** {@inheritDoc} */
     protected String getHeadBlock()
     {
-        return LatexSink.defaultSinkCommands()
+        return ((LatexSink) getSink()).defaultSinkCommands()
             + "\\documentclass[a4paper]{article}"
-            + LatexSink.defaultPreamble()
+            + ((LatexSink) getSink()).defaultPreamble()
             + "\\begin{document}";
     }
 

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java?rev=628378&r1=628377&r2=628378&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
Sat Feb 16 13:12:16 2008
@@ -169,8 +169,7 @@
 
                 if ( StringUtils.isEmpty( macroName ) )
                 {
-                    // TODO use logging?
-                    throw new IllegalArgumentException( "The '" + Attribute.NAME.toString()
+ "' attribute for the '"
+                    throw new MacroExecutionException( "The '" + Attribute.NAME.toString()
+ "' attribute for the '"
                         + MACRO_TAG.toString() + "' tag is required." );
                 }
             }
@@ -191,7 +190,7 @@
 
                     if ( StringUtils.isEmpty( paramName ) || StringUtils.isEmpty( paramValue
) )
                     {
-                        throw new IllegalArgumentException( "'" + Attribute.NAME.toString()
+ "' and '"
+                        throw new MacroExecutionException( "'" + Attribute.NAME.toString()
+ "' and '"
                             + Attribute.VALUE.toString() + "' attributes for the '" + Tag.PARAM.toString()
                             + "' tag are required inside the '" + MACRO_TAG.toString() +
"' tag." );
                     }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java?rev=628378&r1=628377&r2=628378&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
Sat Feb 16 13:12:16 2008
@@ -129,7 +129,14 @@
         }
         else if ( !baseStartTag( parser, sink ) )
         {
-            // TODO: log( "Unrecognized start tag!" );
+            if ( getLog().isWarnEnabled() )
+            {
+                String position = "[" + parser.getLineNumber() + ":"
+                    + parser.getColumnNumber() + "]";
+                String tag = "<" + parser.getName() + ">";
+
+                getLog().warn( "Unrecognized tag: " + tag + " at " + position );
+            }
         }
     }
 
@@ -166,7 +173,7 @@
         }
         else if ( !baseEndTag( parser, sink ) )
         {
-            // TODO: log( "Unrecognized end tag!" );
+            // unrecognized tag is already logged in StartTag
         }
     }
 



Mime
View raw message