maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r645499 - /maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
Date Mon, 07 Apr 2008 13:15:23 GMT
Author: vsiveton
Date: Mon Apr  7 06:15:22 2008
New Revision: 645499

URL: http://svn.apache.org/viewvc?rev=645499&view=rev
Log:
o prevent NPE

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java

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=645499&r1=645498&r2=645499&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
Mon Apr  7 06:15:22 2008
@@ -117,6 +117,10 @@
         }
         else if ( parser.getName().equals( Tag.TITLE.toString() ) )
         {
+            if ( currentPart == null )
+            {
+                throw new XmlPullParserException( "The currentPart is not set" );
+            }
             try
             {
                 currentPart.setTitle( parser.nextText().trim() );
@@ -187,12 +191,20 @@
         }
         else if ( parser.getName().equals( FAQ_TAG.toString() ) )
         {
+            if ( currentPart == null )
+            {
+                throw new XmlPullParserException( "The currentPart is not set" );
+            }
             currentPart.addFaq( currentFaq );
 
             currentFaq = null;
         }
-        if ( parser.getName().equals( QUESTION_TAG.toString() ) )
+        else if ( parser.getName().equals( QUESTION_TAG.toString() ) )
         {
+            if ( currentFaq == null )
+            {
+                throw new XmlPullParserException( "The currentFaq is not set" );
+            }
             buffer.append( String.valueOf( LESS_THAN ) ).append( String.valueOf( SLASH )
)
                 .append( parser.getName() ).append( String.valueOf( GREATER_THAN ) );
 
@@ -202,6 +214,10 @@
         }
         else if ( parser.getName().equals( ANSWER_TAG.toString() ) )
         {
+            if ( currentFaq == null )
+            {
+                throw new XmlPullParserException( "The currentFaq is not set" );
+            }
             buffer.append( String.valueOf( LESS_THAN ) ).append( String.valueOf( SLASH )
)
                 .append( parser.getName() ).append( String.valueOf( GREATER_THAN ) );
 
@@ -313,7 +329,14 @@
                 Faq faq = (Faq) faqIterator.next();
                 sink.numberedListItem();
                 sink.link( faq.getId() );
-                xdocParser.parse( faq.getQuestion(), sink );
+                if ( StringUtils.isNotEmpty( faq.getQuestion() ) )
+                {
+                    xdocParser.parse( faq.getQuestion(), sink );
+                }
+                else
+                {
+                    throw new ParseException( "Question is missing for the FAQ '" + faq.getId()
+ "'" );
+                }
                 sink.link_();
                 sink.numberedListItem_();
             }
@@ -348,12 +371,26 @@
 
                 sink.definedTerm();
                 sink.anchor( faq.getId() );
-                xdocParser.parse( faq.getQuestion(), sink );
+                if ( StringUtils.isNotEmpty( faq.getQuestion() ) )
+                {
+                    xdocParser.parse( faq.getQuestion(), sink );
+                }
+                else
+                {
+                    throw new ParseException( "Question is missing for the FAQ '" + faq.getId()
+ "'" );
+                }
                 sink.anchor_();
                 sink.definedTerm_();
 
                 sink.definition();
-                xdocParser.parse( faq.getAnswer(), sink );
+                if ( StringUtils.isNotEmpty( faq.getAnswer() ) )
+                {
+                    xdocParser.parse( faq.getAnswer(), sink );
+                }
+                else
+                {
+                    throw new ParseException( "Answer is missing for the FAQ '" + faq.getId()
+ "'" );
+                }
 
                 if ( faqs.isToplink() )
                 {



Mime
View raw message