You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by pr...@apache.org on 2007/12/01 15:43:54 UTC
svn commit: r600141 [3/10] - in
/webservices/axis2/branches/java/jaxws21/modules: adb-codegen/
adb-codegen/src/org/apache/axis2/schema/
adb-codegen/src/org/apache/axis2/schema/template/
adb-codegen/src/org/apache/axis2/schema/util/ adb-codegen/src/org/...
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java Sat Dec 1 06:43:28 2007
@@ -47,6 +47,13 @@
* @param primitiveclassName
*/
public static String getWrapper(String primitiveclassName){
- return (String) primitiveTypeWrappersMap.get(primitiveclassName);
+ String returnClassName = null;
+ if (primitiveclassName.trim().endsWith("[]")) {
+ String className = primitiveclassName.substring(0, primitiveclassName.length() - 2);
+ returnClassName = primitiveTypeWrappersMap.get(className) + "[]";
+ } else {
+ returnClassName = (String) primitiveTypeWrappersMap.get(primitiveclassName);
+ }
+ return returnClassName;
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java Sat Dec 1 06:43:28 2007
@@ -337,6 +337,9 @@
new QName(qName.getNamespaceURI(), className)
, modelHeader);
+ /////////////////////////////////////////////////////
+ // System.out.println(DOM2Writer.nodeToString(modelSource.getFirstChild()));
+ /////////////////////////////////////////////////////
}
@@ -427,6 +430,14 @@
XSLTUtils.addAttribute(model, "nillable", "yes", rootElt);
}
+ if (metainf.isParticleClass()) {
+ XSLTUtils.addAttribute(model, "particleClass", "yes", rootElt);
+ }
+
+ if (metainf.isHasParticleType()){
+ XSLTUtils.addAttribute(model, "hasParticleType", "yes", rootElt);
+ }
+
//populate all the information
populateInfo(metainf, model, rootElt, propertyNames, typeMap, false);
@@ -549,7 +560,7 @@
name = qName[i];
String xmlName = makeUniqueCStructName(new ArrayList(), name.getLocalPart());
- XSLTUtils.addAttribute(model, "name", xmlName, property);
+ XSLTUtils.addAttribute(model, "name", name.getLocalPart(), property);
XSLTUtils.addAttribute(model, "originalName", name.getLocalPart(), property);
@@ -581,6 +592,15 @@
//add an attribute that says the type is default
if (isDefault(CClassNameForElement)) {
XSLTUtils.addAttribute(model, "default", "yes", property);
+ }
+
+ // add the default value
+ if (metainf.isDefaultValueAvailable(name)){
+ QName schemaQName = metainf.getSchemaQNameForQName(name);
+ if (baseTypeMap.containsKey(schemaQName)){
+ XSLTUtils.addAttribute(model, "defaultValue",
+ metainf.getDefaultValueForQName(name), property);
+ }
}
if (typeMap.containsKey(metainf.getSchemaQNameForQName(name))) {
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Sat Dec 1 06:43:28 2007
@@ -44,8 +44,6 @@
import java.io.*;
import java.util.*;
-import com.ibm.wsdl.util.xml.DOM2Writer;
-
/**
* Java Bean writer for the schema compiler.
*/
@@ -69,6 +67,8 @@
private boolean writeClasses = false;
+ private boolean isUseWrapperClasses = false;
+
private String packageName = null;
private File rootDir;
@@ -149,6 +149,8 @@
initWithFile(options.getOutputLocation());
packageName = options.getPackageName();
writeClasses = options.isWriteOutput();
+ isUseWrapperClasses = options.isUseWrapperClasses();
+
if (!writeClasses) {
wrapClasses = false;
} else {
@@ -491,6 +493,7 @@
XSLTUtils.addAttribute(model, "originalName", originalName, rootElt);
XSLTUtils.addAttribute(model, "package", packageName, rootElt);
XSLTUtils.addAttribute(model, "nsuri", qName.getNamespaceURI(), rootElt);
+ XSLTUtils.addAttribute(model, "isUseWrapperClasses", isUseWrapperClasses? "yes" : "false", rootElt);
XSLTUtils.addAttribute(model, "nsprefix", isSuppressPrefixesMode ? "" : getPrefixForURI(qName
.getNamespaceURI(), qName.getPrefix()), rootElt);
@@ -730,9 +733,18 @@
//XSLTUtils.addAttribute(model, "restricted", "yes", property);
}
+ long minOccurs = metainf.getMinOccurs(name);
+ if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)
+ && isUseWrapperClasses && ((minOccurs == 0) || metainf.isNillable(name))) {
+ // if this is an primitive class and user wants to use the
+ // wrapper type we change the type to wrapper type.
+ javaClassNameForElement = PrimitiveTypeWrapper.getWrapper(javaClassNameForElement);
+ }
+
XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property);
if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)) {
+
XSLTUtils.addAttribute(model, "primitive", "yes", property);
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/sub-build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/sub-build.xml?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/sub-build.xml (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/sub-build.xml Sat Dec 1 06:43:28 2007
@@ -386,6 +386,14 @@
<arg file="${testsuite.source.dir}/default_value.xsd"/>
<arg file="${schema.generated.src.dir}"/>
</java>
+ <echo>Compiling complexExtension.xsd</echo>
+ <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
+ <jvmarg line="${maven.junit.jvmargs}"/>
+ <classpath refid="maven.dependency.classpath"/>
+ <classpath location="${compiled.classes.dir}"/>
+ <arg file="${testsuite.source.dir}/complexExtension.xsd"/>
+ <arg file="${schema.generated.src.dir}"/>
+ </java>
</target>
</project>
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/anytype.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/anytype.xsd?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/anytype.xsd (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/anytype.xsd Sat Dec 1 06:43:28 2007
@@ -1,6 +1,7 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
- targetNamespace="http://www.w3.org/2005/05/xmlmime">
+ targetNamespace="http://adb.test/anyType"
+ xmlns:tns="http://adb.test/anyType"
+ elementFormDefault="qualified">
<xs:element name="TestAnyTypeElement1" type="xs:anyType"/>
<xs:element name="TestAnyTypeElement2" type="xs:anyType" nillable="true"/>
<xs:element name="TestAnyTypeElement3">
@@ -59,5 +60,41 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+ <xs:complexType name="TestComplexParent">
+ <xs:sequence>
+ <xs:element name="param1" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="TestComplexChild">
+ <xs:complexContent>
+ <xs:extension base="tns:TestComplexParent">
+ <xs:sequence>
+ <xs:element name="param2" type="xs:int"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:simpleType name="TestSimpleType">
+ <xs:restriction base="xs:string">
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="DynamicProperty">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="val" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="TestElement">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param1" type="tns:DynamicProperty" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+
</xs:schema>
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/element_references.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/element_references.xsd?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/element_references.xsd (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/element_references.xsd Sat Dec 1 06:43:28 2007
@@ -29,7 +29,6 @@
</sequence>
</complexType>
</element>
-
<element name="checkEligibility2">
<complexType>
<sequence>
@@ -45,6 +44,22 @@
<element minOccurs="0" name="expirationDate" type="string"/>
<element minOccurs="0" name="yearOfRedemption" type="int"/>
<element minOccurs="0" name="clientId" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- circular element references -->
+ <element name="Element1" type="tns:ComplexType1"/>
+ <complexType name="ComplexType1">
+ <sequence>
+ <element ref="tns:Element1" minOccurs="0"/>
+ </sequence>
+ </complexType>
+ <element name="Element2">
+ <complexType>
+ <sequence>
+ <element name="param1" type="string"/>
+ <element ref="tns:Element2" minOccurs="0"/>
</sequence>
</complexType>
</element>
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/extensions.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/extensions.xsd?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/extensions.xsd (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test-resources/testsuite/extensions.xsd Sat Dec 1 06:43:28 2007
@@ -84,5 +84,6 @@
<xs:element minOccurs="0" name="SORT_DESCENDING" type="xs:int"/>
</xs:sequence>
</xs:complexType>
+
</schema>
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java Sat Dec 1 06:43:28 2007
@@ -16,7 +16,7 @@
package org.apache.axis2.schema.anytype;
import junit.framework.TestCase;
-import org.w3.www._2005._05.xmlmime.*;
+import test.adb.anytype.*;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.util.StAXUtils;
@@ -28,6 +28,7 @@
import java.io.ByteArrayInputStream;
+
public class AnyTypeTest extends TestCase {
public void testAnyTypeElement1() {
@@ -354,6 +355,43 @@
}
}
+ public void testAnyTypeElement61(){
+ TestAnyTypeElement6 testAnyTypeElement6 = new TestAnyTypeElement6();
+
+ TestComplexParent[] testComplexParents = new TestComplexParent[2];
+ testComplexParents[0] = new TestComplexParent();
+ testComplexParents[0].setParam1("test param1");
+
+ TestComplexChild testComplexChild = new TestComplexChild();
+ testComplexChild.setParam1("test param1");
+ testComplexChild.setParam2(3);
+ testComplexParents[1] = testComplexChild;
+
+ testAnyTypeElement6.setParam1(testComplexParents);
+
+ try {
+ OMElement omElement = testAnyTypeElement6.getOMElement(
+ TestAnyTypeElement6.MY_QNAME,OMAbstractFactory.getOMFactory());
+ String omElementString = omElement.toStringWithConsume();
+ System.out.println("OM Element String ==> " + omElementString);
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(
+ new ByteArrayInputStream(omElementString.getBytes()));
+ TestAnyTypeElement6 result = TestAnyTypeElement6.Factory.parse(xmlReader);
+ TestComplexParent resultParent = (TestComplexParent) result.getParam1()[0];
+ assertEquals(resultParent.getParam1(),"test param1");
+ TestComplexChild resultChild = (TestComplexChild) result.getParam1()[1];
+ assertEquals(resultChild.getParam1(), "test param1");
+ assertEquals(resultChild.getParam2(), 3);
+ } catch (ADBException e) {
+ fail();
+ } catch (XMLStreamException e) {
+ fail();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
public void testAnyTypeElement7() {
TestAnyTypeElement7 testAnyTypeElement;
@@ -394,6 +432,32 @@
}
}
+ public void testAnyTypeElement71(){
+ TestAnyTypeElement7 testAnyTypeElement7 = new TestAnyTypeElement7();
+ TestComplexParent testComplexParent = new TestComplexParent();
+ testComplexParent.setParam1("test param1");
+ testAnyTypeElement7.setParam1(testComplexParent);
+
+ try {
+ OMElement omElement = testAnyTypeElement7.getOMElement(
+ TestAnyTypeElement7.MY_QNAME,OMAbstractFactory.getOMFactory());
+ String omElementString = omElement.toStringWithConsume();
+ System.out.println("OM Element ==> " + omElementString);
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(
+ new ByteArrayInputStream(omElementString.getBytes()));
+ TestAnyTypeElement7 result = TestAnyTypeElement7.Factory.parse(xmlReader);
+ TestComplexParent resultParent = (TestComplexParent) result.getParam1();
+ assertEquals(resultParent.getParam1(),"test param1");
+
+ } catch (ADBException e) {
+ fail();
+ } catch (XMLStreamException e) {
+ fail();
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
public void testAnyTypeElement8() {
TestAnyTypeElement8 testAnyTypeElement;
@@ -547,6 +611,56 @@
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
TestAnyTypeElement1 result = TestAnyTypeElement1.Factory.parse(xmlReader);
assertEquals(result.getTestAnyTypeElement1(),new QName("http://wso2.org","testElement"));
+ } catch (ADBException e) {
+ fail();
+ } catch (XMLStreamException e) {
+ fail();
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testTestElement(){
+ TestElement testElement = new TestElement();
+
+ DynamicProperty[] dynamicProperties = new DynamicProperty[3];
+ TestComplexParent testComplexParent = null;
+
+ dynamicProperties[0] = new DynamicProperty();
+ dynamicProperties[0].setName("test name");
+ dynamicProperties[0].setVal(new Integer(5));
+
+ dynamicProperties[1] = new DynamicProperty();
+ dynamicProperties[1].setName("test name");
+ testComplexParent = new TestComplexParent();
+ testComplexParent.setParam1("test complext type");
+ dynamicProperties[1].setVal(testComplexParent);
+
+ TestSimpleType testSimpleType = new TestSimpleType();
+ testSimpleType.setTestSimpleType("test simple string");
+ dynamicProperties[2] = new DynamicProperty();
+ dynamicProperties[2].setName("test name");
+ dynamicProperties[2].setVal(testSimpleType);
+
+
+ testElement.setParam1(dynamicProperties);
+
+ try {
+ OMElement omElement = testElement.getOMElement(
+ TestElement.MY_QNAME,OMAbstractFactory.getOMFactory());
+ String omElementString = omElement.toStringWithConsume();
+ System.out.println("OM String ==> " + omElementString);
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(
+ new ByteArrayInputStream(omElementString.getBytes()));
+ TestElement result = TestElement.Factory.parse(xmlReader);
+ DynamicProperty[] resultProperties = result.getParam1();
+ assertEquals(resultProperties[0].getName(), "test name");
+ assertEquals(resultProperties[0].getVal(), new Integer(5));
+ assertEquals(resultProperties[1].getName(), "test name");
+ assertEquals(((TestComplexParent)resultProperties[1].getVal()).getParam1(), "test complext type");
+ assertEquals(resultProperties[2].getName(), "test name");
+ assertEquals(((TestSimpleType)resultProperties[2].getVal()).getTestSimpleType(),"test simple string");
+
} catch (ADBException e) {
fail();
} catch (XMLStreamException e) {
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java Sat Dec 1 06:43:28 2007
@@ -30,9 +30,12 @@
"2002-10-10T07:00:00Z"
};
private String xmlString[] = {
- "<dateTimeParam xmlns=\"http://soapinterop.org/xsd\">"+values[0]+"</dateTimeParam>",
- "<dateTimeParam xmlns=\"http://soapinterop.org/xsd\">"+values[1]+"</dateTimeParam>",
- "<dateTimeParam xmlns=\"http://soapinterop.org/xsd\">"+values[2]+"</dateTimeParam>"
+ "<dateTimeParam xmlns=\"http://soapinterop.org/xsd\">"+
+ ConverterUtil.convertToString(ConverterUtil.convertToDateTime(values[0])) +"</dateTimeParam>",
+ "<dateTimeParam xmlns=\"http://soapinterop.org/xsd\">"+
+ ConverterUtil.convertToString(ConverterUtil.convertToDateTime(values[1]))+"</dateTimeParam>",
+ "<dateTimeParam xmlns=\"http://soapinterop.org/xsd\">"+
+ ConverterUtil.convertToString(ConverterUtil.convertToDateTime(values[2]))+"</dateTimeParam>"
};
// force others to implement this method
public void testPopulate() throws Exception {
@@ -42,7 +45,7 @@
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
for (int i = 0; i < values.length; i++) {
calendar = ConverterUtil.convertToDateTime(values[i]);
- checkValue(xmlString[i],simpleDateFormat.format(calendar.getTime()));
+ checkValue(xmlString[i],ConverterUtil.convertToString(calendar));
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java Sat Dec 1 06:43:28 2007
@@ -18,15 +18,15 @@
*/
package org.apache.axis2.schema.references;
-import com.americanexpress.www.wsdl.ctn.utilities.atb.AtbRequestCheckEligibility_type0;
-import com.americanexpress.www.wsdl.ctn.utilities.atb.CheckEligibility1;
-import com.americanexpress.www.wsdl.ctn.utilities.atb.CheckEligibility2;
+import com.americanexpress.www.wsdl.ctn.utilities.atb.*;
import junit.framework.TestCase;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.databinding.ADBException;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
import java.io.ByteArrayInputStream;
@@ -98,4 +98,84 @@
fail();
}
}
+
+ public void testElement11(){
+
+ Element1 element1 = new Element1();
+ ComplexType1 complexType1 = new ComplexType1();
+ element1.setElement1(complexType1);
+
+ try {
+ OMElement omElement = element1.getOMElement(Element1.MY_QNAME,OMAbstractFactory.getOMFactory());
+ String omElementString = omElement.toStringWithConsume();
+ System.out.println("OM String ==> " + omElementString);
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ Element1 result = Element1.Factory.parse(xmlReader);
+ assertNotNull(result);
+ } catch (ADBException e) {
+ fail();
+ } catch (XMLStreamException e) {
+ fail();
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testElement12(){
+
+ Element1 element1 = new Element1();
+ ComplexType1 complexType1 = new ComplexType1();
+ element1.setElement1(complexType1);
+ ComplexType1 complexType2 = new ComplexType1();
+ complexType1.setElement1(complexType2);
+ ComplexType1 complexType3 = new ComplexType1();
+ complexType2.setElement1(complexType3);
+
+
+ try {
+ OMElement omElement = element1.getOMElement(Element1.MY_QNAME,OMAbstractFactory.getOMFactory());
+ String omElementString = omElement.toStringWithConsume();
+ System.out.println("OM String ==> " + omElementString);
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ Element1 result = Element1.Factory.parse(xmlReader);
+ assertNotNull(result);
+ assertNotNull(result.getElement1());
+ assertNotNull(result.getElement1().getElement1());
+ } catch (ADBException e) {
+ fail();
+ } catch (XMLStreamException e) {
+ fail();
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testElement21(){
+ Element2 element2 = new Element2();
+ Element2_type0 element2_type0 = new Element2_type0();
+ element2.setElement2(element2_type0);
+ element2_type0.setParam1("test string1");
+
+ Element2_type0 element2_type1 = new Element2_type0();
+ element2_type1.setParam1("test string2");
+ element2_type0.setElement2(element2_type1);
+
+ try {
+ OMElement omElement = element2.getOMElement(Element2.MY_QNAME,OMAbstractFactory.getOMFactory());
+ String omElmentString = omElement.toStringWithConsume();
+ System.out.println("OM element ==>" + omElmentString);
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElmentString.getBytes()));
+ Element2 result = Element2.Factory.parse(xmlReader);
+ assertEquals(result.getElement2().getParam1(),"test string1");
+ assertEquals(result.getElement2().getElement2().getParam1(), "test string2");
+ } catch (ADBException e) {
+ fail();
+ } catch (XMLStreamException e) {
+ fail();
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBBean.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBBean.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBBean.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBBean.java Sat Dec 1 06:43:28 2007
@@ -18,6 +18,9 @@
*/
package org.apache.axis2.databinding;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter;
+
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamException;
@@ -36,6 +39,18 @@
* @return Returns a pull parser for this ADBBean.
*/
public XMLStreamReader getPullParser(QName adbBeanQName) throws XMLStreamException;
+
+
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter)
+ throws XMLStreamException, ADBException;
+
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter,
+ boolean serializeType)
+ throws XMLStreamException, ADBException;
/**
* There will be a self factory in every generated data bound class XXX:
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java Sat Dec 1 06:43:28 2007
@@ -19,7 +19,10 @@
package org.apache.axis2.databinding;
import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.ds.ByteArrayDataSource;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axis2.databinding.utils.writer.OMElementStreamWriter;
import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter;
@@ -30,12 +33,20 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.util.HashMap;
-public abstract class ADBDataSource implements OMDataSource {
+public abstract class ADBDataSource implements OMDataSourceExt {
protected QName parentQName;
private ADBBean bean;
+
+ HashMap map = null; // Map of properties
/**
* Constructor taking in an ADBBean
@@ -67,7 +78,9 @@
* @see OMDataSource#serialize(java.io.Writer, org.apache.axiom.om.OMOutputFormat)
*/
public void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException {
- serialize(StAXUtils.createXMLStreamWriter(writer));
+ XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
+ serialize(xmlStreamWriter);
+ xmlStreamWriter.flush();
}
/**
@@ -80,6 +93,7 @@
public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException{
MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = new MTOMAwareXMLSerializer(xmlWriter);
serialize(mtomAwareXMLStreamWriter);
+ mtomAwareXMLStreamWriter.flush();
}
public abstract void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException;
@@ -97,4 +111,93 @@
return mtomAwareOMBuilder.getOMElement().getXMLStreamReader();
}
+ /**
+ * Returns the backing Object.
+ * @return Object
+ */
+ public Object getObject() {
+ return bean;
+ }
+
+ /**
+ * Returns true if reading the backing object is destructive.
+ * An example of an object with a destructive read is an InputSteam.
+ * The owning OMSourcedElement uses this information to detemine if OM tree
+ * expansion is needed when reading the OMDataSourceExt.
+ * @return boolean
+ */
+ public boolean isDestructiveRead() {
+ return false;
+ }
+
+ /**
+ * Returns true if writing the backing object is destructive.
+ * An example of an object with a destructive write is an InputStream.
+ * The owning OMSourcedElement uses this information to detemine if OM tree
+ * expansion is needed when writing the OMDataSourceExt.
+ * @return boolean
+ */
+ public boolean isDestructiveWrite() {
+ return false;
+ }
+
+ /**
+ * Returns a InputStream representing the xml data
+ * @param encoding String encoding of InputStream
+ * @return InputStream
+ */
+ public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException {
+ return new ByteArrayInputStream(getXMLBytes(encoding));
+ }
+
+ /**
+ * Returns a byte[] representing the xml data
+ * @param encoding String encoding of InputStream
+ * @return byte[]
+ * @see getXMLInputStream
+ */
+ public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ OMOutputFormat format = new OMOutputFormat();
+ format.setCharSetEncoding(encoding);
+ try {
+ serialize(baos, format);
+ } catch (XMLStreamException e) {
+ new OMException(e);
+ }
+ return baos.toByteArray();
+ }
+
+ /**
+ * Close the DataSource and free its resources.
+ */
+ public void close() {
+ parentQName = null;
+ bean = null;
+ }
+
+ public OMDataSourceExt copy() {
+ return null;
+ }
+
+ public Object getProperty(String key) {
+ if (map == null) {
+ return null;
+ }
+ return map.get(key);
+ }
+
+ public Object setProperty(String key, Object value) {
+ if (map == null) {
+ map = new HashMap();
+ }
+ return map.put(key, value);
+ }
+
+ public boolean hasProperty(String key) {
+ if (map == null) {
+ return false;
+ }
+ return map.containsKey(key);
+ }
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java Sat Dec 1 06:43:28 2007
@@ -19,6 +19,8 @@
package org.apache.axis2.databinding;
import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.util.StAXUtils;
@@ -26,16 +28,24 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.HashMap;
-public abstract class ADBHelperDataSource implements OMDataSource {
+public abstract class ADBHelperDataSource implements OMDataSourceExt {
protected QName parentQName;
protected Object bean;
protected String helperClassName;
+
+ HashMap map = null; // Map of properties
/**
* Constructor taking in an ADBBean
@@ -57,7 +67,9 @@
* @see OMDataSource#serialize(java.io.OutputStream, org.apache.axiom.om.OMOutputFormat)
*/
public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
- serialize(StAXUtils.createXMLStreamWriter(output));
+ XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
+ serialize(xmlStreamWriter);
+ xmlStreamWriter.flush();
}
/**
@@ -67,7 +79,9 @@
* @see OMDataSource#serialize(java.io.Writer, org.apache.axiom.om.OMOutputFormat)
*/
public void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException {
- serialize(StAXUtils.createXMLStreamWriter(writer));
+ XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
+ serialize(xmlStreamWriter);
+ xmlStreamWriter.flush();
}
/**
@@ -104,4 +118,93 @@
}
+ /**
+ * Returns the backing Object.
+ * @return Object
+ */
+ public Object getObject() {
+ return bean;
+ }
+
+ /**
+ * Returns true if reading the backing object is destructive.
+ * An example of an object with a destructive read is an InputSteam.
+ * The owning OMSourcedElement uses this information to detemine if OM tree
+ * expansion is needed when reading the OMDataSourceExt.
+ * @return boolean
+ */
+ public boolean isDestructiveRead() {
+ return false;
+ }
+
+ /**
+ * Returns true if writing the backing object is destructive.
+ * An example of an object with a destructive write is an InputStream.
+ * The owning OMSourcedElement uses this information to detemine if OM tree
+ * expansion is needed when writing the OMDataSourceExt.
+ * @return boolean
+ */
+ public boolean isDestructiveWrite() {
+ return false;
+ }
+
+ /**
+ * Returns a InputStream representing the xml data
+ * @param encoding String encoding of InputStream
+ * @return InputStream
+ */
+ public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException {
+ return new ByteArrayInputStream(getXMLBytes(encoding));
+ }
+
+ /**
+ * Returns a byte[] representing the xml data
+ * @param encoding String encoding of InputStream
+ * @return byte[]
+ * @see getXMLInputStream
+ */
+ public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ OMOutputFormat format = new OMOutputFormat();
+ format.setCharSetEncoding(encoding);
+ try {
+ serialize(baos, format);
+ } catch (XMLStreamException e) {
+ new OMException(e);
+ }
+ return baos.toByteArray();
+ }
+
+ /**
+ * Close the DataSource and free its resources.
+ */
+ public void close() {
+ parentQName = null;
+ bean = null;
+ }
+
+ public OMDataSourceExt copy() {
+ return null;
+ }
+
+ public Object getProperty(String key) {
+ if (map == null) {
+ return null;
+ }
+ return map.get(key);
+ }
+
+ public Object setProperty(String key, Object value) {
+ if (map == null) {
+ map = new HashMap();
+ }
+ return map.put(key, value);
+ }
+
+ public boolean hasProperty(String key) {
+ if (map == null) {
+ return false;
+ }
+ return map.containsKey(key);
+ }
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java Sat Dec 1 06:43:28 2007
@@ -23,10 +23,13 @@
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.om.OMFactory;
import org.apache.axis2.util.StreamWrapper;
+import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
/** Builds a SOAPEnvelope around an ADB pull parser */
public class ADBSOAPModelBuilder extends StAXSOAPModelBuilder {
@@ -65,6 +68,21 @@
new StreamWrapper(new org.apache.axis2.databinding.utils.reader.
ADBXMLStreamReaderImpl(qName, elementList.toArray(), null));
}
+
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter)
+ throws XMLStreamException, ADBException {
+ serialize(parentQName,factory,xmlWriter,false);
+ }
+
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter,
+ boolean serializeType)
+ throws XMLStreamException, ADBException {
+ throw new UnsupportedOperationException("Un implemented method");
+ }
}
protected void identifySOAPVersion(String soapVersionURIFromTransport) {
@@ -87,6 +105,21 @@
elementList.toArray(),
null);
}
+
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter)
+ throws XMLStreamException, ADBException {
+ serialize(parentQName,factory,xmlWriter,false);
+ }
+
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter,
+ boolean serializeType)
+ throws XMLStreamException, ADBException {
+ throw new UnsupportedOperationException("Un implemented method");
+ }
}
public static class Header
@@ -97,6 +130,20 @@
elementList.toArray(),
null);
}
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter)
+ throws XMLStreamException, ADBException {
+ serialize(parentQName,factory,xmlWriter,false);
+ }
+
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter,
+ boolean serializeType)
+ throws XMLStreamException, ADBException {
+ throw new UnsupportedOperationException("Un implemented method");
+ }
}
public static class Child
@@ -109,6 +156,20 @@
public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) {
return parser;
+ }
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter)
+ throws XMLStreamException, ADBException {
+ serialize(parentQName,factory,xmlWriter,false);
+ }
+
+ public void serialize(final QName parentQName,
+ final OMFactory factory,
+ MTOMAwareXMLStreamWriter xmlWriter,
+ boolean serializeType)
+ throws XMLStreamException, ADBException {
+ throw new UnsupportedOperationException("Un implemented method");
}
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java Sat Dec 1 06:43:28 2007
@@ -73,6 +73,7 @@
public static Object getSimpleTypeObject(Class parameter, OMElement value) {
String name = parameter.getName();
String text = value.getText();
+
if(name.equals(STRING)) {
return text;
} else if (text == null || text.length() == 0) {
@@ -80,7 +81,7 @@
} else if (name.equals(INT)) {
return new Integer(text);
} else if (name.equals(BOOLEAN)) {
- return Boolean.valueOf(text);
+ return new Boolean(ConverterUtil.convertToBoolean(text));
} else if (name.equals(BYTE)) {
return new Byte(text);
} else if (name.equals(DOUBLE)) {
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/types/Name.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/types/Name.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/types/Name.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/types/Name.java Sat Dec 1 06:43:28 2007
@@ -48,7 +48,7 @@
catch (IllegalArgumentException e) {
// recast normalizedString exception as token exception
throw new IllegalArgumentException(
- //Messages.getMessage("badNameType00") +
+ " invalid value for name " +
"data=[" + stValue + "]");
}
}
@@ -62,7 +62,7 @@
public void setValue(String stValue) throws IllegalArgumentException {
if (!Name.isValid(stValue))
throw new IllegalArgumentException(
- //Messages.getMessage("badNameType00") +
+ " invalid value for name " +
" data=[" + stValue + "]");
m_value = stValue;
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/types/Time.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/types/Time.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/types/Time.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/types/Time.java Sat Dec 1 06:43:28 2007
@@ -19,6 +19,8 @@
package org.apache.axis2.databinding.types;
+import org.apache.axis2.databinding.utils.ConverterUtil;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -38,17 +40,13 @@
* a shared java.text.SimpleDateFormat instance used for parsing the basic component of the
* timestamp
*/
- private static SimpleDateFormat zulu =
- new SimpleDateFormat("HH:mm:ss.SSSSSSSSS'Z'");
-
- static {
- zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
/** Initializes with a Calender. Year, month and date are ignored. */
public Time(Calendar value) {
this._value = value;
- _value.set(0, 0, 0); // ignore year, month, date
+ this._value.clear(Calendar.YEAR);
+ this._value.clear(Calendar.MONTH);
+ this._value.clear(Calendar.DATE);
}
/** Converts a string formatted as HH:mm:ss[.SSS][+/-offset] */
@@ -74,7 +72,9 @@
*/
public void setTime(Calendar date) {
this._value = date;
- _value.set(0, 0, 0); // ignore year, month, date
+ this._value.clear(Calendar.YEAR);
+ this._value.clear(Calendar.MONTH);
+ this._value.clear(Calendar.DATE);
}
/**
@@ -84,55 +84,89 @@
*/
public void setTime(Date date) {
_value.setTime(date);
- _value.set(0, 0, 0); // ignore year, month, date
+ this._value.clear(Calendar.YEAR);
+ this._value.clear(Calendar.MONTH);
+ this._value.clear(Calendar.DATE);
}
/** Utility function that parses xsd:time strings and returns a Date object */
private Calendar makeValue(String source) throws NumberFormatException {
// cannonical form of the times is hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
+ if ((source == null) || (source.trim().length() == 0)){
+ return null;
+ }
- Calendar calendar = Calendar.getInstance();
- SimpleDateFormat simpleDateFormat = null;
- Date date;
+ source = source.trim();
- if ((source != null) && (source.length() >= 8)) {
- if (source.length() == 8) {
- // i.e this does not have milisecond values or time zone value
- simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
- } else {
+ Calendar calendar = Calendar.getInstance();
+ calendar.clear();
+ int hour = 0;
+ int minite = 0;
+ int second = 0;
+ int miliSecond = 0;
+ int timeZoneOffSet = TimeZone.getDefault().getRawOffset();
+
+ if (source.length() >= 8) {
+ if ((source.charAt(2) != ':' )|| (source.charAt(5) != ':')){
+ throw new RuntimeException("Invalid time format (" + source + ") having : s in wrong places");
+ }
+ hour = Integer.parseInt(source.substring(0, 2));
+ minite = Integer.parseInt(source.substring(3, 5));
+ second = Integer.parseInt(source.substring(6, 8));
+ if (source.length() > 8) {
String rest = source.substring(8);
if (rest.startsWith(".")) {
// i.e this have the ('.'s+) part
if (rest.endsWith("Z")) {
// this is in gmt time zone
- simpleDateFormat = new SimpleDateFormat("HH:mm:ss.SSSSSSSSS'Z'");
- simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ timeZoneOffSet = 0;
+ miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("Z")));
- } else if ((rest.indexOf("+") > 0) || (rest.indexOf("-") > 0)) {
+ } else if ((rest.lastIndexOf("+") > 0) || (rest.lastIndexOf("-") > 0)) {
// this is given in a general time zione
- simpleDateFormat = new SimpleDateFormat("HH:mm:ss.SSSSSSSSSz");
+ String timeOffSet = null;
if (rest.lastIndexOf("+") > 0) {
- source = source.substring(0, source.lastIndexOf("+")) + "GMT" +
- rest.substring(rest.lastIndexOf("+"));
+ timeOffSet = rest.substring(rest.lastIndexOf("+") + 1);
+ miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("+")));
+ // we keep +1 or -1 to finally calculate the value
+ timeZoneOffSet = 1;
+
} else if (rest.lastIndexOf("-") > 0) {
- source = source.substring(0, source.lastIndexOf("-")) + "GMT" +
- rest.substring(rest.lastIndexOf("-"));
+ timeOffSet = rest.substring(rest.lastIndexOf("-") + 1);
+ miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("-")));
+ // we keep +1 or -1 to finally calculate the value
+ timeZoneOffSet = -1;
}
+ if (timeOffSet.charAt(2) != ':') {
+ throw new RuntimeException("invalid time zone format (" + source
+ + ") without : at correct place");
+ }
+ int hours = Integer.parseInt(timeOffSet.substring(0, 2));
+ int minits = Integer.parseInt(timeOffSet.substring(3, 5));
+ timeZoneOffSet = ((hours * 60) + minits) * 60000 * timeZoneOffSet;
+
} else {
// i.e it does not have time zone
- simpleDateFormat = new SimpleDateFormat("HH:mm:ss.SSSSSSSSS");
+ miliSecond = Integer.parseInt(rest.substring(1));
}
} else {
if (rest.startsWith("Z")) {
// this is in gmt time zone
- simpleDateFormat = new SimpleDateFormat("HH:mm:ss'Z'");
- simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ timeZoneOffSet = 0;
} else if (rest.startsWith("+") || rest.startsWith("-")) {
// this is given in a general time zione
- simpleDateFormat = new SimpleDateFormat("HH:mm:ssz");
- source = source.substring(0, 8) + "GMT" + rest;
+ if (rest.charAt(3) != ':') {
+ throw new RuntimeException("invalid time zone format (" + source
+ + ") without : at correct place");
+ }
+ int hours = Integer.parseInt(rest.substring(1, 3));
+ int minits = Integer.parseInt(rest.substring(4, 6));
+ timeZoneOffSet = ((hours * 60) + minits) * 60000;
+ if (rest.startsWith("-")) {
+ timeZoneOffSet = timeZoneOffSet * -1;
+ }
} else {
throw new NumberFormatException("in valid time zone attribute");
}
@@ -142,13 +176,11 @@
throw new RuntimeException("invalid message string");
}
- try {
- date = simpleDateFormat.parse(source);
- calendar.setTime(date);
- calendar.set(0, 0, 0);
- } catch (ParseException e) {
- throw new RuntimeException("invalid message string");
- }
+ calendar.set(Calendar.HOUR_OF_DAY, hour);
+ calendar.set(Calendar.MINUTE, minite);
+ calendar.set(Calendar.SECOND, second);
+ calendar.set(Calendar.MILLISECOND, miliSecond);
+ calendar.set(Calendar.ZONE_OFFSET, timeZoneOffSet);
return calendar;
}
@@ -168,9 +200,10 @@
if (isFromString) {
return originalString;
} else {
- synchronized (zulu) {
- return zulu.format(_value.getTime());
- }
+ StringBuffer timeString = new StringBuffer();
+ ConverterUtil.appendTime(_value,timeString);
+ ConverterUtil.appendTimeZone(_value,timeString);
+ return timeString.toString();
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java Sat Dec 1 06:43:28 2007
@@ -22,11 +22,17 @@
import org.apache.axiom.attachments.utils.IOUtils;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMConstants;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.MTOMConstants;
+import org.apache.axiom.om.impl.llom.OMStAXWrapper;
import org.apache.axiom.om.util.Base64;
import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.om.util.ElementHelper;
+import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
import org.apache.axis2.databinding.ADBBean;
import org.apache.axis2.databinding.ADBException;
+import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter;
import org.apache.axis2.databinding.i18n.ADBMessages;
import org.apache.axis2.databinding.types.*;
import org.apache.commons.logging.Log;
@@ -38,6 +44,10 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.DatatypeConfigurationException;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.Array;
@@ -105,21 +115,63 @@
}
public static String convertToString(Date value) {
+
if (isCustomClassPresent) {
// this means user has define a seperate converter util class
return invokeToStringMethod(value,Date.class);
} else {
// lexical form of the date is '-'? yyyy '-' mm '-' dd zzzzzz?
- // we have to serialize it with the GMT timezone
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-ddZ");
- // this does not create the semicolen need so add that.
- String dateString = simpleDateFormat.format(value);
- // append semicolen
- dateString = dateString.substring(0, dateString.length() - 2) +
- ":" + dateString.substring(dateString.length() - 2);
+ Calendar calendar = Calendar.getInstance();
+ calendar.clear();
+ calendar.setTime(value);
+ if (!calendar.isSet(Calendar.ZONE_OFFSET)){
+ calendar.setTimeZone(TimeZone.getDefault());
+ }
+ StringBuffer dateString = new StringBuffer(16);
+ appendDate(dateString, calendar);
+ appendTimeZone(calendar, dateString);
+ return dateString.toString();
+ }
+ }
+
+ public static void appendTimeZone(Calendar calendar, StringBuffer dateString) {
+ int timezoneOffSet = calendar.get(Calendar.ZONE_OFFSET);
+ int timezoneOffSetInMinits = timezoneOffSet / 60000;
+ if (timezoneOffSetInMinits < 0){
+ dateString.append("-");
+ timezoneOffSetInMinits = timezoneOffSetInMinits * -1;
+ } else {
+ dateString.append("+");
+ }
+ int hours = timezoneOffSetInMinits / 60;
+ int minits = timezoneOffSetInMinits % 60;
- return dateString;
+ if (hours < 10) {
+ dateString.append("0");
}
+ dateString.append(hours).append(":");
+
+ if (minits < 10){
+ dateString.append("0");
+ }
+
+ dateString.append(minits);
+ }
+
+ public static void appendDate(StringBuffer dateString, Calendar calendar) {
+ dateString.append(calendar.get(Calendar.YEAR)).append("-");
+
+ // xml date month is started from 1 and calendar month is
+ // started from 0. so have to add one
+ int month = calendar.get(Calendar.MONTH) + 1;
+ if (month < 10){
+ dateString.append("0");
+ }
+ dateString.append(month).append("-");
+ if (calendar.get(Calendar.DAY_OF_MONTH) < 10){
+ dateString.append("0");
+ }
+ dateString.append(calendar.get(Calendar.DAY_OF_MONTH));
}
private static String invokeToStringMethod(Object value, Class type) {
@@ -145,13 +197,41 @@
return invokeToStringMethod(value,Calendar.class);
} else {
// lexical form of the calendar is '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
- SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
- // Sun JDK bug http://developer.java.sun.com/developer/bugParade/bugs/4229798.html
- return zulu.format(value.getTime());
+ if (!value.isSet(Calendar.ZONE_OFFSET)){
+ value.setTimeZone(TimeZone.getDefault());
+ }
+ StringBuffer dateString = new StringBuffer(28);
+ appendDate(dateString, value);
+ dateString.append("T");
+ //adding hours
+ appendTime(value, dateString);
+ appendTimeZone(value, dateString);
+ return dateString.toString();
}
}
+ public static void appendTime(Calendar value, StringBuffer dateString) {
+ if (value.get(Calendar.HOUR_OF_DAY) < 10) {
+ dateString.append("0");
+ }
+ dateString.append(value.get(Calendar.HOUR_OF_DAY)).append(":");
+ if (value.get(Calendar.MINUTE) < 10) {
+ dateString.append("0");
+ }
+ dateString.append(value.get(Calendar.MINUTE)).append(":");
+ if (value.get(Calendar.SECOND) < 10) {
+ dateString.append("0");
+ }
+ dateString.append(value.get(Calendar.SECOND)).append(".");
+ if (value.get(Calendar.MILLISECOND) < 10) {
+ dateString.append("0");
+ }
+ if (value.get(Calendar.MILLISECOND) < 100) {
+ dateString.append("0");
+ }
+ dateString.append(value.get(Calendar.MILLISECOND));
+ }
+
public static String convertToString(Day o) {
return o.toString();
}
@@ -441,32 +521,47 @@
public static Date convertToDate(String source) {
// the lexical form of the date is '-'? yyyy '-' mm '-' dd zzzzzz?
- if ((source == null) || source.equals("")){
+ if ((source == null) || source.trim().equals("")) {
return null;
}
- Calendar calendar = Calendar.getInstance();
- SimpleDateFormat simpleDateFormat = null;
+ source = source.trim();
boolean bc = false;
if (source.startsWith("-")) {
source = source.substring(1);
bc = true;
}
- if ((source != null) && (source.length() >= 10)) {
- if (source.length() == 10) {
- //i.e this stirng has only the compulsory part
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- } else {
+ int year = 0;
+ int month = 0;
+ int day = 0;
+ int timeZoneOffSet = TimeZone.getDefault().getRawOffset();
+
+ if (source.length() >= 10) {
+ //first 10 numbers must give the year
+ if ((source.charAt(4) != '-') || (source.charAt(7) != '-')){
+ throw new RuntimeException("invalid date format (" + source + ") wiht out - s at correct place ");
+ }
+ year = Integer.parseInt(source.substring(0,4));
+ month = Integer.parseInt(source.substring(5,7));
+ day = Integer.parseInt(source.substring(8,10));
+
+ if (source.length() > 10) {
String restpart = source.substring(10);
if (restpart.startsWith("Z")) {
// this is a gmt time zone value
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'Z'");
- simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ timeZoneOffSet = 0;
} else if (restpart.startsWith("+") || restpart.startsWith("-")) {
// this is a specific time format string
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-ddz");
- // have to add the GMT part to process the message
- source = source.substring(0, 10) + "GMT" + restpart;
+ if (restpart.charAt(3) != ':'){
+ throw new RuntimeException("invalid time zone format (" + source
+ + ") without : at correct place");
+ }
+ int hours = Integer.parseInt(restpart.substring(1,3));
+ int minits = Integer.parseInt(restpart.substring(4,6));
+ timeZoneOffSet = ((hours * 60) + minits) * 60000;
+ if (restpart.startsWith("-")){
+ timeZoneOffSet = timeZoneOffSet * -1;
+ }
} else {
throw new RuntimeException("In valid string sufix");
}
@@ -475,19 +570,20 @@
throw new RuntimeException("In valid string to parse");
}
- Date date;
- try {
- date = simpleDateFormat.parse(source);
- if (bc) {
- calendar.setTime(date);
- calendar.set(Calendar.ERA, GregorianCalendar.BC);
- date = calendar.getTime();
- }
- } catch (ParseException e) {
- throw new RuntimeException("In valid string to parse");
+ Calendar calendar = Calendar.getInstance();
+ calendar.clear();
+ calendar.set(Calendar.YEAR, year);
+ //xml month stars from the 1 and calendar month is starts with 0
+ calendar.set(Calendar.MONTH, month - 1);
+ calendar.set(Calendar.DAY_OF_MONTH, day);
+ calendar.set(Calendar.ZONE_OFFSET, timeZoneOffSet);
+ calendar.getTimeInMillis();
+ if (bc){
+ calendar.set(Calendar.ERA, GregorianCalendar.BC);
}
- return date;
+ return calendar.getTime();
+
}
public static Time convertToTime(String s) {
@@ -725,74 +821,118 @@
*/
public static Calendar convertToDateTime(String source) {
- if ((source == null) || source.equals("")){
+ if ((source == null) || source.trim().equals("")) {
return null;
}
+ source = source.trim();
// the lexical representation of the date time as follows
// '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
- SimpleDateFormat simpleDateFormat = null;
Date date = null;
Calendar calendar = Calendar.getInstance();
+ calendar.clear();
if (source.startsWith("-")) {
source = source.substring(1);
calendar.set(Calendar.ERA, GregorianCalendar.BC);
}
- try {
- if ((source != null) && (source.length() >= 19)) {
- if (source.length() == 19) {
- // i.e. this does not have any additional assume this time in current local
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
-
- } else {
- String rest = source.substring(19);
- if (rest.startsWith(".")) {
- // i.e this have the ('.'s+) part
- if (rest.endsWith("Z")) {
- // this is in gmt time zone
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'");
- simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- } else if ((rest.lastIndexOf("+") > 0) || (rest.lastIndexOf("-") > 0)) {
- // this is given in a general time zione
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSz");
- if (rest.lastIndexOf("+") > 0) {
- source = source.substring(0, source.lastIndexOf("+")) + "GMT" +
- rest.substring(rest.lastIndexOf("+"));
- } else if (rest.lastIndexOf("-") > 0) {
- source = source.substring(0, source.lastIndexOf("-")) + "GMT" +
- rest.substring(rest.lastIndexOf("-"));
- }
-
- } else {
- // i.e it does not have time zone
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS");
+ int year = 0;
+ int month = 0;
+ int day = 0;
+ int hour = 0;
+ int minite = 0;
+ int second = 0;
+ int miliSecond = 0;
+ int timeZoneOffSet = TimeZone.getDefault().getRawOffset();
+
+
+ if ((source != null) && (source.length() >= 19)) {
+ if ((source.charAt(4) != '-') ||
+ (source.charAt(7) != '-') ||
+ (source.charAt(10) != 'T') ||
+ (source.charAt(13) != ':') ||
+ (source.charAt(16) != ':')) {
+ throw new RuntimeException("invalid date format (" + source + ") wiht out - s at correct place ");
+ }
+ year = Integer.parseInt(source.substring(0, 4));
+ month = Integer.parseInt(source.substring(5, 7));
+ day = Integer.parseInt(source.substring(8, 10));
+ hour = Integer.parseInt(source.substring(11, 13));
+ minite = Integer.parseInt(source.substring(14, 16));
+ second = Integer.parseInt(source.substring(17, 19));
+
+ if (source.length() > 19) {
+ String rest = source.substring(19);
+ if (rest.startsWith(".")) {
+ // i.e this have the ('.'s+) part
+ if (rest.endsWith("Z")) {
+ // this is in gmt time zone
+ timeZoneOffSet = 0;
+ miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("Z")));
+
+ } else if ((rest.lastIndexOf("+") > 0) || (rest.lastIndexOf("-") > 0)) {
+ // this is given in a general time zione
+ String timeOffSet = null;
+ if (rest.lastIndexOf("+") > 0) {
+ timeOffSet = rest.substring(rest.lastIndexOf("+") + 1);
+ miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("+")));
+ // we keep +1 or -1 to finally calculate the value
+ timeZoneOffSet = 1;
+
+ } else if (rest.lastIndexOf("-") > 0) {
+ timeOffSet = rest.substring(rest.lastIndexOf("-") + 1);
+ miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("-")));
+ // we keep +1 or -1 to finally calculate the value
+ timeZoneOffSet = -1;
}
+ if (timeOffSet.charAt(2) != ':') {
+ throw new RuntimeException("invalid time zone format (" + source
+ + ") without : at correct place");
+ }
+ int hours = Integer.parseInt(timeOffSet.substring(0, 2));
+ int minits = Integer.parseInt(timeOffSet.substring(3, 5));
+ timeZoneOffSet = ((hours * 60) + minits) * 60000 * timeZoneOffSet;
} else {
- if (rest.startsWith("Z")) {
- // this is in gmt time zone
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
- simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
- } else if (rest.startsWith("+") || rest.startsWith("-")) {
- // this is given in a general time zione
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
- source = source.substring(0, 19) + "GMT" + rest;
- } else {
- throw new NumberFormatException("in valid time zone attribute");
+ // i.e it does not have time zone
+ miliSecond = Integer.parseInt(rest.substring(1));
+ }
+
+ } else {
+ if (rest.startsWith("Z")) {
+ // this is in gmt time zone
+ timeZoneOffSet = 0;
+ } else if (rest.startsWith("+") || rest.startsWith("-")) {
+ // this is given in a general time zione
+ if (rest.charAt(3) != ':') {
+ throw new RuntimeException("invalid time zone format (" + source
+ + ") without : at correct place");
}
+ int hours = Integer.parseInt(rest.substring(1, 3));
+ int minits = Integer.parseInt(rest.substring(4, 6));
+ timeZoneOffSet = ((hours * 60) + minits) * 60000;
+ if (rest.startsWith("-")) {
+ timeZoneOffSet = timeZoneOffSet * -1;
+ }
+ } else {
+ throw new NumberFormatException("in valid time zone attribute");
}
}
- date = simpleDateFormat.parse(source);
- calendar.setTime(date);
-
- } else {
- throw new NumberFormatException("date string can not be less than 19 charactors");
}
- } catch (ParseException e) {
- throw new NumberFormatException(e.getMessage());
+ calendar.set(Calendar.YEAR, year);
+ // xml month is started from 1 and calendar month is started from 0
+ calendar.set(Calendar.MONTH, month - 1);
+ calendar.set(Calendar.DAY_OF_MONTH, day);
+ calendar.set(Calendar.HOUR_OF_DAY, hour);
+ calendar.set(Calendar.MINUTE, minite);
+ calendar.set(Calendar.SECOND, second);
+ calendar.set(Calendar.MILLISECOND, miliSecond);
+ calendar.set(Calendar.ZONE_OFFSET, timeZoneOffSet);
+
+ } else {
+ throw new NumberFormatException("date string can not be less than 19 charactors");
}
+
return calendar;
}
@@ -1201,6 +1341,8 @@
serializeAnyType("boolean", value.toString(), xmlStreamWriter);
} else if (value instanceof URI) {
serializeAnyType("anyURI", value.toString(), xmlStreamWriter);
+ } else if (value instanceof Byte) {
+ serializeAnyType("byte", value.toString(), xmlStreamWriter);
} else if (value instanceof Date) {
serializeAnyType("date", convertToString((Date) value), xmlStreamWriter);
} else if (value instanceof Calendar) {
@@ -1217,6 +1359,10 @@
serializeAnyType("short", value.toString(), xmlStreamWriter);
} else if (value instanceof BigDecimal) {
serializeAnyType("decimal", value.toString(), xmlStreamWriter);
+ } else if (value instanceof DataHandler) {
+ addTypeAttribute(xmlStreamWriter,"base64Binary");
+ MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = (MTOMAwareXMLStreamWriter) xmlStreamWriter;
+ mtomAwareXMLStreamWriter.writeDataHandler((DataHandler)value);
} else if (value instanceof QName) {
QName qNameValue = (QName) value;
String prefix = xmlStreamWriter.getPrefix(qNameValue.getNamespaceURI());
@@ -1265,6 +1411,11 @@
XMLStreamWriter xmlStreamWriter)
throws XMLStreamException {
+ addTypeAttribute(xmlStreamWriter, type);
+ xmlStreamWriter.writeCharacters(value);
+ }
+
+ private static void addTypeAttribute(XMLStreamWriter xmlStreamWriter, String type) throws XMLStreamException {
String prefix = xmlStreamWriter.getPrefix(Constants.XSI_NAMESPACE);
if (prefix == null) {
prefix = BeanUtil.getUniquePrefix();
@@ -1287,10 +1438,10 @@
}
xmlStreamWriter.writeAttribute(Constants.XSI_NAMESPACE, "type", attributeValue);
- xmlStreamWriter.writeCharacters(value);
}
- public static Object getAnyTypeObject(XMLStreamReader xmlStreamReader) throws XMLStreamException {
+ public static Object getAnyTypeObject(XMLStreamReader xmlStreamReader,
+ Class extensionMapperClass) throws XMLStreamException {
Object returnObject = null;
// make sure reader is at the first element.
@@ -1304,69 +1455,98 @@
} else {
String attributeType = xmlStreamReader.getAttributeValue(Constants.XSI_NAMESPACE, "type");
if (attributeType != null) {
+ String attributeTypePrefix = "";
if (attributeType.indexOf(":") > -1) {
+ attributeTypePrefix = attributeType.substring(0,attributeType.indexOf(":"));
attributeType = attributeType.substring(attributeType.indexOf(":") + 1);
}
NamespaceContext namespaceContext = xmlStreamReader.getNamespaceContext();
- xmlStreamReader.next();
+ String attributeNameSpace = namespaceContext.getNamespaceURI(attributeTypePrefix);
- String attribValue = xmlStreamReader.getText();
- if (attribValue != null){
- if (attributeType.equals("string")) {
- returnObject = attribValue;
- } else if (attributeType.equals("int")) {
- returnObject = new Integer(attribValue);
- } else if (attributeType.equals("QName")) {
- String namespacePrefix = null;
- String localPart = null;
- if (attribValue.indexOf(":") > -1){
- namespacePrefix = attribValue.substring(0,attribValue.indexOf(":"));
- localPart = attribValue.substring(attribValue.indexOf(":") + 1);
- returnObject = new QName(namespaceContext.getNamespaceURI(namespacePrefix),localPart);
- }
- } else if ("boolean".equals(attributeType)) {
- returnObject = new Boolean(attribValue);
- } else if ("anyURI".equals(attributeType)) {
- try {
- returnObject = new URI(attribValue);
- } catch (URI.MalformedURIException e) {
- throw new XMLStreamException("Invalid URI");
- }
- } else if ("date".equals(attributeType)) {
- returnObject = ConverterUtil.convertToDate(attribValue);
- } else if ("dateTime".equals(attributeType)) {
- returnObject = ConverterUtil.convertToDateTime(attribValue);
- } else if ("time".equals(attributeType)) {
- returnObject = ConverterUtil.convertToTime(attribValue);
- } else if ("float".equals(attributeType)) {
- returnObject = new Float(attribValue);
- } else if ("long".equals(attributeType)) {
- returnObject = new Long(attribValue);
- } else if ("double".equals(attributeType)) {
- returnObject = new Double(attribValue);
- } else if ("decimal".equals(attributeType)) {
- returnObject = new BigDecimal(attribValue);
- } else if ("unsignedLong".equals(attributeType)) {
- returnObject = new UnsignedLong(attribValue);
- } else if ("unsignedInt".equals(attributeType)) {
- returnObject = new UnsignedInt(attribValue);
- } else if ("unsignedShort".equals(attributeType)) {
- returnObject = new UnsignedShort(attribValue);
- } else if ("unsignedByte".equals(attributeType)) {
- returnObject = new UnsignedByte(attribValue);
- } else if ("positiveInteger".equals(attributeType)) {
- returnObject = new PositiveInteger(attribValue);
- } else if ("negativeInteger".equals(attributeType)) {
- returnObject = new NegativeInteger(attribValue);
- } else if ("nonNegativeInteger".equals(attributeType)) {
- returnObject = new NonNegativeInteger(attribValue);
- } else if ("nonPositiveInteger".equals(attributeType)) {
- returnObject = new NonPositiveInteger(attribValue);
+ if (attributeNameSpace.equals(Constants.XSD_NAMESPACE)) {
+ if ("base64Binary".equals(attributeType)) {
+ returnObject = getDataHandlerObject(xmlStreamReader);
} else {
- throw new ADBException("Unknown type ==> " + attributeType);
+ String attribValue = xmlStreamReader.getElementText();
+ if (attribValue != null) {
+ if (attributeType.equals("string")) {
+ returnObject = attribValue;
+ } else if (attributeType.equals("int")) {
+ returnObject = new Integer(attribValue);
+ } else if (attributeType.equals("QName")) {
+ String namespacePrefix = null;
+ String localPart = null;
+ if (attribValue.indexOf(":") > -1) {
+ namespacePrefix = attribValue.substring(0, attribValue.indexOf(":"));
+ localPart = attribValue.substring(attribValue.indexOf(":") + 1);
+ returnObject = new QName(namespaceContext.getNamespaceURI(namespacePrefix), localPart);
+ }
+ } else if ("boolean".equals(attributeType)) {
+ returnObject = new Boolean(attribValue);
+ } else if ("anyURI".equals(attributeType)) {
+ try {
+ returnObject = new URI(attribValue);
+ } catch (URI.MalformedURIException e) {
+ throw new XMLStreamException("Invalid URI");
+ }
+ } else if ("date".equals(attributeType)) {
+ returnObject = ConverterUtil.convertToDate(attribValue);
+ } else if ("dateTime".equals(attributeType)) {
+ returnObject = ConverterUtil.convertToDateTime(attribValue);
+ } else if ("time".equals(attributeType)) {
+ returnObject = ConverterUtil.convertToTime(attribValue);
+ } else if ("byte".equals(attributeType)) {
+ returnObject = new Byte(attribValue);
+ } else if ("short".equals(attributeType)) {
+ returnObject = new Short(attribValue);
+ } else if ("float".equals(attributeType)) {
+ returnObject = new Float(attribValue);
+ } else if ("long".equals(attributeType)) {
+ returnObject = new Long(attribValue);
+ } else if ("double".equals(attributeType)) {
+ returnObject = new Double(attribValue);
+ } else if ("decimal".equals(attributeType)) {
+ returnObject = new BigDecimal(attribValue);
+ } else if ("unsignedLong".equals(attributeType)) {
+ returnObject = new UnsignedLong(attribValue);
+ } else if ("unsignedInt".equals(attributeType)) {
+ returnObject = new UnsignedInt(attribValue);
+ } else if ("unsignedShort".equals(attributeType)) {
+ returnObject = new UnsignedShort(attribValue);
+ } else if ("unsignedByte".equals(attributeType)) {
+ returnObject = new UnsignedByte(attribValue);
+ } else if ("positiveInteger".equals(attributeType)) {
+ returnObject = new PositiveInteger(attribValue);
+ } else if ("negativeInteger".equals(attributeType)) {
+ returnObject = new NegativeInteger(attribValue);
+ } else if ("nonNegativeInteger".equals(attributeType)) {
+ returnObject = new NonNegativeInteger(attribValue);
+ } else if ("nonPositiveInteger".equals(attributeType)) {
+ returnObject = new NonPositiveInteger(attribValue);
+ } else {
+ throw new ADBException("Unknown type ==> " + attributeType);
+ }
+ } else {
+ throw new ADBException("Attribute value is null");
+ }
}
} else {
- throw new ADBException("Attribute value is null");
+ try {
+ Method getObjectMethod = extensionMapperClass.getMethod("getTypeObject",
+ new Class[]{String.class, String.class, XMLStreamReader.class});
+ returnObject = getObjectMethod.invoke(null,
+ new Object[]{attributeNameSpace, attributeType, xmlStreamReader});
+ } catch (NoSuchMethodException e) {
+ throw new ADBException("Can not find the getTypeObject method in the " +
+ "extension mapper class ", e);
+ } catch (IllegalAccessException e) {
+ throw new ADBException("Can not access the getTypeObject method in the " +
+ "extension mapper class ", e);
+ } catch (InvocationTargetException e) {
+ throw new ADBException("Can not invoke the getTypeObject method in the " +
+ "extension mapper class ", e);
+ }
+
}
} else {
@@ -1374,6 +1554,26 @@
}
}
return returnObject;
+ }
+
+ private static Object getDataHandlerObject(XMLStreamReader reader) throws XMLStreamException {
+ Object dataHandler = null;
+ if (Boolean.TRUE.equals(reader.getProperty(OMConstants.IS_DATA_HANDLERS_AWARE))
+ && Boolean.TRUE.equals(reader.getProperty(OMConstants.IS_BINARY))) {
+ dataHandler = reader.getProperty(org.apache.axiom.om.OMConstants.DATA_HANDLER);
+ } else {
+ if (reader.getEventType() == XMLStreamConstants.START_ELEMENT &&
+ reader.getName().equals(new QName(MTOMConstants.XOP_NAMESPACE_URI, MTOMConstants.XOP_INCLUDE))) {
+ String id = ElementHelper.getContentID(reader, "UTF-8");
+ dataHandler = ((MTOMStAXSOAPModelBuilder) ((OMStAXWrapper) reader).getBuilder()).getDataHandler(id);
+ reader.next();
+ } else if (reader.hasText()) {
+ String content = reader.getText();
+ dataHandler = ConverterUtil.convertToBase64Binary(content);
+
+ }
+ }
+ return dataHandler;
}
static {
Modified: webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/rpc/receivers/RPCInOnlyMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/rpc/receivers/RPCInOnlyMessageReceiver.java?rev=600141&r1=600140&r2=600141&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/rpc/receivers/RPCInOnlyMessageReceiver.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/adb/src/org/apache/axis2/rpc/receivers/RPCInOnlyMessageReceiver.java Sat Dec 1 06:43:28 2007
@@ -66,6 +66,7 @@
methodElement,inMessage);
}
+ replicateState(inMessage);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org