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 gd...@apache.org on 2007/03/29 20:49:16 UTC
svn commit: r523794 [4/8] - in /webservices/axis2/trunk/java/modules:
adb/src/org/apache/axis2/databinding/
adb/src/org/apache/axis2/databinding/i18n/
adb/src/org/apache/axis2/databinding/typemapping/
adb/src/org/apache/axis2/databinding/types/ adb/src...
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Union.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Union.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Union.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Union.java Thu Mar 29 11:49:12 2007
@@ -18,15 +18,12 @@
import org.apache.axis2.databinding.utils.ConverterUtil;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamException;
import javax.xml.namespace.QName;
-import java.util.Date;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
-/**
- * this class is the super class of all the union simple types
- */
+/** this class is the super class of all the union simple types */
public abstract class Union {
// object to store values
protected Object localObject;
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedByte.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedByte.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedByte.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedByte.java Thu Mar 29 11:49:12 2007
@@ -16,7 +16,6 @@
package org.apache.axis2.databinding.types;
-
/**
* Custom class for supporting primitive XSD data type UnsignedByte
*
@@ -27,24 +26,24 @@
private static final long serialVersionUID = 4631754787145526759L;
- public UnsignedByte() {
+ public UnsignedByte() {
}
/**
* ctor for UnsignedByte
- * @exception Exception will be thrown if validation fails
+ *
+ * @throws Exception will be thrown if validation fails
*/
public UnsignedByte(long sValue) throws NumberFormatException {
- setValue(sValue);
+ setValue(sValue);
}
public UnsignedByte(String sValue) throws NumberFormatException {
- setValue(Long.parseLong(sValue));
+ setValue(Long.parseLong(sValue));
}
/**
- *
* validates the data and sets the value for the object.
*
* @param sValue the number to set
@@ -52,14 +51,14 @@
public void setValue(long sValue) throws NumberFormatException {
if (!UnsignedByte.isValid(sValue))
throw new NumberFormatException(
- // Messages.getMessage("badUnsignedByte00") +
+ // Messages.getMessage("badUnsignedByte00") +
String.valueOf(sValue) + "]");
lValue = new Long(sValue);
}
/**
- *
* validate the value against the xsd value space definition
+ *
* @param sValue number to check against range
*/
public static boolean isValid(long sValue) {
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedInt.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedInt.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedInt.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedInt.java Thu Mar 29 11:49:12 2007
@@ -16,8 +16,6 @@
package org.apache.axis2.databinding.types;
-
-
/**
* Custom class for supporting primitive XSD data type UnsignedInt
*
@@ -26,66 +24,63 @@
public class UnsignedInt extends java.lang.Number {
private static final long serialVersionUID = -8915204168154746305L;
-
- protected Long lValue = new Long(0);
+
+ protected Long lValue = new Long(0);
public UnsignedInt() {
}
/**
* ctor for UnsignedInt
- * @exception NumberFormatException will be thrown if validation fails
+ *
+ * @throws NumberFormatException will be thrown if validation fails
*/
public UnsignedInt(long iValue) throws NumberFormatException {
- setValue(iValue);
+ setValue(iValue);
}
public UnsignedInt(String stValue) throws NumberFormatException {
- setValue(Long.parseLong(stValue));
+ setValue(Long.parseLong(stValue));
}
/**
- *
* validates the data and sets the value for the object.
*
* @param iValue value
*/
public void setValue(long iValue) throws NumberFormatException {
- if (!UnsignedInt.isValid(iValue))
+ if (!UnsignedInt.isValid(iValue))
throw new NumberFormatException(
// Messages.getMessage("badUnsignedInt00") +
- String.valueOf(iValue) + "]");
- lValue = new Long(iValue);
+String.valueOf(iValue) + "]");
+ lValue = new Long(iValue);
}
- public String toString(){
- if (lValue != null)
- return lValue.toString();
- else
- return null;
- }
-
- public int hashCode(){
- if (lValue != null)
- return lValue.hashCode();
- else
- return 0;
+ public String toString() {
+ if (lValue != null)
+ return lValue.toString();
+ else
+ return null;
}
- /**
- *
- * validate the value against the xsd definition
- *
- */
+ public int hashCode() {
+ if (lValue != null)
+ return lValue.hashCode();
+ else
+ return 0;
+ }
+
+ /** validate the value against the xsd definition */
public static boolean isValid(long iValue) {
return !((iValue < 0L) || (iValue > 4294967295L));
}
private Object __equalsCalc = null;
+
public synchronized boolean equals(Object obj) {
if (!(obj instanceof UnsignedInt)) return false;
- UnsignedInt other = (UnsignedInt) obj;
+ UnsignedInt other = (UnsignedInt)obj;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
@@ -100,12 +95,29 @@
}
// Implement java.lang.Number interface
- public byte byteValue() { return lValue.byteValue(); }
- public short shortValue() { return lValue.shortValue(); }
- public int intValue() { return lValue.intValue(); }
- public long longValue() { return lValue.longValue(); }
- public double doubleValue() { return lValue.doubleValue(); }
- public float floatValue() { return lValue.floatValue(); }
+ public byte byteValue() {
+ return lValue.byteValue();
+ }
+
+ public short shortValue() {
+ return lValue.shortValue();
+ }
+
+ public int intValue() {
+ return lValue.intValue();
+ }
+
+ public long longValue() {
+ return lValue.longValue();
+ }
+
+ public double doubleValue() {
+ return lValue.doubleValue();
+ }
+
+ public float floatValue() {
+ return lValue.floatValue();
+ }
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedLong.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedLong.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedLong.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedLong.java Thu Mar 29 11:49:12 2007
@@ -59,7 +59,8 @@
// That detection must be performed here.
try {
if (stValue.charAt(0) == '\u002d') {
- throw new NumberFormatException("A String that starts with a minus sign is not a valid representation of an UnsignedLong.");
+ throw new NumberFormatException(
+ "A String that starts with a minus sign is not a valid representation of an UnsignedLong.");
}
setValue(new BigInteger(stValue));
}
@@ -71,7 +72,8 @@
catch (IndexOutOfBoundsException indexOutOfBoundsException) {
// This could happen if stValue is empty when we attempt to detect a minus sign.
// From the client's point of view, the empty String should cause a NumberFormatException.
- throw new NumberFormatException("An empty string is not a valid representation of an UnsignedLong.");
+ throw new NumberFormatException(
+ "An empty string is not a valid representation of an UnsignedLong.");
}
}
@@ -80,7 +82,7 @@
if (!UnsignedLong.isValid(val)) {
throw new IllegalArgumentException(
// Messages.getMessage("badUnsignedLong00") +
- String.valueOf(val) + "]");
+String.valueOf(val) + "]");
}
this.lValue = val;
}
@@ -112,7 +114,7 @@
public synchronized boolean equals(Object obj) {
if (!(obj instanceof UnsignedLong)) return false;
- UnsignedLong other = (UnsignedLong) obj;
+ UnsignedLong other = (UnsignedLong)obj;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
@@ -152,23 +154,29 @@
}
/**
- * @return the value 0 if the argument is an UnsignedLong numerically equal to this UnsignedLong; a value less than 0 if the argument is an UnsignedLong numerically greater than this UnsignedLong; and a value greater than 0 if the argument is an UnsignedLong numerically less than this UnsignedLong.
+ * @return the value 0 if the argument is an UnsignedLong numerically equal to this
+ * UnsignedLong; a value less than 0 if the argument is an UnsignedLong numerically
+ * greater than this UnsignedLong; and a value greater than 0 if the argument is an
+ * UnsignedLong numerically less than this UnsignedLong.
*/
public int compareTo(Object o) {
- int retVal = 0; // arbitrary default value in case of exception; required return value in case this object is equal to the specified object
+ int retVal =
+ 0; // arbitrary default value in case of exception; required return value in case this object is equal to the specified object
if (o == null || !(o instanceof UnsignedLong)) {
throw new ClassCastException("The argument is not an UnsignedLong.");
}
// Only need to change retVal if this object is not equal to the specified object.
- retVal = compare(longValue(), ((UnsignedLong) o).longValue());
+ retVal = compare(longValue(), ((UnsignedLong)o).longValue());
return retVal;
}
/**
- * @return the value 0 if thatLong is a long numerically equal to thisLong; a value less than 0 if thatLong is a long numerically greater than thisLong; and a value greater than 0 if thatLong is a long numerically less than thisLong (unsigned comparison).
+ * @return the value 0 if thatLong is a long numerically equal to thisLong; a value less than 0
+ * if thatLong is a long numerically greater than thisLong; and a value greater than 0
+ * if thatLong is a long numerically less than thisLong (unsigned comparison).
*/
private static int compare(long thisLong, long thatLong) {
// To avoid infinite recursion, do not instantiate UnsignedLong in this method, which may be called during UnsignedLong instantiation.
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedShort.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedShort.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedShort.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/UnsignedShort.java Thu Mar 29 11:49:12 2007
@@ -25,24 +25,24 @@
private static final long serialVersionUID = 6822598447692816380L;
- public UnsignedShort() {
+ public UnsignedShort() {
}
/**
* ctor for UnsignedShort
- * @exception NumberFormatException will be thrown if validation fails
+ *
+ * @throws NumberFormatException will be thrown if validation fails
*/
public UnsignedShort(long sValue) throws NumberFormatException {
- setValue(sValue);
+ setValue(sValue);
}
public UnsignedShort(String sValue) throws NumberFormatException {
- setValue(Long.parseLong(sValue));
+ setValue(Long.parseLong(sValue));
}
/**
- *
* validates the data and sets the value for the object.
*
* @param sValue value
@@ -50,16 +50,12 @@
public void setValue(long sValue) throws NumberFormatException {
if (!UnsignedShort.isValid(sValue))
throw new NumberFormatException(
- // Messages.getMessage("badUnsignedShort00") +
+ // Messages.getMessage("badUnsignedShort00") +
String.valueOf(sValue) + "]");
lValue = new Long(sValue);
}
- /**
- *
- * validate the value against the xsd definition
- *
- */
+ /** validate the value against the xsd definition */
public static boolean isValid(long sValue) {
return !((sValue < 0L) || (sValue > 65535L));
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Year.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Year.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Year.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Year.java Thu Mar 29 11:49:12 2007
@@ -25,31 +25,26 @@
* @see <a href="http://www.w3.org/TR/xmlschema-2/#gYear">XML Schema 3.2.11</a>
*/
public class Year implements Serializable {
-
+
private static final long serialVersionUID = 7498876120334857019L;
-
- int year;
+
+ int year;
String timezone = null;
- /**
- * Constructs a Year with the given values
- * No timezone is specified
- */
+ /** Constructs a Year with the given values No timezone is specified */
public Year(int year) throws NumberFormatException {
setValue(year);
}
/**
- * Constructs a Year with the given values, including a timezone string
- * The timezone is validated but not used.
+ * Constructs a Year with the given values, including a timezone string The timezone is
+ * validated but not used.
*/
public Year(int year, String timezone) throws NumberFormatException {
setValue(year, timezone);
}
- /**
- * Construct a Year from a String in the format [-]CCYY[timezone]
- */
+ /** Construct a Year from a String in the format [-]CCYY[timezone] */
public Year(String source) throws NumberFormatException {
int negative = 0;
@@ -58,7 +53,7 @@
}
if (source.length() < (4 + negative)) {
throw new NumberFormatException();
- //Messages.getMessage("badYear00"));
+ //Messages.getMessage("badYear00"));
}
// calculate how many more than 4 digits (if any) in the year
@@ -67,7 +62,7 @@
++pos;
}
- setValue(Integer.parseInt(source.substring(0,pos)),
+ setValue(Integer.parseInt(source.substring(0, pos)),
source.substring(pos));
}
@@ -79,7 +74,7 @@
// validate year, more than 4 digits are allowed!
if (year == 0) {
throw new NumberFormatException();
- //Messages.getMessage("badYear00"));
+ //Messages.getMessage("badYear00"));
}
this.year = year;
@@ -93,19 +88,19 @@
// validate timezone
if (timezone != null && timezone.length() > 0) {
// Format [+/-]HH:MM
- if (timezone.charAt(0)=='+' || (timezone.charAt(0)=='-')) {
- if (timezone.length() != 6 ||
+ if (timezone.charAt(0) == '+' || (timezone.charAt(0) == '-')) {
+ if (timezone.length() != 6 ||
!Character.isDigit(timezone.charAt(1)) ||
!Character.isDigit(timezone.charAt(2)) ||
- timezone.charAt(3) != ':' ||
+ timezone.charAt(3) != ':' ||
!Character.isDigit(timezone.charAt(4)) ||
!Character.isDigit(timezone.charAt(5)))
- throw new NumberFormatException();
- //Messages.getMessage("badTimezone00"));
+ throw new NumberFormatException();
+ //Messages.getMessage("badTimezone00"));
} else if (!timezone.equals("Z")) {
throw new NumberFormatException();
- // Messages.getMessage("badTimezone00"));
+ // Messages.getMessage("badTimezone00"));
}
// if we got this far, its good
this.timezone = timezone;
@@ -113,7 +108,7 @@
}
public void setValue(int year, String timezone)
- throws NumberFormatException {
+ throws NumberFormatException {
setYear(year);
setTimezone(timezone);
}
@@ -140,7 +135,7 @@
public boolean equals(Object obj) {
if (!(obj instanceof Year)) return false;
- Year other = (Year) obj;
+ Year other = (Year)obj;
if (this == obj) return true;
boolean equals = (this.year == other.year);
@@ -151,8 +146,7 @@
}
/**
- * Return the value of year XORed with the hashCode of timezone
- * iff one is defined.
+ * Return the value of year XORed with the hashCode of timezone iff one is defined.
*
* @return an <code>int</code> value
*/
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/YearMonth.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/YearMonth.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/YearMonth.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/YearMonth.java Thu Mar 29 11:49:12 2007
@@ -25,32 +25,27 @@
* @see <a href="http://www.w3.org/TR/xmlschema-2/#gYearMonth">XML Schema 3.2.10</a>
*/
public class YearMonth implements Serializable {
-
+
private static final long serialVersionUID = -5510739842661690551L;
-
- int year;
+
+ int year;
int month;
String timezone = null;
- /**
- * Constructs a YearMonth with the given values
- * No timezone is specified
- */
+ /** Constructs a YearMonth with the given values No timezone is specified */
public YearMonth(int year, int month) throws NumberFormatException {
setValue(year, month);
}
/**
- * Constructs a YearMonth with the given values, including a timezone string
- * The timezone is validated but not used.
+ * Constructs a YearMonth with the given values, including a timezone string The timezone is
+ * validated but not used.
*/
public YearMonth(int year, int month, String timezone) throws NumberFormatException {
setValue(year, month, timezone);
}
- /**
- * Construct a YearMonth from a String in the format [-]CCYY-MM
- */
+ /** Construct a YearMonth from a String in the format [-]CCYY-MM */
public YearMonth(String source) throws NumberFormatException {
int negative = 0;
@@ -59,20 +54,20 @@
}
if (source.length() < (7 + negative)) {
throw new NumberFormatException();
- // Messages.getMessage("badYearMonth00"));
+ // Messages.getMessage("badYearMonth00"));
}
// look for first '-'
int pos = source.substring(negative).indexOf('-');
if (pos < 0) {
throw new NumberFormatException();
- //Messages.getMessage("badYearMonth00"));
+ //Messages.getMessage("badYearMonth00"));
}
if (negative > 0) pos++; //adjust index for orginal string
- setValue(Integer.parseInt(source.substring(0,pos)),
- Integer.parseInt(source.substring(pos+1,pos+3)),
- source.substring(pos+3));
+ setValue(Integer.parseInt(source.substring(0, pos)),
+ Integer.parseInt(source.substring(pos + 1, pos + 3)),
+ source.substring(pos + 3));
}
public int getYear() {
@@ -83,7 +78,7 @@
// validate year, more than 4 digits are allowed!
if (year == 0) {
throw new NumberFormatException();
- // Messages.getMessage("badYearMonth00"));
+ // Messages.getMessage("badYearMonth00"));
}
this.year = year;
@@ -97,7 +92,7 @@
// validate month
if (month < 1 || month > 12) {
throw new NumberFormatException();
- //Messages.getMessage("badYearMonth00"));
+ //Messages.getMessage("badYearMonth00"));
}
this.month = month;
}
@@ -110,19 +105,19 @@
// validate timezone
if (timezone != null && timezone.length() > 0) {
// Format [+/-]HH:MM
- if (timezone.charAt(0)=='+' || (timezone.charAt(0)=='-')) {
- if (timezone.length() != 6 ||
+ if (timezone.charAt(0) == '+' || (timezone.charAt(0) == '-')) {
+ if (timezone.length() != 6 ||
!Character.isDigit(timezone.charAt(1)) ||
!Character.isDigit(timezone.charAt(2)) ||
- timezone.charAt(3) != ':' ||
+ timezone.charAt(3) != ':' ||
!Character.isDigit(timezone.charAt(4)) ||
!Character.isDigit(timezone.charAt(5)))
- throw new NumberFormatException();
- //Messages.getMessage("badTimezone00"));
+ throw new NumberFormatException();
+ //Messages.getMessage("badTimezone00"));
} else if (!timezone.equals("Z")) {
throw new NumberFormatException();
- //Messages.getMessage("badTimezone00"));
+ //Messages.getMessage("badTimezone00"));
}
// if we got this far, its good
this.timezone = timezone;
@@ -162,7 +157,7 @@
public boolean equals(Object obj) {
if (!(obj instanceof YearMonth)) return false;
- YearMonth other = (YearMonth) obj;
+ YearMonth other = (YearMonth)obj;
if (this == obj) return true;
boolean equals = (this.year == other.year && this.month == other.month);
@@ -173,14 +168,13 @@
}
/**
- * Return the value of (month + year) XORed with the hashCode of
- * timezone iff one is defined.
+ * Return the value of (month + year) XORed with the hashCode of timezone iff one is defined.
*
* @return an <code>int</code> value
*/
public int hashCode() {
return null == timezone
- ? (month + year)
- : (month + year) ^ timezone.hashCode();
+ ? (month + year)
+ : (month + year) ^ timezone.hashCode();
}
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/package.html
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/package.html?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/package.html (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/package.html Thu Mar 29 11:49:12 2007
@@ -1,5 +1,6 @@
<html>
<body>
- These classes are directly salvaged from Axis 1 codebase. Original author comments have been preserved!
+These classes are directly salvaged from Axis 1 codebase. Original author comments have been
+preserved!
</body>
</html>
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Thu Mar 29 11:49:12 2007
@@ -30,7 +30,12 @@
import org.apache.axis2.engine.ObjectSupplier;
import org.apache.axis2.util.StreamWrapper;
import org.apache.ws.java2wsdl.utils.TypeTable;
-import org.codehaus.jam.*;
+import org.codehaus.jam.JClass;
+import org.codehaus.jam.JProperty;
+import org.codehaus.jam.JamClassIterator;
+import org.codehaus.jam.JamService;
+import org.codehaus.jam.JamServiceFactory;
+import org.codehaus.jam.JamServiceParams;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
@@ -41,7 +46,12 @@
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
public class BeanUtil {
@@ -72,13 +82,14 @@
JamClassIterator jClassIter = service.getClasses();
JClass jClass;
if (jClassIter.hasNext()) {
- jClass = (JClass) jClassIter.next();
+ jClass = (JClass)jClassIter.next();
} else {
throw new AxisFault("No service class found , exception from JAM");
}
QName elemntNameSpace = null;
if (typeTable != null && qualified) {
- QName qNamefortheType = typeTable.getQNamefortheType(beanObject.getClass().getName());
+ QName qNamefortheType =
+ typeTable.getQNamefortheType(beanObject.getClass().getName());
if (qNamefortheType == null) {
qNamefortheType = typeTable.getQNamefortheType(
beanObject.getClass().getPackage().getName());
@@ -89,7 +100,7 @@
}
elemntNameSpace = new QName(qNamefortheType.getNamespaceURI(),
- "elementName");
+ "elementName");
}
// properties from JAM
@@ -100,7 +111,7 @@
propertyList.add(property);
}
JClass supClass = jClass.getSuperclass();
- while(!"java.lang.Object".equals(supClass.getQualifiedName())){
+ while (!"java.lang.Object".equals(supClass.getQualifiedName())) {
properties = supClass.getDeclaredProperties();
for (int i = 0; i < properties.length; i++) {
JProperty property = properties[i];
@@ -110,8 +121,8 @@
}
properties = new JProperty[propertyList.size()];
for (int i = 0; i < propertyList.size(); i++) {
- JProperty jProperty = (JProperty) propertyList.get(i);
- properties[i]= jProperty;
+ JProperty jProperty = (JProperty)propertyList.get(i);
+ properties[i] = jProperty;
}
Arrays.sort(properties);
BeanInfo beanInfo = Introspector.getBeanInfo(beanObject.getClass());
@@ -124,7 +135,7 @@
ArrayList object = new ArrayList();
for (int i = 0; i < properties.length; i++) {
JProperty property = properties[i];
- PropertyDescriptor propDesc = (PropertyDescriptor) propertMap.get(
+ PropertyDescriptor propDesc = (PropertyDescriptor)propertMap.get(
getCorrectName(property.getSimpleName()));
if (propDesc == null) {
// JAM does bad thing so I need to add this
@@ -136,73 +147,77 @@
}
if (SimpleTypeMapper.isSimpleType(ptype)) {
Object value = propDesc.getReadMethod().invoke(beanObject,
- null);
+ null);
if (elemntNameSpace != null) {
object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
+ propDesc.getName(), elemntNameSpace.getPrefix()));
} else {
object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
+ propDesc.getName(), beanName.getPrefix()));
}
object.add(value == null ? null : SimpleTypeMapper.getStringValue(value));
} else if (ptype.isArray()) {
if (SimpleTypeMapper.isSimpleType(ptype.getComponentType())) {
Object value = propDesc.getReadMethod().invoke(beanObject,
- null);
+ null);
if (value != null) {
int i1 = Array.getLength(value);
for (int j = 0; j < i1; j++) {
Object o = Array.get(value, j);
if (elemntNameSpace != null) {
object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
+ propDesc.getName(),
+ elemntNameSpace.getPrefix()));
} else {
object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
+ propDesc.getName(), beanName.getPrefix()));
}
object.add(o == null ? null : SimpleTypeMapper.getStringValue(o));
}
} else {
if (elemntNameSpace != null) {
object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
+ propDesc.getName(),
+ elemntNameSpace.getPrefix()));
} else {
object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
+ propDesc.getName(), beanName.getPrefix()));
}
object.add(value);
}
} else {
- Object value [] = (Object[]) propDesc.getReadMethod().invoke(beanObject,
- null);
+ Object value [] = (Object[])propDesc.getReadMethod().invoke(beanObject,
+ null);
if (value != null) {
for (int j = 0; j < value.length; j++) {
Object o = value[j];
if (elemntNameSpace != null) {
object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
+ propDesc.getName(),
+ elemntNameSpace.getPrefix()));
} else {
object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
+ propDesc.getName(), beanName.getPrefix()));
}
object.add(o);
}
- }else {
+ } else {
if (elemntNameSpace != null) {
object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
+ propDesc.getName(),
+ elemntNameSpace.getPrefix()));
} else {
object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
+ propDesc.getName(), beanName.getPrefix()));
}
object.add(value);
}
}
} else if (SimpleTypeMapper.isCollection(ptype)) {
Object value = propDesc.getReadMethod().invoke(beanObject,
- null);
- Collection objList = (Collection) value;
+ null);
+ Collection objList = (Collection)value;
if (objList != null && objList.size() > 0) {
//this was given error , when the array.size = 0
// and if the array contain simple type , then the ADBPullParser asked
@@ -212,48 +227,51 @@
if (SimpleTypeMapper.isSimpleType(o)) {
if (elemntNameSpace != null) {
object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
+ propDesc.getName(),
+ elemntNameSpace.getPrefix()));
} else {
object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
+ propDesc.getName(), beanName.getPrefix()));
}
object.add(o);
} else {
if (elemntNameSpace != null) {
object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
+ propDesc.getName(),
+ elemntNameSpace.getPrefix()));
} else {
object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
+ propDesc.getName(), beanName.getPrefix()));
}
object.add(o);
}
}
- }else {
- if (elemntNameSpace != null) {
- object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
- } else {
- object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
- }
- object.add(value);
+ } else {
+ if (elemntNameSpace != null) {
+ object.add(new QName(elemntNameSpace.getNamespaceURI(),
+ propDesc.getName(), elemntNameSpace.getPrefix()));
+ } else {
+ object.add(new QName(beanName.getNamespaceURI(),
+ propDesc.getName(), beanName.getPrefix()));
}
+ object.add(value);
+ }
} else {
if (elemntNameSpace != null) {
object.add(new QName(elemntNameSpace.getNamespaceURI(),
- propDesc.getName(), elemntNameSpace.getPrefix()));
- } else{
+ propDesc.getName(), elemntNameSpace.getPrefix()));
+ } else {
object.add(new QName(beanName.getNamespaceURI(),
- propDesc.getName(), beanName.getPrefix()));
+ propDesc.getName(), beanName.getPrefix()));
}
Object value = propDesc.getReadMethod().invoke(beanObject,
- null);
+ null);
object.add(value);
}
}
- return new ADBXMLStreamReaderImpl(beanName, object.toArray(), null, typeTable, qualified);
+ return new ADBXMLStreamReaderImpl(beanName, object.toArray(), null, typeTable,
+ qualified);
} catch (java.io.IOException e) {
throw new RuntimeException(e);
} catch (java.beans.IntrospectionException e) {
@@ -266,7 +284,8 @@
}
/**
- * to get the pull parser for a given bean object , generate the wrpper element using class name
+ * to get the pull parser for a given bean object , generate the wrpper element using class
+ * name
*
* @param beanObject
*/
@@ -274,7 +293,7 @@
String className = beanObject.getClass().getName();
if (className.indexOf(".") > 0) {
className = className.substring(className.lastIndexOf('.') + 1,
- className.length());
+ className.length());
}
return getPullParser(beanObject, new QName(className), null, false);
}
@@ -294,20 +313,20 @@
while (parts.hasNext()) {
Object objValue = parts.next();
if (objValue instanceof OMElement) {
- omElement = (OMElement) objValue;
+ omElement = (OMElement)objValue;
if (!arrayLocalName.equals(omElement.getLocalName())) {
continue;
}
Object obj = deserialize(arrayClassType,
- omElement,
- objectSupplier, null);
+ omElement,
+ objectSupplier, null);
if (obj != null) {
valueList.add(obj);
}
}
}
return ConverterUtil.convertToArray(arrayClassType,
- valueList);
+ valueList);
} else {
if (SimpleTypeMapper.isSimpleType(beanClass)) {
return SimpleTypeMapper.getSimpleTypeObject(beanClass, beanElement);
@@ -327,14 +346,14 @@
OMElement parts;
Object objValue = elements.next();
if (objValue instanceof OMElement) {
- parts = (OMElement) objValue;
+ parts = (OMElement)objValue;
} else {
continue;
}
// if parts/@href != null then need to find element with id and deserialize.
// before that first check whether we already have it in the hashtable
String partsLocalName = parts.getLocalName();
- PropertyDescriptor prty = (PropertyDescriptor) properties.get(partsLocalName);
+ PropertyDescriptor prty = (PropertyDescriptor)properties.get(partsLocalName);
if (prty != null) {
Class parameters = prty.getPropertyType();
if (prty.equals("class"))
@@ -347,14 +366,14 @@
partObj = SimpleTypeMapper.getArrayList((OMElement)
parts.getParent(), prty.getName());
} else if (parameters.isArray()) {
- partObj = deserialize(parameters, (OMElement) parts.getParent(),
- objectSupplier, prty.getName());
+ partObj = deserialize(parameters, (OMElement)parts.getParent(),
+ objectSupplier, prty.getName());
} else {
partObj = deserialize(parameters, parts, objectSupplier, null);
}
- Object [] parms = new Object[]{partObj};
+ Object [] parms = new Object[] { partObj };
Method writeMethod = prty.getWriteMethod();
- if (writeMethod!=null) {
+ if (writeMethod != null) {
writeMethod.invoke(beanObj, parms);
}
tuched = true;
@@ -397,12 +416,12 @@
Object child = elements.next();
OMElement parts;
if (child instanceof OMElement) {
- parts = (OMElement) child;
+ parts = (OMElement)child;
} else {
continue;
}
String partsLocalName = parts.getLocalName();
- PropertyDescriptor prty = (PropertyDescriptor) properties.get(
+ PropertyDescriptor prty = (PropertyDescriptor)properties.get(
partsLocalName.toLowerCase());
if (prty != null) {
Class parameters = prty.getPropertyType();
@@ -422,9 +441,9 @@
partObj = deserialize(parameters, parts, objectSupplier, null);
}
}
- Object [] parms = new Object[]{partObj};
+ Object [] parms = new Object[] { partObj };
Method writeMethod = prty.getWriteMethod();
- if (writeMethod!=null) {
+ if (writeMethod != null) {
writeMethod.invoke(beanObj, parms);
}
}
@@ -443,8 +462,9 @@
/**
* To get JavaObjects from XML elemnt , the element most of the time contains only one element
* in that case that element will be converted to the JavaType specified by the javaTypes array
- * The algo is as follows, get the childerns of the response element , and if it conatian more than
- * one element then check the retuen type of that element and conver that to corresponding JavaType
+ * The algo is as follows, get the childerns of the response element , and if it conatian more
+ * than one element then check the retuen type of that element and conver that to corresponding
+ * JavaType
*
* @param response OMElement
* @param javaTypes Array of JavaTypes
@@ -488,7 +508,7 @@
Iterator parts = response.getChildren();
//to handle multirefs
//have to check the instanceof
- MultirefHelper helper = new MultirefHelper((OMElement) response.getParent());
+ MultirefHelper helper = new MultirefHelper((OMElement)response.getParent());
//to support array . if the parameter type is array , then all the omelemnts with that paramtre name
// has to get and add to the list
Class classType;
@@ -497,25 +517,26 @@
Object objValue = parts.next();
OMElement omElement;
if (objValue instanceof OMElement) {
- omElement = (OMElement) objValue;
+ omElement = (OMElement)objValue;
} else {
continue;
}
currentLocalName = omElement.getLocalName();
- classType = (Class) javaTypes[count];
+ classType = (Class)javaTypes[count];
omElement = ProcessElement(classType, omElement, helper, parts,
- currentLocalName, retObjs, count, objectSupplier);
+ currentLocalName, retObjs, count, objectSupplier);
while (omElement != null) {
count ++;
- omElement = ProcessElement((Class) javaTypes[count], omElement,
- helper, parts, omElement.getLocalName(), retObjs, count, objectSupplier);
+ omElement = ProcessElement((Class)javaTypes[count], omElement,
+ helper, parts, omElement.getLocalName(), retObjs, count,
+ objectSupplier);
}
count ++;
}
// Ensure that we have at least a zero element array
for (int i = 0; i < length; i++) {
- Class clazz = (Class) javaTypes[i];
+ Class clazz = (Class)javaTypes[i];
if (retObjs[i] == null && clazz.isArray()) {
retObjs[i] = Array.newInstance(clazz.getComponentType(), 0);
}
@@ -537,15 +558,17 @@
ArrayList valueList = new ArrayList();
Class arrayClassType = classType.getComponentType();
if ("byte".equals(arrayClassType.getName())) {
- retObjs[count] = processObject(omElement, arrayClassType, helper, true, objectSupplier);
+ retObjs[count] =
+ processObject(omElement, arrayClassType, helper, true, objectSupplier);
return null;
} else {
- valueList.add(processObject(omElement, arrayClassType, helper, true, objectSupplier));
+ valueList.add(processObject(omElement, arrayClassType, helper, true,
+ objectSupplier));
}
while (parts.hasNext()) {
objValue = parts.next();
if (objValue instanceof OMElement) {
- omElement = (OMElement) objValue;
+ omElement = (OMElement)objValue;
} else {
continue;
}
@@ -554,11 +577,11 @@
break;
}
Object o = processObject(omElement, arrayClassType,
- helper, true, objectSupplier);
+ helper, true, objectSupplier);
valueList.add(o);
}
retObjs[count] = ConverterUtil.convertToArray(arrayClassType,
- valueList);
+ valueList);
if (!done) {
return omElement;
}
@@ -613,7 +636,7 @@
}
} else if (SimpleTypeMapper.isCollection(classType)) {
return SimpleTypeMapper.getArrayList(omElement);
- }else if(SimpleTypeMapper.isDataHandler(classType)){
+ } else if (SimpleTypeMapper.isDataHandler(classType)) {
return SimpleTypeMapper.getDataHandler(omElement);
} else {
return BeanUtil.deserialize(classType, omElement, objectSupplier, null);
@@ -641,7 +664,7 @@
//way to do that , to solve that problem we need to have RPCRequestParameter
//note that The value of request parameter can either be simple type or JavaBean
if (arg instanceof Object[]) {
- Object array [] = (Object[]) arg;
+ Object array [] = (Object[])arg;
for (int j = 0; j < array.length; j++) {
Object o = array[j];
if (o == null) {
@@ -658,10 +681,10 @@
OMElement wrappingElement;
if (partName == null) {
wrappingElement = fac.createOMElement("item" + argCount, null);
- wrappingElement.addChild((OMElement) o);
+ wrappingElement.addChild((OMElement)o);
} else {
wrappingElement = fac.createOMElement(partName, null);
- wrappingElement.addChild((OMElement) o);
+ wrappingElement.addChild((OMElement)o);
}
objects.add(wrappingElement);
} else {
@@ -689,14 +712,14 @@
OMElement wrappingElement;
if (partName == null) {
wrappingElement = fac.createOMElement("arg" + argCount, null);
- wrappingElement.addChild((OMElement) arg);
+ wrappingElement.addChild((OMElement)arg);
} else {
wrappingElement = fac.createOMElement(partName, null);
- wrappingElement.addChild((OMElement) arg);
+ wrappingElement.addChild((OMElement)arg);
}
objects.add(wrappingElement);
} else if (arg instanceof byte[]) {
- objects.add(Base64.encode((byte[]) arg));
+ objects.add(Base64.encode((byte[])arg));
} else {
objects.add(arg);
}
@@ -705,7 +728,8 @@
argCount ++;
}
- XMLStreamReader xr = new ADBXMLStreamReaderImpl(opName, objects.toArray(), null, typeTable, qualifed);
+ XMLStreamReader xr =
+ new ADBXMLStreamReaderImpl(opName, objects.toArray(), null, typeTable, qualifed);
StreamWrapper parser = new StreamWrapper(xr);
StAXOMBuilder stAXOMBuilder =
@@ -714,9 +738,7 @@
return stAXOMBuilder.getDocumentElement();
}
- /**
- * @deprecated Please use getUniquePrefix
- */
+ /** @deprecated Please use getUniquePrefix */
public static String getUniquePrifix() {
return "s" + nsCount++;
}
@@ -730,17 +752,16 @@
return "s" + nsCount++;
}
-
/**
- * JAM convert first name of an attribute into UpperCase as an example
- * if there is a instance variable called foo in a bean , then Jam give that as Foo
- * so this method is to correct that error
+ * JAM convert first name of an attribute into UpperCase as an example if there is a instance
+ * variable called foo in a bean , then Jam give that as Foo so this method is to correct that
+ * error
*
* @param wrongName
* @return the right name, using english as the locale for case conversion
*/
- private static String getCorrectName(String wrongName) {
+ private static String getCorrectName(String wrongName) {
if (wrongName.length() > 1) {
return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH)
+ wrongName.substring(1, wrongName.length());
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java Thu Mar 29 11:49:12 2007
@@ -1,8 +1,8 @@
package org.apache.axis2.databinding.utils;
+import org.apache.axiom.om.OMConstants;
import org.apache.axis2.databinding.utils.reader.OMAttribKey;
import org.apache.axis2.databinding.utils.reader.OMElementKey;
-import org.apache.axiom.om.OMConstants;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -22,9 +22,9 @@
public interface Constants {
- static String NIL="nil";
- static String TRUE="true";
- static String XSI_NAMESPACE ="http://www.w3.org/2001/XMLSchema-instance";
+ static String NIL = "nil";
+ static String TRUE = "true";
+ static String XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
static Object OM_ATTRIBUTE_KEY = new OMAttribKey();
static Object OM_ELEMENT_KEY = new OMElementKey();
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Converter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Converter.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Converter.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Converter.java Thu Mar 29 11:49:12 2007
@@ -27,12 +27,9 @@
import java.util.Iterator;
import java.util.Set;
-/**
- * Converter
- */
+/** Converter */
public class Converter {
- public static Object convert(Object arg, Class destClass)
- {
+ public static Object convert(Object arg, Class destClass) {
if (destClass == null) {
return arg;
}
@@ -54,17 +51,17 @@
// Convert between Calendar and Date
if (arg instanceof Calendar && destClass == Date.class) {
- return ((Calendar) arg).getTime();
+ return ((Calendar)arg).getTime();
}
if (arg instanceof Date && destClass == Calendar.class) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime((Date) arg);
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime((Date)arg);
return calendar;
}
// Convert between Calendar and java.sql.Date
if (arg instanceof Calendar && destClass == java.sql.Date.class) {
- return new java.sql.Date(((Calendar) arg).getTime().getTime());
+ return new java.sql.Date(((Calendar)arg).getTime().getTime());
}
// Convert between HashMap and Hashtable
@@ -76,20 +73,20 @@
// is a suitable component, return an array with
// the single item.
if (arg != null &&
- destClass.isArray() &&
- !destClass.getComponentType().equals(Object.class) &&
- destClass.getComponentType().isAssignableFrom(arg.getClass())) {
+ destClass.isArray() &&
+ !destClass.getComponentType().equals(Object.class) &&
+ destClass.getComponentType().isAssignableFrom(arg.getClass())) {
Object array =
- Array.newInstance(destClass.getComponentType(), 1);
+ Array.newInstance(destClass.getComponentType(), 1);
Array.set(array, 0, arg);
return array;
}
// Return if no conversion is available
if (!(arg instanceof Collection ||
- (arg != null && arg.getClass().isArray())) &&
- ((destHeldType == null && argHeldType == null) ||
- (destHeldType != null && argHeldType != null))) {
+ (arg != null && arg.getClass().isArray())) &&
+ ((destHeldType == null && argHeldType == null) ||
+ (destHeldType != null && argHeldType != null))) {
return arg;
}
@@ -104,7 +101,7 @@
if (arg.getClass().isArray()) {
length = Array.getLength(arg);
} else {
- length = ((Collection) arg).size();
+ length = ((Collection)arg).size();
}
if (destClass.isArray()) {
if (destClass.getComponentType().isPrimitive()) {
@@ -119,7 +116,7 @@
} else {
int idx = 0;
for (Iterator i = ((Collection)arg).iterator();
- i.hasNext();) {
+ i.hasNext();) {
Array.set(array, idx++, i.next());
}
}
@@ -143,15 +140,14 @@
} else {
int idx = 0;
for (Iterator i = ((Collection)arg).iterator();
- i.hasNext();) {
+ i.hasNext();) {
array[idx++] = convert(i.next(),
- destClass.getComponentType());
+ destClass.getComponentType());
}
}
destValue = array;
}
- }
- else if (Collection.class.isAssignableFrom(destClass)) {
+ } else if (Collection.class.isAssignableFrom(destClass)) {
Collection newList = null;
try {
// if we are trying to create an interface, build something
@@ -174,13 +170,12 @@
}
} else {
for (Iterator j = ((Collection)arg).iterator();
- j.hasNext();) {
+ j.hasNext();) {
newList.add(j.next());
}
}
destValue = newList;
- }
- else {
+ } else {
destValue = arg;
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java Thu Mar 29 11:49:12 2007
@@ -1,5 +1,20 @@
package org.apache.axis2.databinding.utils;
+import org.apache.axiom.attachments.ByteArrayDataSource;
+import org.apache.axiom.attachments.utils.IOUtils;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.Base64;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.databinding.ADBBean;
+import org.apache.axis2.databinding.i18n.ADBMessages;
+import org.apache.axis2.databinding.types.*;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.Array;
@@ -7,59 +22,14 @@
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.text.SimpleDateFormat;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
-
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.axiom.attachments.ByteArrayDataSource;
-import org.apache.axiom.attachments.utils.IOUtils;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.databinding.i18n.ADBMessages;
-import org.apache.axis2.databinding.types.Day;
-import org.apache.axis2.databinding.types.Duration;
-import org.apache.axis2.databinding.types.Entities;
-import org.apache.axis2.databinding.types.Entity;
-import org.apache.axis2.databinding.types.HexBinary;
-import org.apache.axis2.databinding.types.IDRef;
-import org.apache.axis2.databinding.types.IDRefs;
-import org.apache.axis2.databinding.types.Id;
-import org.apache.axis2.databinding.types.Language;
-import org.apache.axis2.databinding.types.Month;
-import org.apache.axis2.databinding.types.MonthDay;
-import org.apache.axis2.databinding.types.NCName;
-import org.apache.axis2.databinding.types.NMToken;
-import org.apache.axis2.databinding.types.NMTokens;
-import org.apache.axis2.databinding.types.Name;
-import org.apache.axis2.databinding.types.NegativeInteger;
-import org.apache.axis2.databinding.types.NonNegativeInteger;
-import org.apache.axis2.databinding.types.NonPositiveInteger;
-import org.apache.axis2.databinding.types.NormalizedString;
-import org.apache.axis2.databinding.types.Notation;
-import org.apache.axis2.databinding.types.PositiveInteger;
-import org.apache.axis2.databinding.types.Time;
-import org.apache.axis2.databinding.types.Token;
-import org.apache.axis2.databinding.types.URI;
-import org.apache.axis2.databinding.types.UnsignedByte;
-import org.apache.axis2.databinding.types.UnsignedInt;
-import org.apache.axis2.databinding.types.UnsignedLong;
-import org.apache.axis2.databinding.types.UnsignedShort;
-import org.apache.axis2.databinding.types.Year;
-import org.apache.axis2.databinding.types.YearMonth;
-import org.apache.axis2.databinding.ADBBean;
-import org.apache.axiom.om.util.Base64;
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -77,11 +47,8 @@
*/
/**
- * Converter methods to go from
- * 1. simple type -> String
- * 2. simple type -> Object
- * 3. String -> simpletype
- * 4. Object list -> array
+ * Converter methods to go from 1. simple type -> String 2. simple type -> Object 3. String ->
+ * simpletype 4. Object list -> array
*/
public class ConverterUtil {
private static final String POSITIVE_INFINITY = "INF";
@@ -284,10 +251,10 @@
public static boolean convertToBoolean(String s) {
boolean returnValue = false;
- if ((s != null) && (s.length() > 0)){
- if ("1".equals(s) || s.toLowerCase().equals("true")){
+ if ((s != null) && (s.length() > 0)) {
+ if ("1".equals(s) || s.toLowerCase().equals("true")) {
returnValue = true;
- } else if (!"0".equals(s) && !s.toLowerCase().equals("false")){
+ } else if (!"0".equals(s) && !s.toLowerCase().equals("false")) {
throw new RuntimeException("in valid string -" + s + " for boolean value");
}
}
@@ -351,8 +318,7 @@
}
/**
- * Converts a given string into a date.
- * Code from Axis1 DateDeserializer.
+ * Converts a given string into a date. Code from Axis1 DateDeserializer.
*
* @param source
* @return Returns Date.
@@ -522,8 +488,7 @@
}
/**
- * Code from Axis1 code base
- * Note - We only follow the convention in the latest schema spec
+ * Code from Axis1 code base Note - We only follow the convention in the latest schema spec
*
* @param source
* @return Returns Calendar.
@@ -763,7 +728,7 @@
}
try {
- objectList.toArray((Object[]) returnArray);
+ objectList.toArray((Object[])returnArray);
} catch (Exception e) {
//we are over with alternatives - throw the
//converison exception
@@ -772,8 +737,7 @@
}
/**
- * We could have used the Arraya.asList() method
- * but that returns an *immutable* list !!!!!
+ * We could have used the Arraya.asList() method but that returns an *immutable* list !!!!!
*
* @param array
* @return list
@@ -864,22 +828,22 @@
return binBigDecimal.doubleValue() - Double.parseDouble(value);
}
- public static long compare(Duration duration, String value){
+ public static long compare(Duration duration, String value) {
Duration compareValue = new Duration(value);
return duration.compare(compareValue);
}
- public static long compare(Date date, String value){
+ public static long compare(Date date, String value) {
Date newDate = convertToDate(value);
return date.getTime() - newDate.getTime();
}
- public static long compare(Time time, String value){
+ public static long compare(Time time, String value) {
Time newTime = new Time(value);
return time.getAsCalendar().getTimeInMillis() - newTime.getAsCalendar().getTimeInMillis();
}
- public static long compare(Calendar calendar, String value){
+ public static long compare(Calendar calendar, String value) {
Calendar newCalendar = convertToDateTime(value);
return calendar.getTimeInMillis() - newCalendar.getTimeInMillis();
}
@@ -904,8 +868,8 @@
}
/**
- * A reflection based method to generate an instance of
- * a given class and populate it with a given value
+ * A reflection based method to generate an instance of a given class and populate it with a
+ * given value
*
* @param clazz
* @param value
@@ -916,8 +880,8 @@
//take the string as an argument.
boolean continueFlag = false;
try {
- Constructor stringConstructor = clazz.getConstructor(new Class[]{String.class});
- return stringConstructor.newInstance(new Object[]{value});
+ Constructor stringConstructor = clazz.getConstructor(new Class[] { String.class });
+ return stringConstructor.newInstance(new Object[] { value });
} catch (NoSuchMethodException e) {
//oops - no such constructors - continue with the
//parse method
@@ -925,34 +889,32 @@
} catch (Exception e) {
throw new ObjectConversionException(
ADBMessages.getMessage("converter.cannotGenerate",
- clazz.getName()),
+ clazz.getName()),
e);
}
if (!continueFlag) {
throw new ObjectConversionException(
ADBMessages.getMessage("converter.cannotConvert",
- clazz.getName()));
+ clazz.getName()));
}
try {
- Method parseMethod = clazz.getMethod("parse", new Class[]{String.class});
+ Method parseMethod = clazz.getMethod("parse", new Class[] { String.class });
Object instance = clazz.newInstance();
- return parseMethod.invoke(instance, new Object[]{value});
+ return parseMethod.invoke(instance, new Object[] { value });
} catch (NoSuchMethodException e) {
throw new ObjectConversionException(e);
} catch (Exception e) {
throw new ObjectConversionException(
ADBMessages.getMessage("converter.cannotGenerate",
- clazz.getName()),
+ clazz.getName()),
e);
}
}
- /**
- * A simple exception that is thrown when the conversion fails
- */
+ /** A simple exception that is thrown when the conversion fails */
public static class ObjectConversionException extends RuntimeException {
public ObjectConversionException() {
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/MultirefHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/MultirefHelper.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/MultirefHelper.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/MultirefHelper.java Thu Mar 29 11:49:12 2007
@@ -22,8 +22,8 @@
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.engine.ObjectSupplier;
import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
+import org.apache.axis2.engine.ObjectSupplier;
import javax.xml.namespace.QName;
import java.util.HashMap;
@@ -51,14 +51,14 @@
}
public OMElement getOMElement(String id) {
- return (OMElement) omElementMap.get(id);
+ return (OMElement)omElementMap.get(id);
}
public OMElement processOMElementRef(String id) throws AxisFault {
if (!filledTable) {
readallChildElements();
}
- OMElement val = (OMElement) elementMap.get(id);
+ OMElement val = (OMElement)elementMap.get(id);
if (val == null) {
throw new AxisFault("Invalid reference :" + id);
} else {
@@ -72,7 +72,7 @@
public OMElement processElementforRefs(OMElement elemnts) throws AxisFault {
Iterator itr = elemnts.getChildElements();
while (itr.hasNext()) {
- OMElement omElement = (OMElement) itr.next();
+ OMElement omElement = (OMElement)itr.next();
OMAttribute attri = processRefAtt(omElement);
if (attri != null) {
String ref = getAttvalue(attri);
@@ -85,7 +85,7 @@
while (itrChild.hasNext()) {
Object obj = itrChild.next();
if (obj instanceof OMNode) {
- omElement.addChild((OMNode) obj);
+ omElement.addChild((OMNode)obj);
}
}
}
@@ -97,11 +97,12 @@
return new StAXOMBuilder(ele.getXMLStreamReader()).getDocumentElement();
}
- public Object processRef(Class javatype, String id , ObjectSupplier objectSupplier) throws AxisFault {
+ public Object processRef(Class javatype, String id, ObjectSupplier objectSupplier)
+ throws AxisFault {
if (!filledTable) {
readallChildElements();
}
- OMElement val = (OMElement) elementMap.get(id);
+ OMElement val = (OMElement)elementMap.get(id);
if (val == null) {
throw new AxisFault("Invalid reference :" + id);
} else {
@@ -123,7 +124,7 @@
objectmap.put(id, valobj);
return valobj;
} else {
- Object obj = BeanUtil.deserialize(javatype, val, this , objectSupplier);
+ Object obj = BeanUtil.deserialize(javatype, val, this, objectSupplier);
objectmap.put(id, obj);
return obj;
}
@@ -133,7 +134,7 @@
private void readallChildElements() {
Iterator childs = parent.getChildElements();
while (childs.hasNext()) {
- OMElement omElement = (OMElement) childs.next();
+ OMElement omElement = (OMElement)childs.next();
OMAttribute id = omElement.getAttribute(new QName("id"));
if (id != null) {
omElement.build();
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java Thu Mar 29 11:49:12 2007
@@ -30,7 +30,6 @@
private QName nameToMatch;
/**
- *
* @param xmlStreamReader
* @param nameToMatch
*/
@@ -43,21 +42,21 @@
/**
*
*/
- public OMElement getOMElement(){
+ public OMElement getOMElement() {
//force to build within the given QName
boolean done = false;
int depth = 0;
- while(!done){
- if (reader.getEventType()==XMLStreamConstants.END_ELEMENT){
+ while (!done) {
+ if (reader.getEventType() == XMLStreamConstants.END_ELEMENT) {
depth--;
- }else if (reader.getEventType()==XMLStreamConstants.START_ELEMENT){
+ } else if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
depth++;
}
- if (depth==0 && reader.getEventType()==XMLStreamConstants.END_ELEMENT &&
- nameToMatch.equals(reader.getName())){
+ if (depth == 0 && reader.getEventType() == XMLStreamConstants.END_ELEMENT &&
+ nameToMatch.equals(reader.getName())) {
done = true;
- }else{
+ } else {
builder.next();
}
@@ -65,7 +64,6 @@
return builder.getDocumentElement();
}
-
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java Thu Mar 29 11:49:12 2007
@@ -22,10 +22,8 @@
* limitations under the License.
*/
-/**
- * A state machine that reads arrays with simple content. returns a string array
- */
-public class SimpleArrayReaderStateMachine implements States,Constants {
+/** A state machine that reads arrays with simple content. returns a string array */
+public class SimpleArrayReaderStateMachine implements States, Constants {
private QName elementNameToTest = null;
private int currentState = INIT_STATE;
@@ -35,15 +33,13 @@
private List list = new ArrayList();
- /**
- * @return an array of strings
- */
+ /** @return an array of strings */
public String[] getTextArray() {
return (String[])list.toArray(new String[list.size()]);
}
- public void setNillable(){
+ public void setNillable() {
nillable = true;
}
@@ -56,14 +52,14 @@
}
/**
- * Resets the state machine. Once the reset is called
- * the state machine is good enough for a fresh run
+ * Resets the state machine. Once the reset is called the state machine is good enough for a
+ * fresh run
*/
- public void reset(){
+ public void reset() {
elementNameToTest = null;
currentState = INIT_STATE;
nillable = false;
- list=new ArrayList();
+ list = new ArrayList();
}
public void setElementNameToTest(QName elementNameToTest) {
@@ -72,125 +68,123 @@
/**
* public read method - reads a given reader to extract the text value
+ *
* @param reader
*/
public void read(XMLStreamReader reader) throws XMLStreamException {
- do{
+ do {
updateState(reader);
//test for the nillable attribute
- if (currentState==START_ELEMENT_FOUND_STATE &&
- nillable){
- if (TRUE.equals(reader.getAttributeValue(XSI_NAMESPACE,NIL))){
+ if (currentState == START_ELEMENT_FOUND_STATE &&
+ nillable) {
+ if (TRUE.equals(reader.getAttributeValue(XSI_NAMESPACE, NIL))) {
list.add(null);
//force the state to be null found
- currentState= NULLED_STATE;
+ currentState = NULLED_STATE;
}
}
- if (currentState==TEXT_FOUND_STATE){
+ if (currentState == TEXT_FOUND_STATE) {
//read the text value and store it in the list
list.add(reader.getText());
}
//increment the parser only if the state is
//not finished
- if (currentState!=FINISHED_STATE
- && currentState!= ILLEGAL_STATE){
+ if (currentState != FINISHED_STATE
+ && currentState != ILLEGAL_STATE) {
reader.next();
}
- }while(currentState!=FINISHED_STATE
- && currentState!= ILLEGAL_STATE);
+ } while (currentState != FINISHED_STATE
+ && currentState != ILLEGAL_STATE);
- if (currentState==ILLEGAL_STATE){
+ if (currentState == ILLEGAL_STATE) {
throw new RuntimeException("Illegal state!");
}
}
-
-
-
- private void updateState(XMLStreamReader reader) throws XMLStreamException{
+ private void updateState(XMLStreamReader reader) throws XMLStreamException {
int event = reader.getEventType();
- switch (currentState){
+ switch (currentState) {
case INIT_STATE:
- if (event== XMLStreamConstants.START_DOCUMENT){
+ if (event == XMLStreamConstants.START_DOCUMENT) {
currentState = STARTED_STATE;
- }else if (event== XMLStreamConstants.START_ELEMENT){
- if (elementNameToTest.equals(reader.getName())){
+ } else if (event == XMLStreamConstants.START_ELEMENT) {
+ if (elementNameToTest.equals(reader.getName())) {
currentState = START_ELEMENT_FOUND_STATE;
- }else{
+ } else {
//we found a start element that does not have
//the name of the element
- currentState = canbeAbsent?
- FINISHED_STATE:
- STARTED_STATE;
+ currentState = canbeAbsent ?
+ FINISHED_STATE :
+ STARTED_STATE;
}
- }else if (event==XMLStreamConstants.END_ELEMENT){
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
// an end element is found at the init state
// we should break the process here ?
- if (!elementNameToTest.equals(reader.getName())){
- currentState = FINISHED_STATE ;
+ if (!elementNameToTest.equals(reader.getName())) {
+ currentState = FINISHED_STATE;
}
}
break;
case STARTED_STATE:
- if (event==XMLStreamConstants.END_ELEMENT){
- if (elementNameToTest.equals(reader.getName())){
+ if (event == XMLStreamConstants.END_ELEMENT) {
+ if (elementNameToTest.equals(reader.getName())) {
currentState = ILLEGAL_STATE;
- }else{
+ } else {
currentState = FINISHED_STATE;
}
- }else if (event==XMLStreamConstants.START_ELEMENT){
+ } else if (event == XMLStreamConstants.START_ELEMENT) {
QName name = reader.getName();
- if (elementNameToTest.equals(name)){
+ if (elementNameToTest.equals(name)) {
currentState = START_ELEMENT_FOUND_STATE;
}
}
break;
case START_ELEMENT_FOUND_STATE:
- if (event==XMLStreamConstants.CHARACTERS){
- currentState = TEXT_FOUND_STATE;
+ if (event == XMLStreamConstants.CHARACTERS) {
+ currentState = TEXT_FOUND_STATE;
}
break;
case TEXT_FOUND_STATE:
- if (event==XMLStreamConstants.END_ELEMENT){
- if (elementNameToTest.equals(reader.getName())){
+ if (event == XMLStreamConstants.END_ELEMENT) {
+ if (elementNameToTest.equals(reader.getName())) {
currentState = END_ELEMENT_FOUND_STATE;
- }else{
+ } else {
currentState = ILLEGAL_STATE;
}
- }else if (event==XMLStreamConstants.CHARACTERS){
+ } else if (event == XMLStreamConstants.CHARACTERS) {
//another char event -
//so append it to the current text
}
break;
case NULLED_STATE:
//read upto the end and set the state to END_ELEMENT_FOUND_STATE
- while (event!= XMLStreamConstants.END_ELEMENT){
- event=reader.next();
+ while (event != XMLStreamConstants.END_ELEMENT) {
+ event = reader.next();
}
currentState = END_ELEMENT_FOUND_STATE;
break;
case END_ELEMENT_FOUND_STATE:
- if (event==XMLStreamConstants.START_ELEMENT ) {
+ if (event == XMLStreamConstants.START_ELEMENT) {
//restart the parsing
- if (elementNameToTest.equals(reader.getName())){
+ if (elementNameToTest.equals(reader.getName())) {
currentState = START_ELEMENT_FOUND_STATE;
- }else{
+ } else {
currentState = FINISHED_STATE;
}
//another end element found after end-element
- }else if (event==XMLStreamConstants.END_ELEMENT ) {
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
currentState = FINISHED_STATE;
//end document found
}
@@ -200,15 +194,15 @@
//characters found - if this is a characters event that was in the correct place then
//it would have been handled already. we need to check whether this is a ignorable
//whitespace and if not push the state machine to a illegal state.
- if (event==XMLStreamConstants.CHARACTERS){
- if (reader.getText().trim().length()==0){
+ if (event == XMLStreamConstants.CHARACTERS) {
+ if (reader.getText().trim().length() == 0) {
//the text is empty - don't change the state
- }else{
+ } else {
//we do NOT handle mixed content
currentState = ILLEGAL_STATE;
}
- } else{
+ } else {
currentState = ILLEGAL_STATE;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org