You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by lt...@apache.org on 2007/09/11 14:47:15 UTC
svn commit: r574578 -
/maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java
Author: ltheussl
Date: Tue Sep 11 05:47:14 2007
New Revision: 574578
URL: http://svn.apache.org/viewvc?rev=574578&view=rev
Log:
Check for valid input format
Modified:
maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java
Modified: maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java?rev=574578&r1=574577&r2=574578&view=diff
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java (original)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java Tue Sep 11 05:47:14 2007
@@ -73,18 +73,26 @@
/** The numbering format. */
private final int format;
- /** Constructor. Initializes count and format.
+ /**
+ * Constructor. Initializes count and format.
+ *
* @param itemFormat The numbering format of this List.
- * Should be one of the formats defined in {@link Sink}.
+ * Should be one of the formats defined in {@link org.apache.maven.doxia.sink.Sink}.
*/
- public NumberedListItem ( int itemFormat )
+ public NumberedListItem( int itemFormat )
{
+ if ( !isValidItemFormat( itemFormat ) )
+ {
+ throw new IllegalArgumentException( "Unknown item format!" );
+ }
+
this.format = itemFormat;
this.count = 0;
}
/**
* Returns the current count, ie the position in the list.
+ *
* @return The current count.
*/
public int count()
@@ -94,6 +102,7 @@
/**
* Returns the numbering format.
+ *
* @return The numbering format.
*/
public int format()
@@ -107,8 +116,9 @@
count++;
}
- /**
+ /**
* Returns the symbol for the current list item.
+ *
* @return The symbol for the current list item.
*/
public String getListItemSymbol()
@@ -145,5 +155,19 @@
return symbol;
}
+ /**
+ * Determines if the given format is one of the formats defined in
+ * {@link org.apache.maven.doxia.sink.Sink}.
+ *
+ * @return True if the format is a valid item format according to the Sink API.
+ */
+ private boolean isValidItemFormat( int itemFormat )
+ {
+ return ( ( itemFormat == Sink.NUMBERING_UPPER_ALPHA )
+ || ( itemFormat == Sink.NUMBERING_LOWER_ALPHA )
+ || ( itemFormat == Sink.NUMBERING_UPPER_ROMAN )
+ || ( itemFormat == Sink.NUMBERING_LOWER_ROMAN )
+ || ( itemFormat == Sink.NUMBERING_DECIMAL ) );
+ }
}