You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ug...@apache.org on 2003/11/17 17:18:13 UTC
cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype EnumSelectionListBuilder.java EnumSelectionList.java
ugo 2003/11/17 08:18:12
Modified: src/blocks/woody/java/org/apache/cocoon/woody/datatype
EnumSelectionListBuilder.java
EnumSelectionList.java
Log:
Added attribute "nullable" to <wd:selection-list type="enum">.
Revision Changes Path
1.2 +3 -2 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/EnumSelectionListBuilder.java
Index: EnumSelectionListBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/EnumSelectionListBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EnumSelectionListBuilder.java 7 Nov 2003 22:04:38 -0000 1.1
+++ EnumSelectionListBuilder.java 17 Nov 2003 16:18:12 -0000 1.2
@@ -65,7 +65,8 @@
public SelectionList build(Element selectionListElement, Datatype datatype)
throws Exception {
String className = DomHelper.getAttribute(selectionListElement, "class");
- return new EnumSelectionList(className, datatype);
+ boolean nullable = DomHelper.getAttributeAsBoolean(selectionListElement, "nullable", true);
+ return new EnumSelectionList(className, datatype, nullable);
}
}
1.4 +12 -4 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EnumSelectionList.java 15 Nov 2003 04:21:28 -0000 1.3
+++ EnumSelectionList.java 17 Nov 2003 16:18:12 -0000 1.4
@@ -70,14 +70,15 @@
private Datatype datatype;
private Class clazz;
+ private boolean nullable;
/**
* @param className
* @param datatype
*/
- public EnumSelectionList(String className, Datatype datatype) throws ClassNotFoundException {
+ public EnumSelectionList(String className, Datatype datatype, boolean nullable) throws ClassNotFoundException {
this.datatype = datatype;
- // FIXME: use the correct class loader.
+ this.nullable = nullable;
this.clazz = Class.forName(className);
}
@@ -96,8 +97,15 @@
Locale locale)
throws SAXException {
try {
- Field fields[] = clazz.getDeclaredFields();
contentHandler.startElement(Constants.WI_NS, SELECTION_LIST_EL, Constants.WI_PREFIX_COLON + SELECTION_LIST_EL, Constants.EMPTY_ATTRS);
+ Field fields[] = clazz.getDeclaredFields();
+ // Create void element
+ if (nullable) {
+ AttributesImpl voidAttrs = new AttributesImpl();
+ voidAttrs.addCDATAAttribute("value", "");
+ contentHandler.startElement(Constants.WI_NS, ITEM_EL, Constants.WI_PREFIX_COLON + ITEM_EL, voidAttrs);
+ contentHandler.endElement(Constants.WI_NS, ITEM_EL, Constants.WI_PREFIX_COLON + ITEM_EL);
+ }
for (int i = 0 ; i < fields.length ; ++i) {
int mods = fields[i].getModifiers();
if (Modifier.isPublic(mods) && Modifier.isStatic(mods)