From e77ce2341ff1050faa41139dbd98b9c9f24811d5 Mon Sep 17 00:00:00 2001 From: heshan Date: Sat, 5 Jun 2010 04:05:24 +0000 Subject: [PATCH] Refactored code. git-svn-id: http://svn.wso2.org/repos/wso2/trunk/wsf@67627 a5903396-d722-0410-b921-86c7d4935375 --- .../schemagenarator/SchemaGenerator.java | 20 ++++++++----------- .../deployer/schemagenarator/TypeTable.java | 3 +-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SchemaGenerator.java b/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SchemaGenerator.java index 890c46e7b..7ff64724d 100644 --- a/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SchemaGenerator.java +++ b/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SchemaGenerator.java @@ -30,7 +30,6 @@ import org.apache.ws.commons.schema.utils.NamespaceMap; import javax.xml.namespace.QName; -import java.util.Iterator; /** * Schema generation class. @@ -47,8 +46,6 @@ public class SchemaGenerator { private TypeTable typeTable; - private String DEFAULT_SCHEMA_NAMESPACE_PREFIX = "xs"; - private String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; private String RESPONSE = "Response"; public NamespaceMap getNamespaceMap() { @@ -65,8 +62,9 @@ public SchemaGenerator(String schemaTargetNamespace, TypeTable typeTable) { xmlSchema.setAttributeFormDefault(new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED)); xmlSchema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED)); - nameSpacesMap.put(DEFAULT_SCHEMA_NAMESPACE_PREFIX, - URI_2001_SCHEMA_XSD); + String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; + String DEFAULT_SCHEMA_NAMESPACE_PREFIX = "xs"; + nameSpacesMap.put(DEFAULT_SCHEMA_NAMESPACE_PREFIX, URI_2001_SCHEMA_XSD); nameSpacesMap.put(prefix, this.schemaTargetNamespace); xmlSchema.setNamespaceContext(nameSpacesMap); } @@ -129,17 +127,15 @@ private XmlSchemaComplexType createComplexType(ComplexType complexType, String e xmlSchema.getItems().add(xmlSchemaComplexType); XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence(); - Iterator iterator = complexType.getMembers().iterator(); - while (iterator.hasNext()) { - Object object = iterator.next(); + for (Type type : complexType.getMembers()) { XmlSchemaElement xmlSchemaElement; - if (object instanceof SimpleType) { - SimpleType simpleType = (SimpleType) object; + if (type instanceof SimpleType) { + SimpleType simpleType = (SimpleType) type; if ((xmlSchemaElement = createXMLSchemaElement(simpleType.getName(), simpleType.getType())) != null) { xmlSchemaSequence.getItems().add(xmlSchemaElement); } - } else if (object instanceof ComplexType) { - ComplexType complexTypeParam = (ComplexType) object; + } else if (type instanceof ComplexType) { + ComplexType complexTypeParam = (ComplexType) type; if ((xmlSchemaElement = handleComplexType(complexTypeParam, elementName + complexTypeParam.getName() + TYPE)) != null) { xmlSchemaElement.setName(complexTypeParam.getName()); diff --git a/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TypeTable.java b/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TypeTable.java index 538d96772..c10a1a1ba 100644 --- a/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TypeTable.java +++ b/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TypeTable.java @@ -19,8 +19,7 @@ import javax.xml.namespace.QName; import java.util.HashMap; -public abstract class - TypeTable { +public abstract class TypeTable { protected HashMap simpleTypetoxsd; protected HashMap complexTypeMap;