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 lt...@apache.org on 2008/04/08 11:08:06 UTC
svn commit: r645802 -
/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
Author: ltheussl
Date: Tue Apr 8 02:08:05 2008
New Revision: 645802
URL: http://svn.apache.org/viewvc?rev=645802&view=rev
Log:
Throw Exception when no id is set on faq or part. Better Exception messages.
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=645802&r1=645801&r2=645802&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 Tue Apr 8 02:08:05 2008
@@ -114,13 +114,21 @@
currentPart = new Part();
currentPart.setId( parser.getAttributeValue( null, Attribute.ID.toString() ) );
+
+ if ( currentPart.getId() == null )
+ {
+ throw new XmlPullParserException( "id attribute required for <part> at: ("
+ + parser.getLineNumber() + ":" + parser.getColumnNumber() + ")" );
+ }
}
else if ( parser.getName().equals( Tag.TITLE.toString() ) )
{
if ( currentPart == null )
{
- throw new XmlPullParserException( "The currentPart is not set" );
+ throw new XmlPullParserException( "Missing <part> at: ("
+ + parser.getLineNumber() + ":" + parser.getColumnNumber() + ")" );
}
+
try
{
currentPart.setTitle( parser.nextText().trim() );
@@ -135,6 +143,12 @@
currentFaq = new Faq();
currentFaq.setId( parser.getAttributeValue( null, Attribute.ID.toString() ) );
+
+ if ( currentFaq.getId() == null )
+ {
+ throw new XmlPullParserException( "id attribute required for <faq> at: ("
+ + parser.getLineNumber() + ":" + parser.getColumnNumber() + ")" );
+ }
}
if ( parser.getName().equals( QUESTION_TAG.toString() ) )
{
@@ -193,8 +207,10 @@
{
if ( currentPart == null )
{
- throw new XmlPullParserException( "The currentPart is not set" );
+ throw new XmlPullParserException( "Missing <part> at: ("
+ + parser.getLineNumber() + ":" + parser.getColumnNumber() + ")" );
}
+
currentPart.addFaq( currentFaq );
currentFaq = null;
@@ -203,8 +219,10 @@
{
if ( currentFaq == null )
{
- throw new XmlPullParserException( "The currentFaq is not set" );
+ throw new XmlPullParserException( "Missing <faq> at: ("
+ + parser.getLineNumber() + ":" + parser.getColumnNumber() + ")" );
}
+
buffer.append( String.valueOf( LESS_THAN ) ).append( String.valueOf( SLASH ) )
.append( parser.getName() ).append( String.valueOf( GREATER_THAN ) );
@@ -216,7 +234,8 @@
{
if ( currentFaq == null )
{
- throw new XmlPullParserException( "The currentFaq is not set" );
+ throw new XmlPullParserException( "Missing <faq> at: ("
+ + parser.getLineNumber() + ":" + parser.getColumnNumber() + ")" );
}
buffer.append( String.valueOf( LESS_THAN ) ).append( String.valueOf( SLASH ) )
.append( parser.getName() ).append( String.valueOf( GREATER_THAN ) );
@@ -329,14 +348,16 @@
Faq faq = (Faq) faqIterator.next();
sink.numberedListItem();
sink.link( faq.getId() );
+
if ( StringUtils.isNotEmpty( faq.getQuestion() ) )
{
xdocParser.parse( faq.getQuestion(), sink );
}
else
{
- throw new ParseException( "Question is missing for the FAQ '" + faq.getId() + "'" );
+ throw new ParseException( "Missing <question> for FAQ '" + faq.getId() + "'" );
}
+
sink.link_();
sink.numberedListItem_();
}
@@ -371,25 +392,28 @@
sink.definedTerm();
sink.anchor( faq.getId() );
+
if ( StringUtils.isNotEmpty( faq.getQuestion() ) )
{
xdocParser.parse( faq.getQuestion(), sink );
}
else
{
- throw new ParseException( "Question is missing for the FAQ '" + faq.getId() + "'" );
+ throw new ParseException( "Missing <question> for FAQ '" + faq.getId() + "'" );
}
+
sink.anchor_();
sink.definedTerm_();
sink.definition();
+
if ( StringUtils.isNotEmpty( faq.getAnswer() ) )
{
xdocParser.parse( faq.getAnswer(), sink );
}
else
{
- throw new ParseException( "Answer is missing for the FAQ '" + faq.getId() + "'" );
+ throw new ParseException( "Missing <answer> for FAQ '" + faq.getId() + "'" );
}
if ( faqs.isToplink() )