[mashup-dev] svn commit r6047 -
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer
svn at wso2.org
svn at wso2.org
Thu Aug 2 05:02:47 PDT 2007
Author: keith
Date: Thu Aug 2 05:02:43 2007
New Revision: 6047
Modified:
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/SchemaGenerator.java
Log:
Adding code comments and renaming private function
Modified: trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/SchemaGenerator.java
==============================================================================
--- trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/SchemaGenerator.java (original)
+++ trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/SchemaGenerator.java Thu Aug 2 05:02:43 2007
@@ -193,7 +193,7 @@
}
if (param.indexOf('|') > 0) {
String[] enums = param.split("|");
- XmlSchemaSimpleType schemaSimpleType = test(name + "enumerationType", enums);
+ XmlSchemaSimpleType schemaSimpleType = handleEnumeration(name + "EnumerationType", enums);
xmlSchema.getItems().add(schemaSimpleType);
xmlSchemaElement.setSchemaTypeName(schemaSimpleType.getQName());
return xmlSchemaElement;
@@ -239,16 +239,27 @@
return schemaTargetNamespace;
}
- private XmlSchemaSimpleType test(String name, String[] enums) {
+ /**
+ * If the inputType annotations match the pattern of enumeration create the appropriate schema element to handle
+ * that.
+ * @param name - The name of the parameter
+ * @param enums - Array of enumeration values
+ * @return XmlSchemaSimpleType - An XmlSchemaSimpleType which has a restriction and the enumaration.
+ */
+ private XmlSchemaSimpleType handleEnumeration(String name, String[] enums) {
XmlSchemaSimpleTypeRestriction simpleTypeRestriction = new XmlSchemaSimpleTypeRestriction();
+ // Set the base type to string. 95% of the time enumerations are strings so use it.
simpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING);
XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema);
simpleType.setName(name);
simpleType.setContent(simpleTypeRestriction);
+ // Create enumeration facets for each value
for (int i=0; i < enums.length; i++) {
String enumeration = enums[i].trim();
+
+ // Filter out unnecessary values.
if ("".equals(enumeration) || "|".equals(enumeration)) {
continue;
}
More information about the Mashup-dev
mailing list