axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r349112 [1/4] - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2: databinding/schema/ databinding/schema/typemap/ databinding/schema/types/ wsdl/template/csharp/
Date Sat, 26 Nov 2005 13:07:29 GMT
Author: ajith
Date: Sat Nov 26 05:07:02 2005
New Revision: 349112

URL: http://svn.apache.org/viewcvs?rev=349112&view=rev
Log:
1. Added all the type classes from Axis1
2. Updated the Constants to include all the XSD QNames
3. Updated the JavaTypemap for ADB to include the newly added types

Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Day.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Duration.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entities.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entity.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/HexBinary.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRef.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRefs.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Id.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Language.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Month.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/MonthDay.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NCName.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMToken.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMTokens.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Name.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NegativeInteger.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonNegativeInteger.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonPositiveInteger.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NormalizedString.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Notation.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/PositiveInteger.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Time.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Token.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/URI.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/UnsignedByte.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/UnsignedInt.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/UnsignedLong.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/UnsignedShort.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Year.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/YearMonth.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/package.html
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/csharp/package.html

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java?rev=349112&r1=349111&r2=349112&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaConstants.java Sat Nov 26 05:07:02 2005
@@ -46,6 +46,38 @@
     public static final QName XSD_TIME = new QName(URI_DEFAULT_SCHEMA_XSD, "time");
 
 
+    public static final QName XSD_UNSIGNEDLONG = new QName(URI_DEFAULT_SCHEMA_XSD, "unsignedLong");
+    public static final QName XSD_UNSIGNEDINT = new QName(URI_DEFAULT_SCHEMA_XSD, "unsignedInt");
+    public static final QName XSD_UNSIGNEDSHORT = new QName(URI_DEFAULT_SCHEMA_XSD, "unsignedShort");
+    public static final QName XSD_UNSIGNEDBYTE = new QName(URI_DEFAULT_SCHEMA_XSD, "unsignedByte");
+    public static final QName XSD_POSITIVEINTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "positiveInteger");
+    public static final QName XSD_NEGATIVEINTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "negativeInteger");
+    public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "nonNegativeInteger");
+    public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "nonPositiveInteger");
+
+    public static final QName XSD_YEARMONTH = new QName(URI_DEFAULT_SCHEMA_XSD, "gYearMonth");
+    public static final QName XSD_MONTHDAY = new QName(URI_DEFAULT_SCHEMA_XSD, "gMonthDay");
+    public static final QName XSD_YEAR = new QName(URI_DEFAULT_SCHEMA_XSD, "gYear");
+    public static final QName XSD_MONTH = new QName(URI_DEFAULT_SCHEMA_XSD, "gMonth");
+    public static final QName XSD_DAY = new QName(URI_DEFAULT_SCHEMA_XSD, "gDay");
+    public static final QName XSD_DURATION = new QName(URI_DEFAULT_SCHEMA_XSD, "duration");
+
+    public static final QName XSD_NAME = new QName(URI_DEFAULT_SCHEMA_XSD, "Name");
+    public static final QName XSD_NCNAME = new QName(URI_DEFAULT_SCHEMA_XSD, "NCName");
+    public static final QName XSD_NMTOKEN = new QName(URI_DEFAULT_SCHEMA_XSD, "NMTOKEN");
+    public static final QName XSD_NMTOKENS = new QName(URI_DEFAULT_SCHEMA_XSD, "NMTOKENS");
+    public static final QName XSD_NOTATION = new QName(URI_DEFAULT_SCHEMA_XSD, "NOTATION");
+    public static final QName XSD_ENTITY = new QName(URI_DEFAULT_SCHEMA_XSD, "ENTITY");
+    public static final QName XSD_ENTITIES = new QName(URI_DEFAULT_SCHEMA_XSD, "ENTITIES");
+    public static final QName XSD_IDREF = new QName(URI_DEFAULT_SCHEMA_XSD, "IDREF");
+    public static final QName XSD_IDREFS = new QName(URI_DEFAULT_SCHEMA_XSD, "IDREFS");
+    public static final QName XSD_ANYURI = new QName(URI_DEFAULT_SCHEMA_XSD, "anyURI");
+    public static final QName XSD_LANGUAGE = new QName(URI_DEFAULT_SCHEMA_XSD, "language");
+    public static final QName XSD_ID = new QName(URI_DEFAULT_SCHEMA_XSD, "ID");
+    public static final QName XSD_SCHEMA = new QName(URI_DEFAULT_SCHEMA_XSD, "schema");
+
+    public static final QName XSD_NORMALIZEDSTRING = new QName(URI_DEFAULT_SCHEMA_XSD, "normalizedString");
+    public static final QName XSD_TOKEN = new QName(URI_DEFAULT_SCHEMA_XSD, "token");
 
     public static final Integer ATTRIBUTE_TYPE = new Integer(0);
     public static final Integer ANY_TYPE = new Integer(1);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java?rev=349112&r1=349111&r2=349112&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/typemap/JavaTypeMap.java Sat Nov 26 05:07:02 2005
@@ -2,6 +2,7 @@
 
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.databinding.schema.SchemaConstants;
+import org.apache.axis2.databinding.schema.types.*;
 
 import javax.xml.namespace.QName;
 import java.util.Map;
@@ -46,7 +47,99 @@
         addTypemapping(SchemaConstants.XSD_SHORT, short.class.getName());
         addTypemapping(SchemaConstants.XSD_BYTE, byte.class.getName());
         addTypemapping(SchemaConstants.XSD_ANY, OMElement.class.getName());
+
+        //anytype is mapped to the OMElement instead of the java.lang.Object
         addTypemapping(SchemaConstants.XSD_ANYTYPE, OMElement.class.getName());
+
+         //Qname maps to  jax rpc QName class
+        addTypemapping(SchemaConstants.XSD_QNAME, javax.xml.namespace.QName.class.getName());
+
+        //xsd Date is mapped to the java.util.date!
+        addTypemapping(SchemaConstants.XSD_DATE,  java.util.Date.class.getName());
+
+        // Mapping for xsd:time.  Map to Axis type Time
+        addTypemapping(SchemaConstants.XSD_TIME, Time.class.getName());
+
+        // These are the g* types (gYearMonth, etc) which map to Axis types
+        addTypemapping(SchemaConstants.XSD_YEARMONTH, YearMonth.class.getName());
+        addTypemapping(SchemaConstants.XSD_YEAR, Year.class.getName());
+        addTypemapping(SchemaConstants.XSD_MONTH, Month.class.getName());
+        addTypemapping(SchemaConstants.XSD_DAY, Day.class.getName());
+        addTypemapping(SchemaConstants.XSD_MONTHDAY, MonthDay.class.getName());
+
+// xsd:token
+        addTypemapping(SchemaConstants.XSD_TOKEN, Token.class.getName());
+
+        // a xsd:normalizedString
+        addTypemapping(SchemaConstants.XSD_NORMALIZEDSTRING, NormalizedString.class.getName());
+
+        // a xsd:unsignedLong
+        addTypemapping(SchemaConstants.XSD_UNSIGNEDLONG, UnsignedLong.class.getName());
+
+        // a xsd:unsignedInt
+        addTypemapping(SchemaConstants.XSD_UNSIGNEDINT, UnsignedInt.class.getName());
+
+        // a xsd:unsignedShort
+        addTypemapping(SchemaConstants.XSD_UNSIGNEDSHORT, UnsignedShort.class.getName());
+
+        // a xsd:unsignedByte
+        addTypemapping(SchemaConstants.XSD_UNSIGNEDBYTE, UnsignedByte.class.getName());
+
+        // a xsd:nonNegativeInteger
+        addTypemapping(SchemaConstants.XSD_NONNEGATIVEINTEGER, NonNegativeInteger.class.getName());
+
+        // a xsd:negativeInteger
+        addTypemapping(SchemaConstants.XSD_NEGATIVEINTEGER, NegativeInteger.class.getName() );
+
+        // a xsd:positiveInteger
+        addTypemapping(SchemaConstants.XSD_POSITIVEINTEGER, PositiveInteger.class.getName());
+
+        // a xsd:nonPositiveInteger
+        addTypemapping(SchemaConstants.XSD_NONPOSITIVEINTEGER, NonPositiveInteger.class.getName());
+
+        // a xsd:Name
+        addTypemapping(SchemaConstants.XSD_NAME, Name.class.getName());
+
+        // a xsd:NCName
+        addTypemapping(SchemaConstants.XSD_NCNAME, NCName.class.getName());
+
+         // a xsd:ID
+        addTypemapping(SchemaConstants.XSD_ID, Id.class.getName());
+
+        // a xml:lang
+       // addTypemapping(SchemaConstants.XML_LANG,Language.class.getName());
+
+        // a xsd:language
+        addTypemapping(SchemaConstants.XSD_LANGUAGE, Language.class.getName());
+
+        // a xsd:NmToken
+        addTypemapping(SchemaConstants.XSD_NMTOKEN, NMToken.class.getName());
+
+        // a xsd:NmTokens
+        addTypemapping(SchemaConstants.XSD_NMTOKENS, NMTokens.class.getName());
+
+        // a xsd:NOTATION
+        addTypemapping(SchemaConstants.XSD_NOTATION, Notation.class.getName());
+
+        // a xsd:XSD_ENTITY
+        addTypemapping(SchemaConstants.XSD_ENTITY, Entity.class.getName());
+
+        // a xsd:XSD_ENTITIES
+        addTypemapping(SchemaConstants.XSD_ENTITIES, Entities.class.getName());
+
+        // a xsd:XSD_IDREF
+        addTypemapping(SchemaConstants.XSD_IDREF, IDRef.class.getName());
+
+        // a xsd:XSD_XSD_IDREFS
+        addTypemapping(SchemaConstants.XSD_IDREFS, IDRefs.class.getName());
+
+        // a xsd:Duration
+        addTypemapping(SchemaConstants.XSD_DURATION, Duration.class.getName() );
+
+        // a xsd:anyURI
+        addTypemapping(SchemaConstants.XSD_ANYURI, URI.class.getName() );
+
+
 
     }
     private static void addTypemapping(QName name,String str) {

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Day.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Day.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Day.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Day.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2002-2004 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.schema.types;
+
+
+import java.text.NumberFormat;
+
+/**
+ * Implementation of the XML Schema type gDay
+ *
+ * @author Tom Jordahl <tomj@macromedia.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#gDay">XML Schema 3.2.13</a>
+ */
+public class Day implements java.io.Serializable {
+    int day;
+    String timezone = null;
+
+    /**
+     * Constructs a Day with the given values
+     * No timezone is specified
+     */
+    public Day(int day) throws NumberFormatException {
+        setValue(day);
+    }
+
+    /**
+     * Constructs a Day with the given values, including a timezone string
+     * The timezone is validated but not used.
+     */
+    public Day(int day, String timezone)
+        throws NumberFormatException {
+        setValue(day, timezone);
+    }
+
+    /**
+     * Construct a Day from a String in the format ---DD[timezone]
+     */
+    public Day(String source) throws NumberFormatException {
+        if (source.length() < 5) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badDay00"));
+        }
+
+        if (source.charAt(0) != '-' ||
+            source.charAt(1) != '-' ||
+            source.charAt(2) != '-' ) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badDay00"));
+        }
+
+        setValue(Integer.parseInt(source.substring(3,5)),
+                 source.substring(5));
+    }
+
+    public int getDay() {
+        return day;
+    }
+
+    /**
+     * Set the day
+     */
+    public void setDay(int day) {
+        // validate day
+        if (day < 1 || day > 31) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badDay00"));
+        }
+        this.day = day;
+    }
+
+    public String getTimezone() {
+        return timezone;
+    }
+
+    public void setTimezone(String timezone) {
+        // validate timezone
+        if (timezone != null && timezone.length() > 0) {
+            // Format [+/-]HH:MM
+            if (timezone.charAt(0)=='+' || (timezone.charAt(0)=='-')) {
+                    if (timezone.length() != 6 ||
+                        !Character.isDigit(timezone.charAt(1)) ||
+                        !Character.isDigit(timezone.charAt(2)) ||
+                        timezone.charAt(3) != ':'              ||
+                        !Character.isDigit(timezone.charAt(4)) ||
+                        !Character.isDigit(timezone.charAt(5)))
+                        throw new NumberFormatException();
+                               // Messages.getMessage("badTimezone00"));
+
+            } else if (!timezone.equals("Z")) {
+                throw new NumberFormatException();
+                       // Messages.getMessage("badTimezone00"));
+            }
+            // if we got this far, its good
+            this.timezone = timezone;
+        }
+    }
+
+    public void setValue(int day, String timezone)
+        throws NumberFormatException {
+        setDay(day);
+        setTimezone(timezone);
+    }
+
+    public void setValue(int day) throws NumberFormatException {
+        setDay(day);
+    }
+
+    public String toString() {
+        // use NumberFormat to ensure leading zeros
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setGroupingUsed(false);
+
+        // Day
+        nf.setMinimumIntegerDigits(2);
+        String s = "---"  + nf.format(day);
+
+        // timezone
+        if (timezone != null) {
+            s = s + timezone;
+        }
+        return s;
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof Day)) return false;
+        Day other = (Day) obj;
+        if (obj == null) return false;
+        if (this == obj) return true;
+
+        boolean equals = (this.day == other.day);
+        if (timezone != null) {
+            equals = equals && timezone.equals(other.timezone);
+        }
+        return equals;
+    }
+
+    /**
+     * Return the value of day XORed with the hashCode of timezone
+     * iff one is defined.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        return null == timezone ? day : day ^ timezone.hashCode();
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Duration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Duration.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Duration.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Duration.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,496 @@
+/*
+ * Copyright 2002-2004 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.schema.types;
+
+import java.util.Calendar;
+
+/**
+ * Implementation of the XML Schema type duration. Duration supports a minimum
+ * fractional second precision of milliseconds.
+ *
+ * @author Wes Moulder <wes@themindelectric.com>
+ * @author Dominik Kacprzak (dominik@opentoolbox.com)
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#duration">XML Schema 3.2.6</a>
+ */
+public class Duration implements java.io.Serializable {
+    boolean isNegative = false;
+    int years;
+    int months;
+    int days;
+    int hours;
+    int minutes;
+    double seconds;
+
+    /**
+     * Default no-arg constructor
+     */
+    public Duration() {
+    }
+
+    /**
+     * @param negative
+     * @param aYears
+     * @param aMonths
+     * @param aDays
+     * @param aHours
+     * @param aMinutes
+     * @param aSeconds
+     */
+    public Duration(boolean negative, int aYears, int aMonths, int aDays,
+                    int aHours, int aMinutes, double aSeconds) {
+        isNegative = negative;
+        years = aYears;
+        months = aMonths;
+        days = aDays;
+        hours = aHours;
+        minutes = aMinutes;
+        setSeconds(aSeconds);
+    }
+
+    /**
+     * Constructs Duration from a String in an xsd:duration format -
+     * PnYnMnDTnHnMnS.
+     *
+     * @param duration String
+     * @throws SchemaException if the string doesn't parse correctly.
+     */
+    public Duration(String duration) throws IllegalArgumentException {
+        int position = 1;
+        int timePosition = duration.indexOf("T");
+
+        // P is required but P by itself is invalid
+        if (duration.indexOf("P") == -1 || duration.equals("P")) {
+            throw new IllegalArgumentException();
+                   // Messages.getMessage("badDuration"));
+        }
+
+        // if present, time cannot be empty
+        if (duration.lastIndexOf("T") == duration.length() - 1) {
+            throw new IllegalArgumentException();
+//                    Messages.getMessage("badDuration"));
+        }
+
+        // check the sign
+        if (duration.startsWith("-")) {
+            isNegative = true;
+            position++;
+        }
+
+        // parse time part
+        if (timePosition != -1) {
+            parseTime(duration.substring(timePosition + 1));
+        } else {
+            timePosition = duration.length();
+        }
+
+        // parse date part
+        if (position != timePosition) {
+            parseDate(duration.substring(position, timePosition));
+        }
+    }
+
+    /**
+     * Constructs Duration from a Calendar.
+     *
+     * @param calendar Calendar
+     * @throws IllegalArgumentException if the calendar object does not
+     * represent any date nor time.
+     */
+    public Duration(boolean negative, Calendar calendar) throws
+            IllegalArgumentException {
+        this.isNegative = negative;
+        this.years = calendar.get(Calendar.YEAR);
+        this.months = calendar.get(Calendar.MONTH);
+        this.days = calendar.get(Calendar.DATE);
+        this.hours = calendar.get(Calendar.HOUR);
+        this.minutes = calendar.get(Calendar.MINUTE);
+        this.seconds = calendar.get(Calendar.SECOND);
+        this.seconds += ((double) calendar.get(Calendar.MILLISECOND)) / 100;
+        if (years == 0 && months == 0 && days == 0 && hours == 0 &&
+            minutes == 0 && seconds == 0) {
+            throw new IllegalArgumentException();
+                    //Messages.getMessage("badCalendarForDuration"));
+        }
+    }
+
+    /**
+     * This method parses the time portion of a String that represents
+     * xsd:duration - nHnMnS.
+     *
+     * @param time
+     * @throws IllegalArgumentException if time does not match pattern
+     *
+     */
+    public void parseTime(String time) throws IllegalArgumentException {
+        if (time.length() == 0 || time.indexOf("-") != -1) {
+            throw new IllegalArgumentException();
+                    //Messages.getMessage("badTimeDuration"));
+        }
+
+        // check if time ends with either H, M, or S
+        if (!time.endsWith("H") && !time.endsWith("M") && !time.endsWith("S")) {
+            throw new IllegalArgumentException();
+                    //Messages.getMessage("badTimeDuration"));
+        }
+
+        try {
+            // parse string and extract hours, minutes, and seconds
+            int start = 0;
+
+            // Hours
+            int end = time.indexOf("H");
+            // if there is H in a string but there is no value for hours,
+            // throw an exception
+            if (start == end) {
+                throw new IllegalArgumentException();
+                        //Messages.getMessage("badTimeDuration"));
+            }
+            if (end != -1) {
+                hours = Integer.parseInt(time.substring(0, end));
+                start = end + 1;
+            }
+
+            // Minutes
+            end = time.indexOf("M");
+            // if there is M in a string but there is no value for hours,
+            // throw an exception
+            if (start == end) {
+                throw new IllegalArgumentException();
+//                        Messages.getMessage("badTimeDuration"));
+            }
+
+            if (end != -1) {
+                minutes = Integer.parseInt(time.substring(start, end));
+                start = end + 1;
+            }
+
+            // Seconds
+            end = time.indexOf("S");
+            // if there is S in a string but there is no value for hours,
+            // throw an exception
+            if (start == end) {
+                throw new IllegalArgumentException();
+                        //Messages.getMessage("badTimeDuration"));
+            }
+
+            if (end != -1) {
+                setSeconds(Double.parseDouble(time.substring(start, end)));
+            }
+        } catch (NumberFormatException e) {
+            throw new IllegalArgumentException();
+                    //Messages.getMessage("badTimeDuration"));
+        }
+    }
+
+    /**
+     * This method parses the date portion of a String that represents
+     * xsd:duration - nYnMnD.
+     *
+     * @param date
+     * @throws IllegalArgumentException if date does not match pattern
+     *
+     */
+    public void parseDate(String date) throws IllegalArgumentException {
+        if (date.length() == 0 || date.indexOf("-") != -1) {
+            throw new IllegalArgumentException();
+                    //Messages.getMessage("badDateDuration"));
+        }
+
+        // check if date string ends with either Y, M, or D
+        if (!date.endsWith("Y") && !date.endsWith("M") && !date.endsWith("D")) {
+            throw new IllegalArgumentException();
+                    //Messages.getMessage("badDateDuration"));
+        }
+
+        // catch any parsing exception
+        try {
+            // parse string and extract years, months, days
+            int start = 0;
+            int end = date.indexOf("Y");
+
+            // if there is Y in a string but there is no value for years,
+            // throw an exception
+            if (start == end) {
+                throw new IllegalArgumentException();
+                       // Messages.getMessage("badDateDuration"));
+            }
+            if (end != -1) {
+                years = Integer.parseInt(date.substring(0, end));
+                start = end + 1;
+            }
+
+            // months
+            end = date.indexOf("M");
+            // if there is M in a string but there is no value for months,
+            // throw an exception
+            if (start == end) {
+                throw new IllegalArgumentException();
+                        //Messages.getMessage("badDateDuration"));
+            }
+            if (end != -1) {
+                months = Integer.parseInt(date.substring(start, end));
+                start = end + 1;
+            }
+
+            end = date.indexOf("D");
+            // if there is D in a string but there is no value for days,
+            // throw an exception
+            if (start == end) {
+                throw new IllegalArgumentException();
+                       // Messages.getMessage("badDateDuration"));
+            }
+            if (end != -1) {
+                days = Integer.parseInt(date.substring(start, end));
+            }
+        } catch (NumberFormatException e) {
+            throw new IllegalArgumentException();
+                    //Messages.getMessage("badDateDuration"));
+        }
+    }
+
+    /**
+     *
+     */
+    public boolean isNegative() {
+        return isNegative;
+    }
+
+    /**
+     *
+     */
+    public int getYears() {
+        return years;
+    }
+
+    /**
+     *
+     */
+    public int getMonths() {
+        return months;
+    }
+
+    /**
+     *
+     */
+    public int getDays() {
+        return days;
+    }
+
+    /**
+     *
+     */
+    public int getHours() {
+        return hours;
+    }
+
+    /**
+     *
+     */
+    public int getMinutes() {
+        return minutes;
+    }
+
+    /**
+     *
+     */
+    public double getSeconds() {
+        return seconds;
+    }
+
+    /**
+     * @param negative
+     */
+    public void setNegative(boolean negative) {
+        isNegative = negative;
+    }
+
+    /**
+     * @param years
+     */
+    public void setYears(int years) {
+        this.years = years;
+    }
+
+    /**
+     * @param months
+     */
+    public void setMonths(int months) {
+        this.months = months;
+    }
+
+    /**
+     * @param days
+     */
+    public void setDays(int days) {
+        this.days = days;
+    }
+
+    /**
+     * @param hours
+     */
+    public void setHours(int hours) {
+        this.hours = hours;
+    }
+
+    /**
+     * @param minutes
+     */
+    public void setMinutes(int minutes) {
+        this.minutes = minutes;
+    }
+
+    /**
+     * @param seconds
+     * @deprecated use {@link #setSeconds(double) setSeconds(double)}
+     * instead
+     */
+    public void setSeconds(int seconds) {
+        this.seconds = seconds;
+    }
+
+    /**
+     * Sets the seconds. NOTE: The fractional value of seconds is rounded up to
+     * milliseconds.
+     *
+     * @param seconds double
+     */
+    public void setSeconds(double seconds) {
+        this.seconds = ((double) (Math.round(seconds * 100))) / 100;
+    }
+
+    /**
+     * This returns the xml representation of an xsd:duration object.
+     */
+    public String toString() {
+        StringBuffer duration = new StringBuffer();
+
+        duration.append("P");
+
+        if (years != 0) {
+            duration.append(years + "Y");
+        }
+        if (months != 0) {
+            duration.append(months + "M");
+        }
+        if (days != 0) {
+            duration.append(days + "D");
+        }
+        if (hours != 0 || minutes != 0 || seconds != 0.0) {
+            duration.append("T");
+
+            if (hours != 0) {
+                duration.append(hours + "H");
+
+            }
+            if (minutes != 0) {
+                duration.append(minutes + "M");
+
+            }
+            if (seconds != 0) {
+                if (seconds == (int) seconds) {
+                    duration.append((int) seconds + "S");
+                } else {
+                    duration.append(seconds + "S");
+                }
+            }
+        }
+
+        if (duration.length() == 1) {
+            duration.append("T0S");
+        }
+
+        if (isNegative) {
+            duration.insert(0, "-");
+        }
+
+        return duration.toString();
+    }
+
+    /**
+     * The equals method compares the time represented by duration object, not
+     * its string representation.
+     * Hence, a duration object representing 65 minutes is considered equal to a
+     * duration object representing 1 hour and 5 minutes.
+     *
+     * @param object
+     */
+    public boolean equals(Object object) {
+        if (!(object instanceof Duration)) {
+            return false;
+        }
+
+        Calendar thisCalendar = this.getAsCalendar();
+        Duration duration = (Duration) object;
+
+        return this.isNegative == duration.isNegative &&
+                this.getAsCalendar().equals(duration.getAsCalendar());
+    }
+
+    public int hashCode() {
+        int hashCode = 0;
+
+        if (isNegative) {
+            hashCode++;
+        }
+        hashCode += years;
+        hashCode += months;
+        hashCode += days;
+        hashCode += hours;
+        hashCode += minutes;
+        hashCode += seconds;
+        // milliseconds
+        hashCode += (seconds * 100) % 100;
+
+        return hashCode;
+    }
+
+    /**
+     * Returns duration as a calendar.  Due to the way a Calendar class works,
+     * the values for particular fields may not be the same as obtained through
+     * getter methods.  For example, if a duration's object getMonths
+     * returns 20, a similar call on a calendar object will return 1 year and
+     * 8 months.
+     *
+     * @return Calendar
+     */
+    public Calendar getAsCalendar() {
+        return getAsCalendar(Calendar.getInstance());
+    }
+
+    /**
+     * Returns duration as a calendar.  Due to the way a Calendar class works,
+     * the values for particular fields may not be the same as obtained through
+     * getter methods.  For example, if a Duration's object getMonths
+     * returns 20, a similar call on a Calendar object will return 1 year and
+     * 8 months.
+     *
+     * @param startTime Calendar
+     * @return Calendar
+     */
+    public Calendar getAsCalendar(Calendar startTime) {
+        Calendar ret = (Calendar) startTime.clone();
+        ret.set(Calendar.YEAR, years);
+        ret.set(Calendar.MONTH, months);
+        ret.set(Calendar.DATE, days);
+        ret.set(Calendar.HOUR, hours);
+        ret.set(Calendar.MINUTE, minutes);
+        ret.set(Calendar.SECOND, (int) seconds);
+        ret.set(Calendar.MILLISECOND,
+                (int) (seconds * 100 - Math.round(seconds) * 100));
+        return ret;
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entities.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entities.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entities.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entities.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+import java.util.StringTokenizer;
+
+/**
+ * Custom class for supporting XSD data type Entities
+ * 
+ * @author Davanum Srinivas <dims@yahoo.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#ENTITIES">XML Schema 3.3.12 ENTITIES</a>
+ */
+public class Entities extends NCName {
+    private Entity[] entities;
+    
+    public Entities() {
+        super();
+    }
+    /**
+     * ctor for Entities
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public Entities (String stValue) throws IllegalArgumentException {
+        StringTokenizer tokenizer = new StringTokenizer(stValue);
+        int count = tokenizer.countTokens();
+        entities = new Entity[count];
+        for(int i=0;i<count;i++){
+            entities[i] = new Entity(tokenizer.nextToken());
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entity.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entity.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entity.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Entity.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+
+
+/**
+ * Custom class for supporting XSD data type Entity
+ * 
+ * @author Davanum Srinivas <dims@yahoo.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#ENTITY">XML Schema 3.3.11 ENTITY</a>
+ */
+public class Entity extends NCName {
+    public Entity() {
+        super();
+    }
+    /**
+     * ctor for Entity
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public Entity (String stValue) throws IllegalArgumentException {
+        super(stValue);
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/HexBinary.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/HexBinary.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/HexBinary.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/HexBinary.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2001-2004 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.schema.types ;
+
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Custom class for supporting primitive XSD data type hexBinary.
+ *
+ * @author Davanum Srinivas <dims@yahoo.com>
+ */
+public class HexBinary extends Object implements java.io.Serializable{
+
+    byte[] m_value = null;
+
+    public HexBinary() {
+    }
+
+    public HexBinary(String string){
+        m_value = decode(string);
+    }
+
+    public HexBinary(byte[] bytes){
+        m_value = bytes;
+    }
+
+    public byte[] getBytes(){
+        return m_value;
+    }
+
+    public String toString(){
+        return encode(m_value);
+    }
+
+    public int hashCode(){
+        //TODO: How do we hash this?
+        return super.hashCode();
+    }
+
+    public boolean equals(Object object){
+        //TODO: Is this good enough?
+        String s1 = object.toString();
+        String s2 = this.toString();
+        return s1.equals(s2);
+    }
+
+   // public static final String ERROR_ODD_NUMBER_OF_DIGITS =
+            //Messages.getMessage("oddDigits00");
+    //public static final String ERROR_BAD_CHARACTER_IN_HEX_STRING =
+    //        Messages.getMessage("badChars01");
+
+    // Code from Ajp11, from Apache's JServ
+
+    // Table for HEX to DEC byte translation
+    public static final int[] DEC = {
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        00, 01, 02, 03, 04, 05, 06, 07,  8,  9, -1, -1, -1, -1, -1, -1,
+        -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    };
+
+    /**
+     * Convert a String of hexadecimal digits into the corresponding
+     * byte array by encoding each two hexadecimal digits as a byte.
+     *
+     * @param digits Hexadecimal digits representation
+     *
+     * @exception IllegalArgumentException if an invalid hexadecimal digit
+     *  is found, or the input string contains an odd number of hexadecimal
+     *  digits
+     */
+    public static byte[] decode(String digits) {
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        for (int i = 0; i < digits.length(); i += 2) {
+            char c1 = digits.charAt(i);
+            if ((i+1) >= digits.length())
+                throw new IllegalArgumentException
+                    ();//ERROR_ODD_NUMBER_OF_DIGITS);
+            char c2 = digits.charAt(i + 1);
+            byte b = 0;
+            if ((c1 >= '0') && (c1 <= '9'))
+                b += ((c1 - '0') * 16);
+            else if ((c1 >= 'a') && (c1 <= 'f'))
+                b += ((c1 - 'a' + 10) * 16);
+            else if ((c1 >= 'A') && (c1 <= 'F'))
+                b += ((c1 - 'A' + 10) * 16);
+            else
+                throw new IllegalArgumentException
+                    ();//ERROR_BAD_CHARACTER_IN_HEX_STRING);
+            if ((c2 >= '0') && (c2 <= '9'))
+                b += (c2 - '0');
+            else if ((c2 >= 'a') && (c2 <= 'f'))
+                b += (c2 - 'a' + 10);
+            else if ((c2 >= 'A') && (c2 <= 'F'))
+                b += (c2 - 'A' + 10);
+            else
+                throw new IllegalArgumentException
+                    ();//ERROR_BAD_CHARACTER_IN_HEX_STRING);
+            baos.write(b);
+        }
+        return (baos.toByteArray());
+
+    }
+
+
+    /**
+     * Convert a byte array into a printable format containing a
+     * String of hexadecimal digit characters (two per byte).
+     *
+     * @param bytes Byte array representation
+     */
+    public static String encode(byte bytes[]) {
+
+        StringBuffer sb = new StringBuffer(bytes.length * 2);
+        for (int i = 0; i < bytes.length; i++) {
+            sb.append(convertDigit((int) (bytes[i] >> 4)));
+            sb.append(convertDigit((int) (bytes[i] & 0x0f)));
+        }
+        return (sb.toString());
+
+    }
+
+    /**
+     * Convert 4 hex digits to an int, and return the number of converted
+     * bytes.
+     *
+     * @param hex Byte array containing exactly four hexadecimal digits
+     *
+     * @exception IllegalArgumentException if an invalid hexadecimal digit
+     *  is included
+     */
+    public static int convert2Int( byte[] hex ) {
+        // Code from Ajp11, from Apache's JServ
+
+        // assert b.length==4
+        // assert valid data
+        int len;
+        if(hex.length < 4 ) return 0;
+        if( DEC[hex[0]]<0 )
+            throw new IllegalArgumentException();//ERROR_BAD_CHARACTER_IN_HEX_STRING);
+        len = DEC[hex[0]];
+        len = len << 4;
+        if( DEC[hex[1]]<0 )
+            throw new IllegalArgumentException();//ERROR_BAD_CHARACTER_IN_HEX_STRING);
+        len += DEC[hex[1]];
+        len = len << 4;
+        if( DEC[hex[2]]<0 )
+            throw new IllegalArgumentException();//ERROR_BAD_CHARACTER_IN_HEX_STRING);
+        len += DEC[hex[2]];
+        len = len << 4;
+        if( DEC[hex[3]]<0 )
+            throw new IllegalArgumentException();//ERROR_BAD_CHARACTER_IN_HEX_STRING);
+        len += DEC[hex[3]];
+        return len;
+    }
+
+    /**
+     * [Private] Convert the specified value (0 .. 15) to the corresponding
+     * hexadecimal digit.
+     *
+     * @param value Value to be converted
+     */
+    private static char convertDigit(int value) {
+
+        value &= 0x0f;
+        if (value >= 10)
+            return ((char) (value - 10 + 'a'));
+        else
+            return ((char) (value + '0'));
+
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRef.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRef.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRef.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRef.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+
+
+/**
+ * Custom class for supporting XSD data type IDRef
+ * 
+ * @author Davanum Srinivas <dims@yahoo.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#IDREF">XML Schema 3.3.10 IDREFS</a>
+ */
+public class IDRef extends NCName {
+    public IDRef() {
+        super();
+    }
+    /**
+     * ctor for IDRef
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public IDRef (String stValue) throws IllegalArgumentException {
+        super(stValue);
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRefs.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRefs.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRefs.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/IDRefs.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Custom class for supporting XSD data type IDRefs
+ *
+ * @author Davanum Srinivas <dims@yahoo.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#IDREFS">XML Schema 3.3.10 IDREFS</a>
+ */
+public class IDRefs extends NCName {
+    private IDRef[] idrefs;
+
+    public IDRefs() {
+        super();
+    }
+    /**
+     * ctor for IDRefs
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public IDRefs (String stValue) throws IllegalArgumentException {
+        setValue(stValue);
+    }
+
+    public void setValue(String stValue) {
+        StringTokenizer tokenizer = new StringTokenizer(stValue);
+        int count = tokenizer.countTokens();
+        idrefs = new IDRef[count];
+        for(int i=0;i<count;i++){
+            idrefs[i] = new IDRef(tokenizer.nextToken());
+        }
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < idrefs.length; i++) {
+            IDRef ref = idrefs[i];
+            if (i > 0) buf.append(" ");
+            buf.append(ref.toString());
+        }
+        return buf.toString();
+    }
+
+    /**
+     * IDREFs can be equal without having identical ordering because
+     * they represent a set of references.  Hence we have to compare
+     * values here as a set, not a list.
+     *
+     * @param object an <code>Object</code> value
+     * @return a <code>boolean</code> value
+     */
+    public boolean equals(Object object) {
+        if (object == this) {
+            return true;        // succeed quickly, when possible
+        }
+        if (object instanceof IDRefs) {
+            IDRefs that = (IDRefs)object;
+            if (this.idrefs.length == that.idrefs.length) {
+                Set ourSet = new HashSet(Arrays.asList(this.idrefs));
+                Set theirSet = new HashSet(Arrays.asList(that.idrefs));
+                return ourSet.equals(theirSet);
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Returns the sum of the hashcodes of the underlying idrefs, an
+     * operation which is not sensitive to ordering.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        int hash = 0;
+        for (int i = 0; i < idrefs.length; i++) {
+            hash += idrefs[i].hashCode();
+        }
+        return hash;
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Id.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Id.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Id.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Id.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+
+/**
+ * Custom class for supporting XSD data type ID
+ * The base type of Id is NCName.
+ *
+ * @author Eddie Pick <eddie@pick.eu.org>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#ID">XML Schema 3.3.8</a>
+ */
+public class Id extends NCName {
+
+    public Id() {
+        super();
+    }
+
+    /**
+     * ctor for Id
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public Id(String stValue) throws IllegalArgumentException {
+        try {
+            setValue(stValue);
+        }
+        catch (IllegalArgumentException e) {
+            // recast normalizedString exception as token exception
+            throw new IllegalArgumentException();
+                    //Messages.getMessage("badIdType00") + "data=[" +
+                    //stValue + "]");
+        }
+    }
+
+    /**
+     *
+     * validates the data and sets the value for the object.
+     * @param Token String value
+     * @throws IllegalArgumentException if invalid format
+     */
+    public void setValue(String stValue) throws IllegalArgumentException {
+        if (Id.isValid(stValue) == false)
+            throw new IllegalArgumentException(
+              // Messages.getMessage("badIdType00") +
+               " data=[" + stValue + "]");
+        m_value = stValue;
+    }
+
+    /**
+     *
+     * validate the value against the xsd definition
+     *
+     * Same validation as NCName for the time being
+     */
+    public static boolean isValid(String stValue) {
+      return NCName.isValid(stValue);
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Language.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Language.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Language.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Language.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+
+/**
+ * Custom class for supporting XSD data type language
+ * language represents natural language identifiers as defined by [RFC 1766]. 
+ * The value space of language is the set of all strings that are valid language identifiers 
+ * as defined in the language identification section of [XML 1.0 (Second Edition)]. 
+ * The lexical space of language is the set of all strings that are valid language identifiers 
+ * as defined in the language identification section of [XML 1.0 (Second Edition)]. 
+ * The base type of language is token. 
+ *
+ * @author Eddie Pick <eddie@pick.eu.org>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#language">XML Schema 3.3.3</a>
+ */
+public class Language extends Token {
+
+    public Language() {
+        super();
+    }
+
+    /**
+     * ctor for Language
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public Language(String stValue) throws IllegalArgumentException {
+        try {
+            setValue(stValue);
+        }
+        catch (IllegalArgumentException e) {
+            // recast normalizedString exception as token exception
+            throw new IllegalArgumentException(
+//                Messages.getMessage("badLanguage00") +
+                  "data=[" + stValue + "]");
+        }
+    }
+
+   /**
+    *
+    * validate the value against the xsd definition
+    * TODO
+    * @see <a href="http://www.ietf.org/rfc/rfc1766.txt">RFC1766</a>
+    * Language-Tag = Primary-tag *( "-" Subtag )
+    * Primary-tag = 1*8ALPHA
+    * Subtag = 1*8ALPHA
+    */
+    public static boolean isValid(String stValue) {
+        return true;
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Month.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Month.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Month.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Month.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2002-2004 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.schema.types;
+
+
+import java.text.NumberFormat;
+
+/**
+ * Implementation of the XML Schema type gMonth
+ *
+ * @author Tom Jordahl <tomj@macromedia.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#gMonth">XML Schema 3.2.14</a>
+ */
+public class Month implements java.io.Serializable {
+    int month;
+    String timezone = null;
+
+    /**
+     * Constructs a Month with the given values
+     * No timezone is specified
+     */
+    public Month(int month) throws NumberFormatException {
+        setValue(month);
+    }
+
+    /**
+     * Constructs a Month with the given values, including a timezone string
+     * The timezone is validated but not used.
+     */
+    public Month(int month, String timezone)
+        throws NumberFormatException {
+        setValue(month, timezone);
+    }
+
+    /**
+     * Construct a Month from a String in the format --MM--[timezone]
+     */
+    public Month(String source) throws NumberFormatException {
+        if (source.length() < (6)) {
+            throw new NumberFormatException();
+                   // Messages.getMessage("badMonth00"));
+        }
+
+        if (source.charAt(0) != '-' ||
+            source.charAt(1) != '-' ||
+            source.charAt(4) != '-' ||
+            source.charAt(5) != '-' ) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badMonth00"));
+        }
+
+        setValue(Integer.parseInt(source.substring(2,4)),
+                 source.substring(6));
+    }
+
+    public int getMonth() {
+        return month;
+    }
+
+    public void setMonth(int month) {
+        // validate month
+        if (month < 1 || month > 12) {
+            throw new NumberFormatException();
+                   // Messages.getMessage("badMonth00"));
+        }
+        this.month = month;
+    }
+
+    public String getTimezone() {
+        return timezone;
+    }
+
+    public void setTimezone(String timezone) {
+        // validate timezone
+        if (timezone != null && timezone.length() > 0) {
+            // Format [+/-]HH:MM
+            if (timezone.charAt(0)=='+' || (timezone.charAt(0)=='-')) {
+                    if (timezone.length() != 6 ||
+                        !Character.isDigit(timezone.charAt(1)) ||
+                        !Character.isDigit(timezone.charAt(2)) ||
+                        timezone.charAt(3) != ':'              ||
+                        !Character.isDigit(timezone.charAt(4)) ||
+                        !Character.isDigit(timezone.charAt(5)))
+                        throw new NumberFormatException();
+                                //Messages.getMessage("badTimezone00"));
+
+            } else if (!timezone.equals("Z")) {
+                throw new NumberFormatException();
+                        //Messages.getMessage("badTimezone00"));
+            }
+            // if we got this far, its good
+            this.timezone = timezone;
+        }
+    }
+
+    public void setValue(int month, String timezone) throws NumberFormatException {
+        setMonth(month);
+        setTimezone(timezone);
+    }
+
+    public void setValue(int month) throws NumberFormatException {
+        setMonth(month);
+    }
+
+    public String toString() {
+        // use NumberFormat to ensure leading zeros
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setGroupingUsed(false);
+
+        // month
+        nf.setMinimumIntegerDigits(2);
+        String s = "--" + nf.format(month) + "--";
+
+        // timezone
+        if (timezone != null) {
+            s = s + timezone;
+        }
+        return s;
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof Month)) return false;
+        Month other = (Month) obj;
+        if (obj == null) return false;
+        if (this == obj) return true;
+
+        boolean equals = (this.month == other.month);
+        if (timezone != null) {
+            equals = equals && timezone.equals(other.timezone);
+        }
+        return equals;
+    }
+
+    /**
+     * Return the value of month XORed with the hashCode of timezone
+     * iff one is defined.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        return null == timezone ? month : month ^ timezone.hashCode();
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/MonthDay.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/MonthDay.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/MonthDay.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/MonthDay.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2002-2004 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.schema.types;
+
+
+import java.text.NumberFormat;
+
+/**
+ * Implementation of the XML Schema type gMonthDay
+ *
+ * @author Tom Jordahl <tomj@macromedia.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#gMonthDay">XML Schema 3.2.12</a>
+ */
+public class MonthDay implements java.io.Serializable {
+    int month;
+    int day;
+    String timezone = null;
+
+    /**
+     * Constructs a MonthDay with the given values
+     * No timezone is specified
+     */
+    public MonthDay(int month, int day)
+        throws NumberFormatException {
+        setValue(month, day);
+    }
+
+    /**
+     * Constructs a MonthDay with the given values, including a timezone string
+     * The timezone is validated but not used.
+     */
+    public MonthDay(int month, int day, String timezone)
+        throws NumberFormatException {
+        setValue(month, day, timezone);
+    }
+
+    /**
+     * Construct a MonthDay from a String in the format --MM-DD[timezone]
+     */
+    public MonthDay(String source) throws NumberFormatException {
+        if (source.length() < 6) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badMonthDay00"));
+        }
+
+        if (source.charAt(0) != '-' ||
+            source.charAt(1) != '-' ||
+            source.charAt(4) != '-' ) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badMonthDay00"));
+        }
+
+        setValue(Integer.parseInt(source.substring(2,4)),
+                 Integer.parseInt(source.substring(5,7)),
+                 source.substring(7));
+    }
+
+    public int getMonth() {
+        return month;
+    }
+
+    public void setMonth(int month) {
+        // validate month
+        if (month < 1 || month > 12) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badMonthDay00"));
+        }
+        this.month = month;
+    }
+
+    public int getDay() {
+        return day;
+    }
+
+    /**
+     * Set the day
+     * NOTE: if the month isn't set yet, the day isn't validated
+     */
+    public void setDay(int day) {
+        // validate day
+        if (day < 1 || day > 31) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badMonthDay00"));
+        }
+        // 30 days has September... All the rest have 31 (except Feb!)
+        // NOTE: if month isn't set, we don't validate day.
+        if ((month == 2 && day > 29) ||
+           ((month == 9 || month == 4 || month == 6 || month == 11) && day > 30)) {
+            throw new NumberFormatException();
+                   // Messages.getMessage("badMonthDay00"));
+        }
+        this.day = day;
+    }
+
+    public String getTimezone() {
+        return timezone;
+    }
+
+    public void setTimezone(String timezone) {
+        // validate timezone
+        if (timezone != null && timezone.length() > 0) {
+            // Format [+/-]HH:MM
+            if (timezone.charAt(0)=='+' || (timezone.charAt(0)=='-')) {
+                    if (timezone.length() != 6 ||
+                        !Character.isDigit(timezone.charAt(1)) ||
+                        !Character.isDigit(timezone.charAt(2)) ||
+                        timezone.charAt(3) != ':'              ||
+                        !Character.isDigit(timezone.charAt(4)) ||
+                        !Character.isDigit(timezone.charAt(5)))
+                        throw new NumberFormatException();
+                               // Messages.getMessage("badTimezone00"));
+
+            } else if (!timezone.equals("Z")) {
+                throw new NumberFormatException();
+                        //Messages.getMessage("badTimezone00"));
+            }
+            // if we got this far, its good
+            this.timezone = timezone;
+        }
+    }
+
+    public void setValue(int month, int day, String timezone)
+        throws NumberFormatException {
+        setMonth(month);
+        setDay(day);
+        setTimezone(timezone);
+    }
+
+    public void setValue(int month, int day) throws NumberFormatException {
+        setMonth(month);
+        setDay(day);
+    }
+
+    public String toString() {
+        // use NumberFormat to ensure leading zeros
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setGroupingUsed(false);
+
+        // month & Day: --MM-DD
+        nf.setMinimumIntegerDigits(2);
+        String s = "--" + nf.format(month) + "-" + nf.format(day);
+
+        // timezone
+        if (timezone != null) {
+            s = s + timezone;
+        }
+        return s;
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof MonthDay)) return false;
+        MonthDay other = (MonthDay) obj;
+        if (obj == null) return false;
+        if (this == obj) return true;
+
+        boolean equals = (this.month == other.month && this.day == other.day);
+        if (timezone != null) {
+            equals = equals && timezone.equals(other.timezone);
+        }
+        return equals;
+    }
+
+    /**
+     * Return the value of (month + day) XORed with the hashCode of
+     * timezone iff one is defined.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        return null == timezone
+            ? (month + day)
+            : (month + day) ^ timezone.hashCode();
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NCName.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NCName.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NCName.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NCName.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+import org.apache.axis2.util.XMLChar;
+
+
+/**
+ * Custom class for supporting XSD data type NCName
+ * NCName represents XML "non-colonized" Names
+ * The base type of NCName is Name.
+ *
+ * @author Chris Haddad <chaddad@cobia.net>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#NCName">XML Schema 3.3.7</a>
+ * @see <A href="http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName">NCName Production</a>
+ */
+public class NCName extends Name {
+
+    public NCName() {
+        super();
+    }
+
+    /**
+     * ctor for NCName
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public NCName(String stValue) throws IllegalArgumentException {
+        try {
+            setValue(stValue);
+        }
+        catch (IllegalArgumentException e) {
+            // recast normalizedString exception as token exception
+            throw new IllegalArgumentException(
+                   // Messages.getMessage("badNCNameType00") +
+                            "data=[" +
+                    stValue + "]");
+        }
+    }
+
+    /**
+     *
+     * validates the data and sets the value for the object.
+     * @param stValue String value
+     * @throws IllegalArgumentException if invalid format
+     */
+    public void setValue(String stValue) throws IllegalArgumentException {
+        if (NCName.isValid(stValue) == false)
+            throw new IllegalArgumentException(
+               //Messages.getMessage("badNCNameType00") +
+               " data=[" + stValue + "]");
+        m_value = stValue;
+    }
+
+    /**
+     *
+     * validate the value against the xsd definition
+     *
+     * NCName ::=  (Letter | '_') (NCNameChar)*
+     * NCNameChar ::=  Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender
+     */
+    public static boolean isValid(String stValue) {
+        int scan;
+        boolean bValid = true;
+
+        for (scan=0; scan < stValue.length(); scan++) {
+            if (scan == 0)
+              bValid = XMLChar.isNCNameStart(stValue.charAt(scan));
+            else
+              bValid = XMLChar.isNCName(stValue.charAt(scan));
+            if (bValid == false)
+              break;
+        }
+    return bValid;
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMToken.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMToken.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMToken.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMToken.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+import org.apache.axis2.util.XMLChar;
+
+
+/**
+ * Custom class for supporting XSD data type NMToken
+ *
+ * NMTOKEN represents the NMTOKEN attribute type from
+ * [XML 1.0(Second Edition)]. The value space of NMTOKEN
+ * is the set of tokens that match the Nmtoken production
+ * in [XML 1.0 (Second Edition)].
+ * The base type of NMTOKEN is token.
+ * @author Chris Haddad <chaddad@cobia.net>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#nmtoken">XML Schema 3.3.4</a>
+ */
+public class NMToken extends Token {
+
+    public NMToken() {
+        super();
+    }
+
+    /**
+     * ctor for NMToken
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public NMToken(String stValue) throws IllegalArgumentException {
+        try {
+            setValue(stValue);
+        }
+        catch (IllegalArgumentException e) {
+            // recast normalizedString exception as token exception
+            throw new IllegalArgumentException(
+                    //  Messages.getMessage("badNmtoken00") + "data=[" +
+                stValue + "]");
+        }
+    }
+
+    /**
+     *
+     * validate the value against the xsd definition
+     * Nmtoken    ::=    (NameChar)+
+     * NameChar    ::=     Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
+     */
+    public static boolean isValid(String stValue) {
+        int scan;
+
+        for (scan=0; scan < stValue.length(); scan++) {
+          if (XMLChar.isName(stValue.charAt(scan)) == false)
+            return false;
+        }
+
+        return true;
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMTokens.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMTokens.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMTokens.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NMTokens.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Custom class for supporting XSD data type NMTokens
+ *
+ * @author Davanum Srinivas <dims@yahoo.com>
+ */
+public class NMTokens extends NCName {
+    private NMToken[] tokens;
+
+    public NMTokens() {
+        super();
+    }
+    /**
+     * ctor for NMTokens
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public NMTokens (String stValue) throws IllegalArgumentException {
+        setValue(stValue);
+    }
+
+    public void setValue(String stValue) {
+        StringTokenizer tokenizer = new StringTokenizer(stValue);
+        int count = tokenizer.countTokens();
+        tokens = new NMToken[count];
+        for(int i=0;i<count;i++){
+            tokens[i] = new NMToken(tokenizer.nextToken());
+        }
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < tokens.length; i++) {
+            NMToken token = tokens[i];
+            if (i > 0) buf.append(" ");
+            buf.append(token.toString());
+        }
+        return buf.toString();
+    }
+
+    /**
+     * NMTokens can be equal without having identical ordering because
+     * they represent a set of references.  Hence we have to compare
+     * values here as a set, not a list.
+     *
+     * @param object an <code>Object</code> value
+     * @return a <code>boolean</code> value
+     */
+    public boolean equals(Object object) {
+        if (object == this) {
+            return true;        // succeed quickly, when possible
+        }
+        if (object instanceof NMTokens) {
+            NMTokens that = (NMTokens)object;
+            if (this.tokens.length == that.tokens.length) {
+                Set ourSet = new HashSet(Arrays.asList(this.tokens));
+                Set theirSet = new HashSet(Arrays.asList(that.tokens));
+                return ourSet.equals(theirSet);
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Returns the sum of the hashcodes of the underlying tokens, an
+     * operation which is not sensitive to ordering.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        int hash = 0;
+        for (int i = 0; i < tokens.length; i++) {
+            hash += tokens[i].hashCode();
+        }
+        return hash;
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Name.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Name.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Name.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Name.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+
+import org.apache.axis2.util.XMLChar;
+
+/**
+ * Custom class for supporting XSD data type Name
+ * Name represents XML Names. The value space of Name is
+ * the set of all strings which match the Name production
+ * of [XML 1.0 (Second Edition)].
+ * The base type of Name is token.
+ * @author Chris Haddad <chaddad@cobia.net>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#Name">XML Schema 3.3.6</a>
+ */
+public class Name extends Token {
+
+    public Name() {
+        super();
+    }
+
+    /**
+     * ctor for Name
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public Name(String stValue) throws IllegalArgumentException {
+        try {
+            setValue(stValue);
+        }
+        catch (IllegalArgumentException e) {
+            // recast normalizedString exception as token exception
+            throw new IllegalArgumentException(
+                 //Messages.getMessage("badNameType00") +
+                 "data=[" +stValue + "]");
+        }
+    }
+
+    /**
+     *
+     * validates the data and sets the value for the object.
+     * @param stValue String value
+     * @throws IllegalArgumentException if invalid format
+     */
+    public void setValue(String stValue) throws IllegalArgumentException {
+        if (Name.isValid(stValue) == false)
+            throw new IllegalArgumentException(
+               //Messages.getMessage("badNameType00") +
+               " data=[" + stValue + "]");
+        m_value = stValue;
+    }
+
+    /**
+     *
+     * validate the value against the xsd definition
+     *   Name    ::=    (Letter | '_' | ':') ( NameChar)*
+     * NameChar    ::=     Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
+     */
+    //todo - Fix this
+    public static boolean isValid(String stValue) {
+        int scan;
+        boolean bValid = true;
+
+        for (scan=0; scan < stValue.length(); scan++) {
+          if (scan == 0){
+             bValid = XMLChar.isNameStart(stValue.charAt(scan));
+          }else{
+             bValid = XMLChar.isName(stValue.charAt(scan));
+          }
+          if (bValid == false)
+              break;
+        }
+
+        return bValid;
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NegativeInteger.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NegativeInteger.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NegativeInteger.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NegativeInteger.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2001-2004 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.schema.types;
+
+
+import java.math.BigInteger;
+import java.util.Random;
+import java.io.ObjectStreamException;
+
+/**
+ * Custom class for supporting primitive XSD data type negativeinteger
+ *
+ * negativeInteger is derived from nonPositiveInteger by setting the
+ * value of maxInclusive to be -1. This results in the standard 
+ * mathematical concept of the negative integers. The value space of 
+ * negativeInteger is the infinite set {...,-2,-1}. 
+ * The base type of negativeInteger is nonPositiveInteger. 
+ *
+ * @author Chris Haddad <haddadc@apache.org>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#negativeInteger">XML Schema 3.3.15</a>
+ */
+public class NegativeInteger extends NonPositiveInteger {
+
+    public NegativeInteger(byte[] val) {
+        super(val);
+        checkValidity();
+    } // ctor
+
+    public NegativeInteger(int signum, byte[] magnitude) {
+        super(signum, magnitude);
+        checkValidity();
+    } // ctor
+
+    public NegativeInteger(int bitLength, int certainty, Random rnd) {
+        super(bitLength, certainty, rnd);
+        checkValidity();
+    } // ctor
+
+    public NegativeInteger(int numBits, Random rnd) {
+        super(numBits, rnd);
+        checkValidity();
+    } // ctor
+
+    public NegativeInteger(String val) {
+        super(val);
+        checkValidity();
+    }
+
+    public NegativeInteger(String val, int radix) {
+        super(val, radix);
+        checkValidity();
+    } // ctor
+
+    /**
+     * validate the value against the xsd definition
+     */
+    private BigInteger zero = new BigInteger("0");
+    private void checkValidity() {
+        if (compareTo(zero) >= 0) {
+            throw new NumberFormatException(
+                   // Messages.getMessage("badnegInt00") + 
+                    ":  " + this);
+        }
+    } // checkValidity
+
+    /**
+     * Work-around for http://developer.java.sun.com/developer/bugParade/bugs/4378370.html
+     * @return BigIntegerRep
+     * @throws java.io.ObjectStreamException
+     */ 
+    public Object writeReplace() throws ObjectStreamException {
+        return new BigIntegerRep(toByteArray());
+    }
+    
+    protected static class BigIntegerRep implements java.io.Serializable {
+        private byte[] array;
+        protected BigIntegerRep(byte[] array) {
+            this.array = array;
+        }
+        protected Object readResolve() throws java.io.ObjectStreamException {
+            return new NegativeInteger(array);
+        }
+    }
+} // class NonNegativeInteger



Mime
View raw message