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 2008/03/12 13:58:25 UTC

svn commit: r636307 - /maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java

Author: vsiveton
Date: Wed Mar 12 05:58:22 2008
New Revision: 636307

URL: http://svn.apache.org/viewvc?rev=636307&view=rev
Log:
o formatting

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java?rev=636307&r1=636306&r2=636307&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java Wed Mar 12 05:58:22 2008
@@ -55,35 +55,39 @@
     extends AbstractTextParser
 {
     private static final int EXTENSION_LENGTH = 6;
+
     /**
      * paragraph parser. stateless
      */
     private final ParagraphBlockParser paraParser = new ParagraphBlockParser();
+
     /**
      * section parser. stateless
      */
     private final SectionBlockParser sectionParser = new SectionBlockParser();
+
     /**
      * enumeration parser. stateless
      */
-    private final GenericListBlockParser listParser =
-        new GenericListBlockParser();
+    private final GenericListBlockParser listParser = new GenericListBlockParser();
+
     /**
      * Text parser. stateless
      */
-    private final FormatedTextParser formatTextParser =
-        new FormatedTextParser();
+    private final FormatedTextParser formatTextParser = new FormatedTextParser();
+
     /**
      * text parser. stateless
-     * This only works for xhtml output, but there is no way 
+     * This only works for xhtml output, but there is no way
      * of transforming a wikiWord in another context.
      */
-    private final TextParser textParser = new TextParser( 
-            new XHTMLWikiWordLinkResolver() );
+    private final TextParser textParser = new TextParser( new XHTMLWikiWordLinkResolver() );
+
     /**
      * hruler parser. stateless
      */
     private final HRuleBlockParser hrulerParser = new HRuleBlockParser();
+
     /**
      * table parser
      */
@@ -93,11 +97,11 @@
      * verbatim parser
      */
     private final VerbatimBlockParser verbatimParser = new VerbatimBlockParser();
-    
+
     /**
      * list of parsers to try to apply to the toplevel
      */
-    private final BlockParser [] parsers;
+    private final BlockParser[] parsers;
 
     /**
      * Creates the TWikiParser.
@@ -117,12 +121,7 @@
         formatTextParser.setTextParser( textParser );
         tableParser.setTextParser( formatTextParser );
 
-        parsers = new BlockParser[]{
-            sectionParser,
-            hrulerParser,
-            verbatimParser,
-            paraParser,
-        };
+        parsers = new BlockParser[] { sectionParser, hrulerParser, verbatimParser, paraParser, };
     }
 
     /**
@@ -153,8 +152,7 @@
             }
             if ( !accepted )
             {
-                throw new ParseException( "don't  know how to handle line: "
-                    + source.getLineNumber() + ": " + line );
+                throw new ParseException( "don't  know how to handle line: " + source.getLineNumber() + ": " + line );
             }
         }
 
@@ -179,20 +177,19 @@
         }
         catch ( final Exception e )
         {
-            throw new ParseException( e, src.getName(),
-                                      src.getLineNumber() );
+            throw new ParseException( e, src.getName(), src.getLineNumber() );
         }
 
         sink.head();
-        
-        final String title = getTitle( blocks, src ); 
-        if ( title != null ) 
+
+        final String title = getTitle( blocks, src );
+        if ( title != null )
         {
             sink.title();
             sink.text( title );
             sink.title_();
         }
-        
+
         sink.head_();
         sink.body();
         for ( Iterator it = blocks.iterator(); it.hasNext(); )
@@ -204,52 +201,52 @@
         sink.body_();
     }
 
-    /**  
+    /**
      * Guess a title for the page. It uses the first section that it finds.
-     * If it doesn't find any section tries to get it from 
+     * If it doesn't find any section tries to get it from
      * {@link ByLineReaderSource#getName()}
-     * 
+     *
      * @param blocks blocks to parse
      * @param source source to parse
      * @return a title for a page
      */
-    public final String getTitle( final List blocks, final ByLineSource source ) 
+    public final String getTitle( final List blocks, final ByLineSource source )
     {
         String title = null;
-        
+
         for ( Iterator it = blocks.iterator(); title == null && it.hasNext(); )
         {
             final Block block = (Block) it.next();
-            
-            if ( block instanceof SectionBlock ) 
+
+            if ( block instanceof SectionBlock )
             {
                 final SectionBlock sectionBlock = (SectionBlock) block;
                 title = sectionBlock.getTitle();
             }
         }
-        
-        if ( title == null ) 
+
+        if ( title == null )
         {
             String name = source.getName();
-            if ( name != null ) 
+            if ( name != null )
             {
                 name = name.trim();
-                
+
                 if ( name.length() != 0 )
                 {
-                    if ( name.endsWith( ".twiki" ) ) 
+                    if ( name.endsWith( ".twiki" ) )
                     {
                         title = name.substring( 0, name.length() - EXTENSION_LENGTH );
                     }
-                    else 
+                    else
                     {
                         title = name;
                     }
                 }
             }
-            
+
         }
-        
+
         return title;
     }
 }