ugo 2003/11/29 07:37:57
Modified: src/blocks/woody/java/org/apache/cocoon/woody/datatype
EnumSelectionList.java
src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl
EnumType.java
Log:
Javadocs.
Revision Changes Path
1.5 +26 -2
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/EnumSelectionList.java
Index: EnumSelectionList.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/EnumSelectionList.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EnumSelectionList.java 17 Nov 2003 16:18:12 -0000 1.4
+++ EnumSelectionList.java 29 Nov 2003 15:37:57 -0000 1.5
@@ -60,7 +60,31 @@
import org.xml.sax.SAXException;
/**
- * Builds a EnumSelectionList.
+ * This type of selection list outputs a list of items
+ * corresponding to the possible instances of an [EMAIL PROTECTED]
org.apache.cocoon.woody.datatype.typeimpl.EnumType}.
+ * <p>Example usage:</p>
+ * <pre>
+ * <wd:selection-list type="enum" class="com.example.Sex"/>
+ * </pre>
+ * <p>Produces the following output:</p>
+ * <pre>
+ * <wi:selection-list>
+ * <wi:item value=""/>
+ * <wi:item value="com.example.Sex.MALE">
+ * <wi:label>
+ * <i18n:text>com.example.Sex.MALE</i18n:text>
+ * </wi:label>
+ * </wi:item>
+ * <wi:item value="com.example.Sex.FEMALE">
+ * <wi:label>
+ * <i18n:text>com.example.Sex.FEMALE</i18n:text>
+ * </wi:label>
+ * </wi:item>
+ * </wi:selection-list>
+ * </pre>
+ * <p>If you don't want an initial null value, add a nullable="false"
+ * attribute to the wd:selection-list element.
+ *
* @version CVS $Id$
*/
public class EnumSelectionList implements SelectionList {
1.5 +12 -9
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/EnumType.java
Index: EnumType.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/EnumType.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EnumType.java 16 Nov 2003 10:56:30 -0000 1.4
+++ EnumType.java 29 Nov 2003 15:37:57 -0000 1.5
@@ -56,6 +56,8 @@
* typesafe enum</a> pattern.
* <p>See the following code for an example:</p>
* <pre>
+ * package com.example;
+ *
* public class Sex {
*
* public static final Sex MALE = new Sex("M");
@@ -63,16 +65,17 @@
* private String code;
*
* private Sex(String code) { this.code = code; }
- *
- * public String toString() {
- * switch(code.charAt(0)) {
- * case 'M' : return this.getClass().getName() + ".MALE";
- * case 'F' : return this.getClass().getName() + ".FEMALE";
- * default : return "unknown"; // Should never happen
- * }
- * }
* }
* </pre>
+ * <p>If your enumerated type does not provide a [EMAIL PROTECTED]
java.lang.Object#toString()}
+ * method, the enum convertor will use the fully qualified class name,
+ * followed by the name of the public static final field referring to
+ * each instance, i.e. "com.example.Sex.MALE", "com.example.Sex.FEMALE"
+ * and so on.</p>
+ * <p>If you provide a toString() method which returns something
+ * different, you should also provide a fromString(String, Locale)
+ * method to convert those strings back to instances.
+ *
* @version CVS $Id$
*/
public class EnumType extends AbstractDatatype {