Return-Path: Delivered-To: apmail-xml-axis-dev-archive@xml.apache.org Received: (qmail 40784 invoked by uid 500); 25 Nov 2002 15:12:45 -0000 Mailing-List: contact axis-dev-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@xml.apache.org Received: (qmail 40775 invoked by uid 500); 25 Nov 2002 15:12:45 -0000 Delivered-To: apmail-xml-axis-wsif-cvs@apache.org Date: 25 Nov 2002 15:12:45 -0000 Message-ID: <20021125151245.32804.qmail@icarus.apache.org> From: owenb@apache.org To: xml-axis-wsif-cvs@apache.org Subject: cvs commit: xml-axis-wsif/java/src/org/apache/wsif/schema ElementType.java Parser.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N owenb 2002/11/25 07:12:45 Modified: java/src/org/apache/wsif/schema ElementType.java Parser.java Log: Fix to correctly map elements which are based on xsd simple types and are nillable Revision Changes Path 1.4 +11 -0 xml-axis-wsif/java/src/org/apache/wsif/schema/ElementType.java Index: ElementType.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/schema/ElementType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ElementType.java 14 Nov 2002 16:23:13 -0000 1.3 +++ ElementType.java 25 Nov 2002 15:12:45 -0000 1.4 @@ -79,6 +79,7 @@ private QName typeName = null; private QName elementType = null; private List childTypes = new ArrayList(); + private boolean nillable = false; /** * Constructor @@ -88,6 +89,12 @@ elementType = getAttributeQName(el, "type", tns); typeName = getAttributeQName(el, "name", tns); + QName nillableAttr = getAttributeQName(el, "nillable", null); + String stTrue = "true"; + if (nillableAttr != null && stTrue.equals(nillableAttr.getLocalPart())) { + nillable = true; + } + // If the element has no name, we cannot map it. Don't do any more processing // of this type if (typeName == null) return; @@ -131,6 +138,10 @@ */ public QName getElementType() { return elementType; + } + + public boolean isNillable() { + return nillable; } /** 1.5 +39 -1 xml-axis-wsif/java/src/org/apache/wsif/schema/Parser.java Index: Parser.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/schema/Parser.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Parser.java 11 Nov 2002 15:49:41 -0000 1.4 +++ Parser.java 25 Nov 2002 15:12:45 -0000 1.5 @@ -256,13 +256,19 @@ QName baseType = ((ElementType) st).getElementType(); if (baseType != null) { + if (((ElementType) st).isNillable()) { + String wrapperClass = getWrapperClassName(baseType); + if (wrapperClass != null) { + table.put(typeName, wrapperClass); + continue; + } + } String baseClassName = (String) table.get(baseType); if (baseClassName == null && !includeStandardMappings) { baseClassName = (String) standards.get(baseType); - ; } if (baseClassName != null) { table.put(typeName, baseClassName); @@ -627,4 +633,36 @@ } return null; } + + /** + * Elements which are nillable and are based on xsd simple types should map to + * the object wrapper version of the corresponding primitive type. This method + * will return the wrapper class name for a given QName. + */ + private static String getWrapperClassName(QName qn) { + if (qn == null) return null; + String ns = qn.getNamespaceURI(); + if (WSIFConstants.NS_URI_1999_SCHEMA_XSD.equals(ns) + || WSIFConstants.NS_URI_2000_SCHEMA_XSD.equals(ns) + || WSIFConstants.NS_URI_2001_SCHEMA_XSD.equals(ns)) { + String lp = qn.getLocalPart(); + if (lp == null) return null; + if (lp.equals("int")) { + return "java.lang.Integer"; + } else if (lp.equals("long")) { + return "java.lang.Long"; + } else if (lp.equals("float")) { + return "java.lang.Float"; + } else if (lp.equals("short")) { + return "java.lang.Short"; + } else if (lp.equals("double")) { + return "java.lang.Double"; + } else if (lp.equals("boolean")) { + return "java.lang.Boolean"; + } else if (lp.equals("byte")) { + return "java.lang.Byte"; + } + } + return null; + } }