You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [35/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/ap...
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/BeanManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/BeanManager.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/BeanManager.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/BeanManager.java Thu Sep 15 11:52:11 2005
@@ -1,127 +1,127 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.metadata;
-
-import org.apache.axis2.databinding.beans.BeanPropertyDescriptor;
-import org.apache.axis2.databinding.typemapping.TypeMappingRegistry;
-import org.apache.axis2.databinding.DeserializerFactory;
-import org.apache.axis2.databinding.Serializer;
-
-import javax.xml.namespace.QName;
-import java.beans.Introspector;
-import java.beans.BeanInfo;
-import java.beans.PropertyDescriptor;
-import java.beans.IndexedPropertyDescriptor;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * BeanManager
- */
-public class BeanManager {
- static Map class2TypeMap = new HashMap();
-
- public static TypeDesc getTypeDesc(Class beanClass) {
- // If we're already done with this class, just return the cached one
- TypeDesc desc = (TypeDesc)class2TypeMap.get(beanClass);
- if (desc != null)
- return desc;
-
- // OK, nothing cached. See if the class has supplied some data itself
- desc = TypeDesc.getTypeDescForClass(beanClass);
- if (desc == null) {
- desc = new TypeDesc();
- }
-
- class2TypeMap.put(beanClass, desc);
-
- try {
- fillInTypeDesc(desc, beanClass);
- } catch (Exception e) {
- desc = null;
- class2TypeMap.remove(beanClass);
- }
-
- return desc;
- }
-
- private static void fillInTypeDesc(TypeDesc desc, Class beanClass)
- throws Exception {
- TypeMappingRegistry tmr = new TypeMappingRegistry();
-
- desc.setJavaClass(beanClass);
-
- BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
- for (int i = 0; i < propDescs.length; i++) {
- PropertyDescriptor propDesc = propDescs[i];
- String name = propDesc.getName();
-
- if (name.equals("class"))
- continue;
-
- BeanPropertyDescriptor beanDesc = new BeanPropertyDescriptor();
- beanDesc.setReadMethod(propDesc.getReadMethod());
- beanDesc.setWriteMethod(propDesc.getWriteMethod());
-
- ElementDesc elDesc = desc.getElementDesc(name);
- boolean addDesc = true; // Should we add this (new) element?
- if (elDesc == null) {
- elDesc = new ElementDesc();
- elDesc.setFieldName(name);
- } else {
- addDesc = false; // Already present, so don't add it again
- }
- Class type;
- boolean isCollection = false;
- if (propDesc instanceof IndexedPropertyDescriptor) {
- IndexedPropertyDescriptor iProp =
- (IndexedPropertyDescriptor)propDesc;
- beanDesc.setIndexedReadMethod(iProp.getIndexedReadMethod());
- beanDesc.setIndexedWriteMethod(iProp.getIndexedWriteMethod());
- type = iProp.getIndexedPropertyType();
- elDesc.setIndexedAccessor(beanDesc);
- isCollection = true;
-// elDesc.setItemQName(new QName("http://foo", "item"));
- } else {
- type = propDesc.getPropertyType();
- // TODO : notice if this is a supported collection type
- }
-
- if (isCollection && elDesc.getMaxOccurs() == 0)
- elDesc.setMaxOccurs(-1);
-
- elDesc.setAccessor(beanDesc);
-
- if (elDesc.getQName() == null) {
- elDesc.setQName(new QName(name));
- }
-
- if (elDesc.getDeserializerFactory() == null) {
- DeserializerFactory dser = tmr.getDeserializerFactory(type);
- elDesc.setDeserializerFactory(dser);
- }
-
- if (elDesc.getRawSerializer() == null) {
- Serializer ser = tmr.getSerializer(type);
- elDesc.setSerializer(ser);
- }
-
- if (addDesc)
- desc.addField(elDesc);
- }
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.metadata;
+
+import org.apache.axis2.databinding.beans.BeanPropertyDescriptor;
+import org.apache.axis2.databinding.typemapping.TypeMappingRegistry;
+import org.apache.axis2.databinding.DeserializerFactory;
+import org.apache.axis2.databinding.Serializer;
+
+import javax.xml.namespace.QName;
+import java.beans.Introspector;
+import java.beans.BeanInfo;
+import java.beans.PropertyDescriptor;
+import java.beans.IndexedPropertyDescriptor;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * BeanManager
+ */
+public class BeanManager {
+ static Map class2TypeMap = new HashMap();
+
+ public static TypeDesc getTypeDesc(Class beanClass) {
+ // If we're already done with this class, just return the cached one
+ TypeDesc desc = (TypeDesc)class2TypeMap.get(beanClass);
+ if (desc != null)
+ return desc;
+
+ // OK, nothing cached. See if the class has supplied some data itself
+ desc = TypeDesc.getTypeDescForClass(beanClass);
+ if (desc == null) {
+ desc = new TypeDesc();
+ }
+
+ class2TypeMap.put(beanClass, desc);
+
+ try {
+ fillInTypeDesc(desc, beanClass);
+ } catch (Exception e) {
+ desc = null;
+ class2TypeMap.remove(beanClass);
+ }
+
+ return desc;
+ }
+
+ private static void fillInTypeDesc(TypeDesc desc, Class beanClass)
+ throws Exception {
+ TypeMappingRegistry tmr = new TypeMappingRegistry();
+
+ desc.setJavaClass(beanClass);
+
+ BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
+ PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
+ for (int i = 0; i < propDescs.length; i++) {
+ PropertyDescriptor propDesc = propDescs[i];
+ String name = propDesc.getName();
+
+ if (name.equals("class"))
+ continue;
+
+ BeanPropertyDescriptor beanDesc = new BeanPropertyDescriptor();
+ beanDesc.setReadMethod(propDesc.getReadMethod());
+ beanDesc.setWriteMethod(propDesc.getWriteMethod());
+
+ ElementDesc elDesc = desc.getElementDesc(name);
+ boolean addDesc = true; // Should we add this (new) element?
+ if (elDesc == null) {
+ elDesc = new ElementDesc();
+ elDesc.setFieldName(name);
+ } else {
+ addDesc = false; // Already present, so don't add it again
+ }
+ Class type;
+ boolean isCollection = false;
+ if (propDesc instanceof IndexedPropertyDescriptor) {
+ IndexedPropertyDescriptor iProp =
+ (IndexedPropertyDescriptor)propDesc;
+ beanDesc.setIndexedReadMethod(iProp.getIndexedReadMethod());
+ beanDesc.setIndexedWriteMethod(iProp.getIndexedWriteMethod());
+ type = iProp.getIndexedPropertyType();
+ elDesc.setIndexedAccessor(beanDesc);
+ isCollection = true;
+// elDesc.setItemQName(new QName("http://foo", "item"));
+ } else {
+ type = propDesc.getPropertyType();
+ // TODO : notice if this is a supported collection type
+ }
+
+ if (isCollection && elDesc.getMaxOccurs() == 0)
+ elDesc.setMaxOccurs(-1);
+
+ elDesc.setAccessor(beanDesc);
+
+ if (elDesc.getQName() == null) {
+ elDesc.setQName(new QName(name));
+ }
+
+ if (elDesc.getDeserializerFactory() == null) {
+ DeserializerFactory dser = tmr.getDeserializerFactory(type);
+ elDesc.setDeserializerFactory(dser);
+ }
+
+ if (elDesc.getRawSerializer() == null) {
+ Serializer ser = tmr.getSerializer(type);
+ elDesc.setSerializer(ser);
+ }
+
+ if (addDesc)
+ desc.addField(elDesc);
+ }
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/BeanManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/ElementDesc.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/ElementDesc.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/ElementDesc.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/ElementDesc.java Thu Sep 15 11:52:11 2005
@@ -1,116 +1,116 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.metadata;
-
-import org.apache.axis2.databinding.Deserializer;
-import org.apache.axis2.databinding.DeserializationTarget;
-import org.apache.axis2.databinding.Serializer;
-import org.apache.axis2.databinding.serializers.CollectionSerializer;
-
-import javax.xml.namespace.QName;
-
-/**
- * ElementDesc
- */
-public class ElementDesc extends FieldDesc {
- protected IndexedFieldAccessor indexedAccessor;
- protected QName itemQName;
-
- class FieldTarget implements DeserializationTarget {
- Object targetObject;
- FieldAccessor accessor;
-
- public FieldTarget(Object targetObject, FieldAccessor accessor) {
- this.targetObject = targetObject;
- this.accessor = accessor;
- }
-
- public void setValue(Object value) throws Exception {
- accessor.setValue(targetObject, value);
- }
- }
-
- protected int minOccurs = 0;
-
- // Might seem strange to default this to zero, but we do it because
- // we want to be able to tell in BeanManager.fillInTypeDesc() if someone
- // set this manually or not. If it's still zero in there (meaning default
- // values are good) we'll set it to 1 for a normal field and -1 (unbounded)
- // for a collection field.
- protected int maxOccurs = 0;
-
- public int getMinOccurs() {
- return minOccurs;
- }
-
- public void setMinOccurs(int minOccurs) {
- this.minOccurs = minOccurs;
- }
-
- public int getMaxOccurs() {
- return maxOccurs;
- }
-
- public void setMaxOccurs(int maxOccurs) {
- this.maxOccurs = maxOccurs;
- }
-
- public QName getItemQName() {
- return itemQName;
- }
-
- public void setItemQName(QName itemQName) {
- this.itemQName = itemQName;
- }
-
- public Deserializer getDeserializer(int index, Object targetObject) {
- if (index > maxOccurs && maxOccurs > -1) {
- throw new RuntimeException("Too many elements (maxOccurs = " +
- maxOccurs + ") called " + qname + " !");
- }
-
- Deserializer dser = deserializerFactory.getDeserializer();
- FieldAccessor accessor;
- if (maxOccurs > 1 || maxOccurs == -1) {
- accessor = new IndexedAccessorWrapper(indexedAccessor, index);
- } else {
- accessor = this.accessor;
- }
-
- dser.setTarget(new FieldTarget(targetObject, accessor));
-
- return dser;
- }
-
- public Serializer getSerializer() {
- if (maxOccurs > 1 || maxOccurs == -1) {
- if (itemQName != null) {
- return new CollectionSerializer(itemQName,
- true,
- super.getSerializer());
- } else {
- return new CollectionSerializer(qname,
- false,
- super.getSerializer());
- }
- }
- return super.getSerializer();
- }
-
- public void setIndexedAccessor(IndexedFieldAccessor indexedAccessor) {
- this.indexedAccessor = indexedAccessor;
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.metadata;
+
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.DeserializationTarget;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.serializers.CollectionSerializer;
+
+import javax.xml.namespace.QName;
+
+/**
+ * ElementDesc
+ */
+public class ElementDesc extends FieldDesc {
+ protected IndexedFieldAccessor indexedAccessor;
+ protected QName itemQName;
+
+ class FieldTarget implements DeserializationTarget {
+ Object targetObject;
+ FieldAccessor accessor;
+
+ public FieldTarget(Object targetObject, FieldAccessor accessor) {
+ this.targetObject = targetObject;
+ this.accessor = accessor;
+ }
+
+ public void setValue(Object value) throws Exception {
+ accessor.setValue(targetObject, value);
+ }
+ }
+
+ protected int minOccurs = 0;
+
+ // Might seem strange to default this to zero, but we do it because
+ // we want to be able to tell in BeanManager.fillInTypeDesc() if someone
+ // set this manually or not. If it's still zero in there (meaning default
+ // values are good) we'll set it to 1 for a normal field and -1 (unbounded)
+ // for a collection field.
+ protected int maxOccurs = 0;
+
+ public int getMinOccurs() {
+ return minOccurs;
+ }
+
+ public void setMinOccurs(int minOccurs) {
+ this.minOccurs = minOccurs;
+ }
+
+ public int getMaxOccurs() {
+ return maxOccurs;
+ }
+
+ public void setMaxOccurs(int maxOccurs) {
+ this.maxOccurs = maxOccurs;
+ }
+
+ public QName getItemQName() {
+ return itemQName;
+ }
+
+ public void setItemQName(QName itemQName) {
+ this.itemQName = itemQName;
+ }
+
+ public Deserializer getDeserializer(int index, Object targetObject) {
+ if (index > maxOccurs && maxOccurs > -1) {
+ throw new RuntimeException("Too many elements (maxOccurs = " +
+ maxOccurs + ") called " + qname + " !");
+ }
+
+ Deserializer dser = deserializerFactory.getDeserializer();
+ FieldAccessor accessor;
+ if (maxOccurs > 1 || maxOccurs == -1) {
+ accessor = new IndexedAccessorWrapper(indexedAccessor, index);
+ } else {
+ accessor = this.accessor;
+ }
+
+ dser.setTarget(new FieldTarget(targetObject, accessor));
+
+ return dser;
+ }
+
+ public Serializer getSerializer() {
+ if (maxOccurs > 1 || maxOccurs == -1) {
+ if (itemQName != null) {
+ return new CollectionSerializer(itemQName,
+ true,
+ super.getSerializer());
+ } else {
+ return new CollectionSerializer(qname,
+ false,
+ super.getSerializer());
+ }
+ }
+ return super.getSerializer();
+ }
+
+ public void setIndexedAccessor(IndexedFieldAccessor indexedAccessor) {
+ this.indexedAccessor = indexedAccessor;
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/ElementDesc.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldAccessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldAccessor.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldAccessor.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldAccessor.java Thu Sep 15 11:52:11 2005
@@ -1,24 +1,24 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.metadata;
-
-/**
- * FieldAccessor
- */
-public interface FieldAccessor {
- public Object getValue(Object targetObject) throws Exception;
- public void setValue(Object targetObject, Object value) throws Exception;
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.metadata;
+
+/**
+ * FieldAccessor
+ */
+public interface FieldAccessor {
+ public Object getValue(Object targetObject) throws Exception;
+ public void setValue(Object targetObject, Object value) throws Exception;
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldAccessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldDesc.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldDesc.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldDesc.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldDesc.java Thu Sep 15 11:52:11 2005
@@ -1,91 +1,91 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.metadata;
-
-import org.apache.axis2.databinding.Deserializer;
-import org.apache.axis2.databinding.Serializer;
-import org.apache.axis2.databinding.DeserializerFactory;
-
-import javax.xml.namespace.QName;
-
-/**
- * FieldDesc
- */
-public abstract class FieldDesc implements FieldAccessor {
- protected QName qname;
- protected FieldAccessor accessor;
- protected DeserializerFactory deserializerFactory;
- protected Serializer ser;
- protected String fieldName;
-
- public String getFieldName() {
- return fieldName;
- }
-
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
-
- public QName getQName() {
- return qname;
- }
-
- public void setQName(QName qname) {
- this.qname = qname;
- }
-
- public FieldAccessor getAccessor() {
- return accessor;
- }
-
- public void setAccessor(FieldAccessor accessor) {
- this.accessor = accessor;
- }
-
- public Object getValue(Object targetObject) throws Exception {
- return accessor.getValue(targetObject);
- }
-
- public void setValue(Object targetObject, Object value) throws Exception {
- accessor.setValue(targetObject, value);
- }
-
- public Serializer getSerializer() {
- return ser;
- }
-
- public void setSerializer(Serializer ser) {
- this.ser = ser;
- }
-
- Serializer getRawSerializer() {
- return ser;
- }
-
- public Deserializer getDeserializer(int index) {
- if (index > 0)
- throw new RuntimeException("Only one element " + qname + " allowed");
- return deserializerFactory.getDeserializer();
- }
-
- public void setDeserializerFactory(DeserializerFactory deser) {
- this.deserializerFactory = deser;
- }
-
- public DeserializerFactory getDeserializerFactory() {
- return deserializerFactory;
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.metadata;
+
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.DeserializerFactory;
+
+import javax.xml.namespace.QName;
+
+/**
+ * FieldDesc
+ */
+public abstract class FieldDesc implements FieldAccessor {
+ protected QName qname;
+ protected FieldAccessor accessor;
+ protected DeserializerFactory deserializerFactory;
+ protected Serializer ser;
+ protected String fieldName;
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ public QName getQName() {
+ return qname;
+ }
+
+ public void setQName(QName qname) {
+ this.qname = qname;
+ }
+
+ public FieldAccessor getAccessor() {
+ return accessor;
+ }
+
+ public void setAccessor(FieldAccessor accessor) {
+ this.accessor = accessor;
+ }
+
+ public Object getValue(Object targetObject) throws Exception {
+ return accessor.getValue(targetObject);
+ }
+
+ public void setValue(Object targetObject, Object value) throws Exception {
+ accessor.setValue(targetObject, value);
+ }
+
+ public Serializer getSerializer() {
+ return ser;
+ }
+
+ public void setSerializer(Serializer ser) {
+ this.ser = ser;
+ }
+
+ Serializer getRawSerializer() {
+ return ser;
+ }
+
+ public Deserializer getDeserializer(int index) {
+ if (index > 0)
+ throw new RuntimeException("Only one element " + qname + " allowed");
+ return deserializerFactory.getDeserializer();
+ }
+
+ public void setDeserializerFactory(DeserializerFactory deser) {
+ this.deserializerFactory = deser;
+ }
+
+ public DeserializerFactory getDeserializerFactory() {
+ return deserializerFactory;
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/FieldDesc.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java Thu Sep 15 11:52:11 2005
@@ -1,37 +1,37 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.metadata;
-
-/**
- * IndexedAccessorWrapper
- */
-public class IndexedAccessorWrapper implements FieldAccessor {
- IndexedFieldAccessor accessor;
- int index;
-
- public IndexedAccessorWrapper(IndexedFieldAccessor accessor, int index) {
- this.accessor = accessor;
- this.index = index;
- }
-
- public Object getValue(Object targetObject) throws Exception {
- return accessor.getIndexedValue(targetObject, index);
- }
-
- public void setValue(Object targetObject, Object value) throws Exception {
- accessor.setIndexedValue(targetObject, value, index);
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.metadata;
+
+/**
+ * IndexedAccessorWrapper
+ */
+public class IndexedAccessorWrapper implements FieldAccessor {
+ IndexedFieldAccessor accessor;
+ int index;
+
+ public IndexedAccessorWrapper(IndexedFieldAccessor accessor, int index) {
+ this.accessor = accessor;
+ this.index = index;
+ }
+
+ public Object getValue(Object targetObject) throws Exception {
+ return accessor.getIndexedValue(targetObject, index);
+ }
+
+ public void setValue(Object targetObject, Object value) throws Exception {
+ accessor.setIndexedValue(targetObject, value, index);
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java Thu Sep 15 11:52:11 2005
@@ -1,29 +1,29 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.metadata;
-
-/**
- * IndexedFieldAccessor
- */
-public interface IndexedFieldAccessor {
- public Object getIndexedValue(Object targetObject, int index)
- throws Exception;
-
- public void setIndexedValue(Object targetObject,
- Object value,
- int index) throws Exception;
-
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.metadata;
+
+/**
+ * IndexedFieldAccessor
+ */
+public interface IndexedFieldAccessor {
+ public Object getIndexedValue(Object targetObject, int index)
+ throws Exception;
+
+ public void setIndexedValue(Object targetObject,
+ Object value,
+ int index) throws Exception;
+
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/TypeDesc.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/TypeDesc.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/TypeDesc.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/TypeDesc.java Thu Sep 15 11:52:11 2005
@@ -1,109 +1,109 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.metadata;
-
-import org.apache.axis2.util.MethodCache;
-
-import javax.xml.namespace.QName;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.lang.reflect.Method;
-
-/**
- * TypeDesc
- */
-public class TypeDesc {
- public static final Class [] noClasses = new Class [] {};
- public static final Object[] noObjects = new Object[] {};
-
- /** A map of class -> TypeDesc */
- private static Map classMap = new Hashtable();
-
- /**
- * Static function for centralizing access to type metadata for a
- * given class.
- *
- * This checks for a static getTypeDesc() method on the
- * class or _Helper class.
- * Eventually we may extend this to provide for external
- * metadata config (via files sitting in the classpath, etc).
- *
- */
- public static TypeDesc getTypeDescForClass(Class cls)
- {
- // First see if we have one explicitly registered
- // or cached from previous lookup
- TypeDesc result = (TypeDesc)classMap.get(cls);
-
- if (result == null) {
- try {
- Method getTypeDesc =
- MethodCache.getInstance().getMethod(cls,
- "getTypeDesc",
- noClasses);
- if (getTypeDesc != null) {
- result = (TypeDesc)getTypeDesc.invoke(null, noObjects);
- if (result != null) {
- classMap.put(cls, result);
- }
- }
- } catch (Exception e) {
- }
- }
-
- return result;
- }
-
- Map elements = new HashMap();
- Map fieldsByName = new HashMap();
- Map attrs = new HashMap();
- Class javaClass;
-
- public Iterator getAttributeDescs() {
- return attrs.values().iterator();
- }
-
- public void addField(ElementDesc fieldDesc) {
- elements.put(fieldDesc.getQName(), fieldDesc);
- fieldsByName.put(fieldDesc.getFieldName(), fieldDesc);
- }
-
- public void addField(AttributeDesc fieldDesc) {
- attrs.put(fieldDesc.getQName(), fieldDesc);
- }
-
- public ElementDesc getElementDesc(QName qname) {
- return (ElementDesc)elements.get(qname);
- }
-
- public ElementDesc getElementDesc(String fieldName) {
- return (ElementDesc)fieldsByName.get(fieldName);
- }
-
- public Iterator getElementDescs() {
- return elements.values().iterator();
- }
-
- public Class getJavaClass() {
- return javaClass;
- }
-
- public void setJavaClass(Class javaClass) {
- this.javaClass = javaClass;
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.metadata;
+
+import org.apache.axis2.util.MethodCache;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.lang.reflect.Method;
+
+/**
+ * TypeDesc
+ */
+public class TypeDesc {
+ public static final Class [] noClasses = new Class [] {};
+ public static final Object[] noObjects = new Object[] {};
+
+ /** A map of class -> TypeDesc */
+ private static Map classMap = new Hashtable();
+
+ /**
+ * Static function for centralizing access to type metadata for a
+ * given class.
+ *
+ * This checks for a static getTypeDesc() method on the
+ * class or _Helper class.
+ * Eventually we may extend this to provide for external
+ * metadata config (via files sitting in the classpath, etc).
+ *
+ */
+ public static TypeDesc getTypeDescForClass(Class cls)
+ {
+ // First see if we have one explicitly registered
+ // or cached from previous lookup
+ TypeDesc result = (TypeDesc)classMap.get(cls);
+
+ if (result == null) {
+ try {
+ Method getTypeDesc =
+ MethodCache.getInstance().getMethod(cls,
+ "getTypeDesc",
+ noClasses);
+ if (getTypeDesc != null) {
+ result = (TypeDesc)getTypeDesc.invoke(null, noObjects);
+ if (result != null) {
+ classMap.put(cls, result);
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ return result;
+ }
+
+ Map elements = new HashMap();
+ Map fieldsByName = new HashMap();
+ Map attrs = new HashMap();
+ Class javaClass;
+
+ public Iterator getAttributeDescs() {
+ return attrs.values().iterator();
+ }
+
+ public void addField(ElementDesc fieldDesc) {
+ elements.put(fieldDesc.getQName(), fieldDesc);
+ fieldsByName.put(fieldDesc.getFieldName(), fieldDesc);
+ }
+
+ public void addField(AttributeDesc fieldDesc) {
+ attrs.put(fieldDesc.getQName(), fieldDesc);
+ }
+
+ public ElementDesc getElementDesc(QName qname) {
+ return (ElementDesc)elements.get(qname);
+ }
+
+ public ElementDesc getElementDesc(String fieldName) {
+ return (ElementDesc)fieldsByName.get(fieldName);
+ }
+
+ public Iterator getElementDescs() {
+ return elements.values().iterator();
+ }
+
+ public Class getJavaClass() {
+ return javaClass;
+ }
+
+ public void setJavaClass(Class javaClass) {
+ this.javaClass = javaClass;
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/metadata/TypeDesc.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java Thu Sep 15 11:52:11 2005
@@ -1,31 +1,31 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.serializers;
-
-import org.apache.axis2.databinding.Serializer;
-import org.apache.axis2.databinding.SerializationContext;
-
-/**
- * AbstractSerializer
- */
-public abstract class AbstractSerializer implements Serializer {
- public void serialize(Object object, SerializationContext context)
- throws Exception {
- if (!context.checkMultiref(object, this)) {
- serializeData(object, context);
- }
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.serializers;
+
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.SerializationContext;
+
+/**
+ * AbstractSerializer
+ */
+public abstract class AbstractSerializer implements Serializer {
+ public void serialize(Object object, SerializationContext context)
+ throws Exception {
+ if (!context.checkMultiref(object, this)) {
+ serializeData(object, context);
+ }
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/BeanSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/BeanSerializer.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/BeanSerializer.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/BeanSerializer.java Thu Sep 15 11:52:11 2005
@@ -1,51 +1,51 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.serializers;
-
-import org.apache.axis2.databinding.SerializationContext;
-import org.apache.axis2.databinding.Serializer;
-import org.apache.axis2.databinding.metadata.ElementDesc;
-import org.apache.axis2.databinding.metadata.TypeDesc;
-
-import javax.xml.namespace.QName;
-import java.util.Iterator;
-
-/**
- * BeanSerializer
- */
-public class BeanSerializer extends AbstractSerializer {
- TypeDesc typeDesc;
-
- public BeanSerializer(TypeDesc typeDesc) {
- this.typeDesc = typeDesc;
- }
-
- public void serializeData(Object object, SerializationContext context)
- throws Exception {
- // Write any attributes that need writing here
-
- Iterator elements = typeDesc.getElementDescs();
- while (elements.hasNext()) {
- ElementDesc desc = (ElementDesc) elements.next();
- Object fieldValue = desc.getValue(object);
- Serializer ser = desc.getSerializer();
- QName qname = desc.getQName();
- context.serializeElement(qname, fieldValue, ser);
- }
-
- context.getWriter().writeEndElement();
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.serializers;
+
+import org.apache.axis2.databinding.SerializationContext;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.metadata.ElementDesc;
+import org.apache.axis2.databinding.metadata.TypeDesc;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * BeanSerializer
+ */
+public class BeanSerializer extends AbstractSerializer {
+ TypeDesc typeDesc;
+
+ public BeanSerializer(TypeDesc typeDesc) {
+ this.typeDesc = typeDesc;
+ }
+
+ public void serializeData(Object object, SerializationContext context)
+ throws Exception {
+ // Write any attributes that need writing here
+
+ Iterator elements = typeDesc.getElementDescs();
+ while (elements.hasNext()) {
+ ElementDesc desc = (ElementDesc) elements.next();
+ Object fieldValue = desc.getValue(object);
+ Serializer ser = desc.getSerializer();
+ QName qname = desc.getQName();
+ context.serializeElement(qname, fieldValue, ser);
+ }
+
+ context.getWriter().writeEndElement();
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/BeanSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java Thu Sep 15 11:52:11 2005
@@ -1,94 +1,94 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.serializers;
-
-import org.apache.axis2.databinding.Serializer;
-import org.apache.axis2.databinding.SerializationContext;
-import org.apache.axis2.databinding.utils.Converter;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamWriter;
-import java.lang.reflect.Array;
-import java.util.Collection;
-
-/**
- * CollectionSerializer
- */
-public class CollectionSerializer extends AbstractSerializer {
- public final QName DEFAULT_ITEM_QNAME = new QName("item");
-
- boolean isWrapped;
- QName itemQName;
- Serializer serializer;
-
- public CollectionSerializer(QName itemQName,
- boolean isWrapped,
- Serializer serializer) {
- this.isWrapped = isWrapped;
- this.itemQName = itemQName == null ? DEFAULT_ITEM_QNAME : itemQName;
- this.serializer = serializer;
- }
-
- public void serialize(Object object, SerializationContext context) throws Exception {
- if (isWrapped) {
- // We have a wrapper element, so it's fine to do multiref checking
- // on the actual collection object
- super.serialize(object, context);
- return;
- }
-
- // No wrapper, so need to do multiref checks on individual elements.
- serializeData(object, context);
- }
-
- public void serializeData(Object object, SerializationContext context)
- throws Exception {
- if (object instanceof Collection) {
- Converter.convert(object, Object[].class);
- }
- XMLStreamWriter writer = context.getWriter();
- if (isWrapped) {
- writer.writeStartElement(itemQName.getNamespaceURI(),
- itemQName.getLocalPart());
- }
-
- int len = Array.getLength(object);
- for (int i = 0; i < len; i++) {
- Object item = Array.get(object, i);
- if (i == 0) {
- if (isWrapped) {
- if (!context.checkMultiref(item, serializer)) {
- serializer.serializeData(item, context);
- }
- } else {
- serializer.serializeData(item, context);
- }
- } else {
- context.serializeElement(itemQName, item, serializer);
- }
- }
-
-// Collection coll = (Collection)object;
-// for (Iterator i = coll.iterator(); i.hasNext();) {
-// Object item = i.next();
-// context.serializeElement(itemQName, item, serializer);
-// }
-
- if (isWrapped) {
- writer.writeEndElement();
- }
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.serializers;
+
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.SerializationContext;
+import org.apache.axis2.databinding.utils.Converter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamWriter;
+import java.lang.reflect.Array;
+import java.util.Collection;
+
+/**
+ * CollectionSerializer
+ */
+public class CollectionSerializer extends AbstractSerializer {
+ public final QName DEFAULT_ITEM_QNAME = new QName("item");
+
+ boolean isWrapped;
+ QName itemQName;
+ Serializer serializer;
+
+ public CollectionSerializer(QName itemQName,
+ boolean isWrapped,
+ Serializer serializer) {
+ this.isWrapped = isWrapped;
+ this.itemQName = itemQName == null ? DEFAULT_ITEM_QNAME : itemQName;
+ this.serializer = serializer;
+ }
+
+ public void serialize(Object object, SerializationContext context) throws Exception {
+ if (isWrapped) {
+ // We have a wrapper element, so it's fine to do multiref checking
+ // on the actual collection object
+ super.serialize(object, context);
+ return;
+ }
+
+ // No wrapper, so need to do multiref checks on individual elements.
+ serializeData(object, context);
+ }
+
+ public void serializeData(Object object, SerializationContext context)
+ throws Exception {
+ if (object instanceof Collection) {
+ Converter.convert(object, Object[].class);
+ }
+ XMLStreamWriter writer = context.getWriter();
+ if (isWrapped) {
+ writer.writeStartElement(itemQName.getNamespaceURI(),
+ itemQName.getLocalPart());
+ }
+
+ int len = Array.getLength(object);
+ for (int i = 0; i < len; i++) {
+ Object item = Array.get(object, i);
+ if (i == 0) {
+ if (isWrapped) {
+ if (!context.checkMultiref(item, serializer)) {
+ serializer.serializeData(item, context);
+ }
+ } else {
+ serializer.serializeData(item, context);
+ }
+ } else {
+ context.serializeElement(itemQName, item, serializer);
+ }
+ }
+
+// Collection coll = (Collection)object;
+// for (Iterator i = coll.iterator(); i.hasNext();) {
+// Object item = i.next();
+// context.serializeElement(itemQName, item, serializer);
+// }
+
+ if (isWrapped) {
+ writer.writeEndElement();
+ }
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java Thu Sep 15 11:52:11 2005
@@ -1,73 +1,73 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.serializers;
-
-import org.apache.axis2.databinding.SerializationContext;
-
-import javax.xml.namespace.QName;
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
-
-/**
- * SimpleSerializer
- */
-public class SimpleSerializer extends AbstractSerializer {
- private static SimpleDateFormat zulu =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- // 0123456789 0 123456789
-
- static {
- zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
-
- public void serialize(Object object, SerializationContext context) throws Exception {
- // Simple types never get multiref'd, so just write the data now.
- serializeData(object, context);
- }
-
- public void serializeData(Object object, SerializationContext context)
- throws Exception {
- String value = object.toString();
- context.getWriter().writeCharacters(value);
- context.getWriter().writeEndElement();
- }
-
- public String getValueAsString(Object value, SerializationContext context) {
- // We could have separate serializers/deserializers to take
- // care of Float/Double cases, but it makes more sence to
- // put them here with the rest of the java lang primitives.
- if (value instanceof Float ||
- value instanceof Double) {
- double data = 0.0;
- if (value instanceof Float) {
- data = ((Float) value).doubleValue();
- } else {
- data = ((Double) value).doubleValue();
- }
- if (Double.isNaN(data)) {
- return "NaN";
- } else if (data == Double.POSITIVE_INFINITY) {
- return "INF";
- } else if (data == Double.NEGATIVE_INFINITY) {
- return "-INF";
- }
- } else if (value instanceof QName) {
- return context.qName2String((QName)value);
- }
-
- return value.toString();
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.serializers;
+
+import org.apache.axis2.databinding.SerializationContext;
+
+import javax.xml.namespace.QName;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+/**
+ * SimpleSerializer
+ */
+public class SimpleSerializer extends AbstractSerializer {
+ private static SimpleDateFormat zulu =
+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ // 0123456789 0 123456789
+
+ static {
+ zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+
+ public void serialize(Object object, SerializationContext context) throws Exception {
+ // Simple types never get multiref'd, so just write the data now.
+ serializeData(object, context);
+ }
+
+ public void serializeData(Object object, SerializationContext context)
+ throws Exception {
+ String value = object.toString();
+ context.getWriter().writeCharacters(value);
+ context.getWriter().writeEndElement();
+ }
+
+ public String getValueAsString(Object value, SerializationContext context) {
+ // We could have separate serializers/deserializers to take
+ // care of Float/Double cases, but it makes more sence to
+ // put them here with the rest of the java lang primitives.
+ if (value instanceof Float ||
+ value instanceof Double) {
+ double data = 0.0;
+ if (value instanceof Float) {
+ data = ((Float) value).doubleValue();
+ } else {
+ data = ((Double) value).doubleValue();
+ }
+ if (Double.isNaN(data)) {
+ return "NaN";
+ } else if (data == Double.POSITIVE_INFINITY) {
+ return "INF";
+ } else if (data == Double.NEGATIVE_INFINITY) {
+ return "-INF";
+ }
+ } else if (value instanceof QName) {
+ return context.qName2String((QName)value);
+ }
+
+ return value.toString();
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java (original)
+++ webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java Thu Sep 15 11:52:11 2005
@@ -1,127 +1,127 @@
-/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.axis2.databinding.typemapping;
-
-import org.apache.axis2.databinding.metadata.BeanManager;
-import org.apache.axis2.databinding.DeserializerFactory;
-import org.apache.axis2.databinding.Serializer;
-import org.apache.axis2.databinding.metadata.BeanManager;
-import org.apache.axis2.databinding.deserializers.BeanDeserializerFactory;
-import org.apache.axis2.databinding.deserializers.SimpleDeserializerFactory;
-import org.apache.axis2.databinding.serializers.BeanSerializer;
-import org.apache.axis2.databinding.serializers.SimpleSerializer;
-import org.apache.axis.xsd.Constants;
-import org.w3c.dom.Element;
-
-import javax.xml.namespace.QName;
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * TypeMappingRegistry
- */
-public class TypeMappingRegistry {
- public static boolean isPrimitive(Object value) {
- if (value == null) return true;
-
- Class javaType = (value instanceof Class) ? (Class)value :
- value.getClass();
-
- if (javaType.isPrimitive()) return true;
-
- if (javaType == String.class) return true;
- if (Calendar.class.isAssignableFrom(javaType)) return true;
- if (Date.class.isAssignableFrom(javaType)) return true;
-// if (HexBinary.class.isAssignableFrom(javaType)) return true;
- if (Element.class.isAssignableFrom(javaType)) return true;
- if (javaType == byte[].class) return true;
- if (Number.class.isAssignableFrom(javaType)) return true;
-
- // There has been discussion as to whether arrays themselves should
- // be regarded as multi-ref.
- // Here are the three options:
- // 1) Arrays are full-fledged Objects and therefore should always be
- // multi-ref'd (Pro: This is like java. Con: Some runtimes don't
- // support this yet, and it requires more stuff to be passed over the wire.)
- // 2) Arrays are not full-fledged Objects and therefore should
- // always be passed as single ref (note the elements of the array
- // may be multi-ref'd.) (Pro: This seems reasonable, if a user
- // wants multi-referencing put the array in a container. Also
- // is more interop compatible. Con: Not like java serialization.)
- // 3) Arrays of primitives should be single ref, and arrays of
- // non-primitives should be multi-ref. (Pro: Takes care of the
- // looping case. Con: Seems like an obtuse rule.)
- //
- // Changing the code from (1) to (2) to see if interop fairs better.
- if (javaType.isArray()) return true;
-
- return false;
- }
-
- public DeserializerFactory getDeserializerFactory(Class cls) {
- if (isPrimitive(cls)) {
- return new SimpleDeserializerFactory(cls, new QName("xsd", cls.getName()));
- }
-
- return new BeanDeserializerFactory(BeanManager.getTypeDesc(cls));
- }
-
- public Serializer getSerializer(Class cls) {
- if (isPrimitive(cls)) {
- return new SimpleSerializer();
- }
-
- return new BeanSerializer(BeanManager.getTypeDesc(cls));
- }
-
- public void registerMapping(Class javaType,
- QName xmlType,
- Serializer serializer,
- DeserializerFactory deserFactory) {
-
- }
-
- public void initializeSchemaTypes() {
- myRegisterSimple(Constants.XSD_STRING, java.lang.String.class);
- myRegisterSimple(Constants.XSD_BOOLEAN, java.lang.Boolean.class);
- myRegisterSimple(Constants.XSD_DOUBLE, java.lang.Double.class);
- myRegisterSimple(Constants.XSD_FLOAT, java.lang.Float.class);
- myRegisterSimple(Constants.XSD_INT, java.lang.Integer.class);
- myRegisterSimple(Constants.XSD_INTEGER, java.math.BigInteger.class
- );
- myRegisterSimple(Constants.XSD_DECIMAL, java.math.BigDecimal.class
- );
- myRegisterSimple(Constants.XSD_LONG, java.lang.Long.class);
- myRegisterSimple(Constants.XSD_SHORT, java.lang.Short.class);
- myRegisterSimple(Constants.XSD_BYTE, java.lang.Byte.class);
-
- // The XSD Primitives are mapped to java primitives.
- myRegisterSimple(Constants.XSD_BOOLEAN, boolean.class);
- myRegisterSimple(Constants.XSD_DOUBLE, double.class);
- myRegisterSimple(Constants.XSD_FLOAT, float.class);
- myRegisterSimple(Constants.XSD_INT, int.class);
- myRegisterSimple(Constants.XSD_LONG, long.class);
- myRegisterSimple(Constants.XSD_SHORT, short.class);
- myRegisterSimple(Constants.XSD_BYTE, byte.class);
- }
-
- private void myRegisterSimple(QName xmlType, Class javaType) {
- DeserializerFactory dser = new SimpleDeserializerFactory(javaType,
- xmlType);
- Serializer ser = new SimpleSerializer();
- registerMapping(javaType, xmlType, ser, dser);
- }
-}
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.axis2.databinding.typemapping;
+
+import org.apache.axis2.databinding.metadata.BeanManager;
+import org.apache.axis2.databinding.DeserializerFactory;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.metadata.BeanManager;
+import org.apache.axis2.databinding.deserializers.BeanDeserializerFactory;
+import org.apache.axis2.databinding.deserializers.SimpleDeserializerFactory;
+import org.apache.axis2.databinding.serializers.BeanSerializer;
+import org.apache.axis2.databinding.serializers.SimpleSerializer;
+import org.apache.axis.xsd.Constants;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * TypeMappingRegistry
+ */
+public class TypeMappingRegistry {
+ public static boolean isPrimitive(Object value) {
+ if (value == null) return true;
+
+ Class javaType = (value instanceof Class) ? (Class)value :
+ value.getClass();
+
+ if (javaType.isPrimitive()) return true;
+
+ if (javaType == String.class) return true;
+ if (Calendar.class.isAssignableFrom(javaType)) return true;
+ if (Date.class.isAssignableFrom(javaType)) return true;
+// if (HexBinary.class.isAssignableFrom(javaType)) return true;
+ if (Element.class.isAssignableFrom(javaType)) return true;
+ if (javaType == byte[].class) return true;
+ if (Number.class.isAssignableFrom(javaType)) return true;
+
+ // There has been discussion as to whether arrays themselves should
+ // be regarded as multi-ref.
+ // Here are the three options:
+ // 1) Arrays are full-fledged Objects and therefore should always be
+ // multi-ref'd (Pro: This is like java. Con: Some runtimes don't
+ // support this yet, and it requires more stuff to be passed over the wire.)
+ // 2) Arrays are not full-fledged Objects and therefore should
+ // always be passed as single ref (note the elements of the array
+ // may be multi-ref'd.) (Pro: This seems reasonable, if a user
+ // wants multi-referencing put the array in a container. Also
+ // is more interop compatible. Con: Not like java serialization.)
+ // 3) Arrays of primitives should be single ref, and arrays of
+ // non-primitives should be multi-ref. (Pro: Takes care of the
+ // looping case. Con: Seems like an obtuse rule.)
+ //
+ // Changing the code from (1) to (2) to see if interop fairs better.
+ if (javaType.isArray()) return true;
+
+ return false;
+ }
+
+ public DeserializerFactory getDeserializerFactory(Class cls) {
+ if (isPrimitive(cls)) {
+ return new SimpleDeserializerFactory(cls, new QName("xsd", cls.getName()));
+ }
+
+ return new BeanDeserializerFactory(BeanManager.getTypeDesc(cls));
+ }
+
+ public Serializer getSerializer(Class cls) {
+ if (isPrimitive(cls)) {
+ return new SimpleSerializer();
+ }
+
+ return new BeanSerializer(BeanManager.getTypeDesc(cls));
+ }
+
+ public void registerMapping(Class javaType,
+ QName xmlType,
+ Serializer serializer,
+ DeserializerFactory deserFactory) {
+
+ }
+
+ public void initializeSchemaTypes() {
+ myRegisterSimple(Constants.XSD_STRING, java.lang.String.class);
+ myRegisterSimple(Constants.XSD_BOOLEAN, java.lang.Boolean.class);
+ myRegisterSimple(Constants.XSD_DOUBLE, java.lang.Double.class);
+ myRegisterSimple(Constants.XSD_FLOAT, java.lang.Float.class);
+ myRegisterSimple(Constants.XSD_INT, java.lang.Integer.class);
+ myRegisterSimple(Constants.XSD_INTEGER, java.math.BigInteger.class
+ );
+ myRegisterSimple(Constants.XSD_DECIMAL, java.math.BigDecimal.class
+ );
+ myRegisterSimple(Constants.XSD_LONG, java.lang.Long.class);
+ myRegisterSimple(Constants.XSD_SHORT, java.lang.Short.class);
+ myRegisterSimple(Constants.XSD_BYTE, java.lang.Byte.class);
+
+ // The XSD Primitives are mapped to java primitives.
+ myRegisterSimple(Constants.XSD_BOOLEAN, boolean.class);
+ myRegisterSimple(Constants.XSD_DOUBLE, double.class);
+ myRegisterSimple(Constants.XSD_FLOAT, float.class);
+ myRegisterSimple(Constants.XSD_INT, int.class);
+ myRegisterSimple(Constants.XSD_LONG, long.class);
+ myRegisterSimple(Constants.XSD_SHORT, short.class);
+ myRegisterSimple(Constants.XSD_BYTE, byte.class);
+ }
+
+ private void myRegisterSimple(QName xmlType, Class javaType) {
+ DeserializerFactory dser = new SimpleDeserializerFactory(javaType,
+ xmlType);
+ Serializer ser = new SimpleSerializer();
+ registerMapping(javaType, xmlType, ser, dser);
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/databinding/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native