You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/11/26 14:07:29 UTC

svn commit: r349112 [2/4] - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2: databinding/schema/ databinding/schema/typemap/ databinding/schema/types/ wsdl/template/csharp/

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonNegativeInteger.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonNegativeInteger.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonNegativeInteger.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonNegativeInteger.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,90 @@
+/*
+ * 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.ObjectStreamException;
+import java.math.BigInteger;
+import java.util.Random;
+
+/**
+ * Custom class for supporting primitive XSD data type nonNegativeInteger
+ *
+ * @author Russell Butek <bu...@us.ibm.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger">XML Schema 3.3.20</a>
+ */
+public class NonNegativeInteger extends BigInteger {
+
+    public NonNegativeInteger(byte[] val) {
+        super(val);
+        checkValidity();
+    } // ctor
+
+    public NonNegativeInteger(int signum, byte[] magnitude) {
+        super(signum, magnitude);
+        checkValidity();
+    } // ctor
+
+    public NonNegativeInteger(int bitLength, int certainty, Random rnd) {
+        super(bitLength, certainty, rnd);
+        checkValidity();
+    } // ctor
+
+    public NonNegativeInteger(int numBits, Random rnd) {
+        super(numBits, rnd);
+        checkValidity();
+    } // ctor
+
+    public NonNegativeInteger(String val) {
+        super(val);
+        checkValidity();
+    }
+
+    public NonNegativeInteger(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("badNonNegInt00") +
+                     ":  " + this);
+        }
+    } // checkValidity
+    
+    /**
+     * Work-around for http://developer.java.sun.com/developer/bugParade/bugs/4378370.html
+     * @return BigIntegerRep
+     * @throws 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 NonNegativeInteger(array);
+        }
+    }
+} // class NonNegativeInteger

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonPositiveInteger.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonPositiveInteger.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonPositiveInteger.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NonPositiveInteger.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,95 @@
+/*
+ * 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 nonPositiveInteger
+ *
+ * nonPositiveInteger is derived from integer by setting the value of 
+ * maxInclusive to be 0. This results in the standard mathematical 
+ * concept of the non-positive integers. The value space of 
+ * nonPositiveInteger is the infinite set {...,-2,-1,0}. 
+ *
+ * @author Chris Haddad <haddadc@apache.org
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger">XML Schema 3.3.14</a>
+ */
+public class NonPositiveInteger extends BigInteger {
+
+    public NonPositiveInteger(byte[] val) {
+        super(val);
+        checkValidity();
+    } // ctor
+
+    public NonPositiveInteger(int signum, byte[] magnitude) {
+        super(signum, magnitude);
+        checkValidity();
+    } // ctor
+
+    public NonPositiveInteger(int bitLength, int certainty, Random rnd) {
+        super(bitLength, certainty, rnd);
+        checkValidity();
+    } // ctor
+
+    public NonPositiveInteger(int numBits, Random rnd) {
+        super(numBits, rnd);
+        checkValidity();
+    } // ctor
+
+    public NonPositiveInteger(String val) {
+        super(val);
+        checkValidity();
+    }
+
+    public NonPositiveInteger(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("badNonPosInt00") +
+                     ":  " + 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 NonPositiveInteger(array);
+        }
+    }
+} // class NonPositiveInteger

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NormalizedString.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NormalizedString.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NormalizedString.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/NormalizedString.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;
+
+
+/**
+ * Custom class for supporting XSD data type NormalizedString.
+ * normalizedString represents white space normalized strings.
+ * The base type of normalizedString is string.
+ *
+ * @author Chris Haddad <ch...@cobia.net>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#normalizedString">XML Schema Part 2: Datatypes 3.3.1</a>
+ */
+public class NormalizedString extends Object implements java.io.Serializable {
+
+    String m_value = null;   // JAX-RPC maps xsd:string to java.lang.String
+
+    public NormalizedString() {
+        super();
+    }
+
+    /**
+     *
+     * ctor for NormalizedString
+     * @param stValue is the String value
+     * @throws IllegalArgumentException if invalid format
+     */
+    public NormalizedString(String stValue) throws IllegalArgumentException {
+        setValue(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 (NormalizedString.isValid(stValue) == false)
+            throw new IllegalArgumentException(
+//               Messages.getMessage("badNormalizedString00") +
+               " data=[" + stValue + "]");
+        m_value = stValue;
+    }
+
+    public String toString(){
+        return m_value;
+    }
+
+    public int hashCode(){
+        return m_value.hashCode();
+    }
+
+    /**
+     *
+     * validate the value against the xsd definition for the object
+     *
+     * The value space of normalizedString is the set of strings that
+     * do not contain the carriage return (#xD), line feed (#xA) nor
+     * tab (#x9) characters. The lexical space of normalizedString is
+     * the set of strings that do not contain the carriage return (#xD)
+     * nor tab (#x9) characters.
+     *
+     * @param stValue the String to test
+     * @returns true if valid normalizedString
+     */
+    public static boolean isValid(String stValue)  {
+        int scan;
+
+        for (scan = 0; scan < stValue.length(); scan++) {
+            char cDigit = stValue.charAt(scan);
+            switch (cDigit) {
+                case 0x09:
+                case 0x0A:
+                case 0x0D:
+                    return false;
+                default:
+                    break;
+            }
+        }
+        return true;
+    }
+
+    public boolean equals(Object object)  {
+        String s1 = object.toString();
+        return s1.equals(m_value);
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Notation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Notation.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Notation.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Notation.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,118 @@
+/*
+ * 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 NOTATION.
+ *
+ * @author Davanum Srinivas <di...@yahoo.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-1/#element-notation">XML Schema Part 1: 3.12 Notation Declarations</a>
+ */
+
+public class Notation implements java.io.Serializable {
+    NCName name;
+    URI publicURI;
+    URI systemURI;
+
+    public Notation() {
+    }
+
+    public Notation(NCName name, URI publicURI, URI systemURI) {
+        this.name = name;
+        this.publicURI = publicURI;
+        this.systemURI = systemURI;
+    }
+
+    public NCName getName() {
+        return name;
+    }
+
+    public void setName(NCName name) {
+        this.name = name;
+    }
+
+    public URI getPublic() {
+        return publicURI;
+    }
+
+    public void setPublic(URI publicURI) {
+        this.publicURI = publicURI;
+    }
+
+    public URI getSystem() {
+        return systemURI;
+    }
+
+    public void setSystem(URI systemURI) {
+        this.systemURI = systemURI;
+    }
+
+    public boolean equals(Object obj) {
+        if (obj == null || !(obj instanceof Notation))
+            return false;
+        Notation other = (Notation) obj;
+        if (name == null) {
+            if (other.getName() != null) {
+                return false;
+            }
+        } else if (!name.equals(other.getName())) {
+            return false;
+        }
+        if (publicURI == null) {
+            if (other.getPublic() != null) {
+                return false;
+            }
+        } else if (!publicURI.equals(other.getPublic())) {
+            return false;
+        }
+        if (systemURI == null) {
+            if (other.getSystem() != null) {
+                return false;
+            }
+        } else if (!systemURI.equals(other.getSystem())) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Returns the sum of the hashcodes of {name,publicURI,systemURI}
+     * for whichever properties in that set is non null.  This is
+     * consistent with the implementation of equals, as required by
+     * {@link java.lang.Object#hashCode() Object.hashCode}.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        int hash = 0;
+        if (null != name) {
+            hash += name.hashCode();
+        }
+        if (null != publicURI) {
+            hash += publicURI.hashCode();
+        }
+        if (null != systemURI) {
+            hash += systemURI.hashCode();
+        }
+        return hash;
+    }
+
+    /**
+     * Note - A lot of code that depended on certain descriptions has been deleted from this class
+     */
+
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/PositiveInteger.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/PositiveInteger.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/PositiveInteger.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/PositiveInteger.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,95 @@
+/*
+ * 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 positiveInteger
+ *
+ * positiveInteger is derived from nonNegativeInteger by setting the value of minInclusive to be 1. 
+ * This results in the standard mathematical concept of the positive integer numbers. The value space
+ * of positiveInteger is the infinite set {1,2,...}. 
+ *
+ * @author Chris Haddad <ha...@apache.org>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#positiveInteger">XML Schema 3.3.25</a>
+ */
+public class PositiveInteger extends NonNegativeInteger {
+
+    public PositiveInteger(byte[] val) {
+        super(val);
+        checkValidity();
+    } // ctor
+
+    public PositiveInteger(int signum, byte[] magnitude) {
+        super(signum, magnitude);
+        checkValidity();
+    } // ctor
+
+    public PositiveInteger(int bitLength, int certainty, Random rnd) {
+        super(bitLength, certainty, rnd);
+        checkValidity();
+    } // ctor
+
+    public PositiveInteger(int numBits, Random rnd) {
+        super(numBits, rnd);
+        checkValidity();
+    } // ctor
+
+    public PositiveInteger(String val) {
+        super(val);
+        checkValidity();
+    }
+
+    public PositiveInteger(String val, int radix) {
+        super(val, radix);
+        checkValidity();
+    } // ctor
+
+    /**
+     * validate the value against the xsd definition
+     */
+    private BigInteger iMinInclusive = new BigInteger("1");
+    private void checkValidity() {
+        if (compareTo(iMinInclusive) < 0) {
+            throw new NumberFormatException(
+                    //Messages.getMessage("badposInt00")
+                    ":  " + 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 PositiveInteger(array);
+        }
+    }
+} // class NonNegativeInteger

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Time.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Time.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Time.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Time.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,261 @@
+/*
+ * 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.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * Class that represents the xsd:time XML Schema type
+ */
+public class Time implements java.io.Serializable {
+    private Calendar _value;
+
+
+    /**
+     * a shared java.text.SimpleDateFormat instance used for parsing the basic
+     * component of the timestamp
+     */
+    private static SimpleDateFormat zulu =
+       new SimpleDateFormat("HH:mm:ss.SSS'Z'");
+
+    // We should always format dates in the GMT timezone
+    static {
+        zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
+    }
+
+
+    /**
+     * Initialize with a Calender, year month and date are ignored
+     */
+    public Time(Calendar value) {
+        this._value = value;
+        _value.set(0,0,0);      // ignore year, month, date
+    }
+
+    /**
+     * Converts a string formatted as HH:mm:ss[.SSS][+/-offset]
+     */
+    public Time(String value) throws NumberFormatException {
+        _value = makeValue(value);
+    }
+
+    /**
+     * return the time as a calendar: ignore the year, month and date fields
+     * @return calendar value; may be null
+     */
+    public Calendar getAsCalendar() {
+        return _value;
+    }
+
+    /**
+     * set the time; ignore year, month, date
+     * @param date
+     */
+    public void setTime(Calendar date) {
+        this._value = date;
+        _value.set(0,0,0);      // ignore year, month, date
+    }
+
+    /**
+     * set the time from a date instance
+     * @param date
+     */
+    public void setTime(Date date) {
+        _value.setTime(date);
+        _value.set(0,0,0);      // ignore year, month, date
+    }
+
+    /**
+     * Utility function that parses xsd:time strings and returns a Date object
+     */
+    private Calendar makeValue(String source) throws NumberFormatException {
+        Calendar calendar = Calendar.getInstance();
+        Date date;
+
+        validateSource(source);
+
+        // convert what we have validated so far
+        date = ParseHoursMinutesSeconds(source);
+
+        int pos = 8;    // The "." in hh:mm:ss.sss
+
+        // parse optional milliseconds
+        if ( source != null ) {
+            if (pos < source.length() && source.charAt(pos)=='.') {
+                int milliseconds = 0;
+                int start = ++pos;
+                while (pos<source.length() &&
+                       Character.isDigit(source.charAt(pos))) {
+                    pos++;
+                }
+
+
+                String decimal=source.substring(start,pos);
+                if (decimal.length()==3) {
+                    milliseconds=Integer.parseInt(decimal);
+                } else if (decimal.length() < 3) {
+                    milliseconds=Integer.parseInt((decimal+"000")
+                                                  .substring(0,3));
+                } else {
+                    milliseconds=Integer.parseInt(decimal.substring(0,3));
+                    if (decimal.charAt(3)>='5') {
+                        ++milliseconds;
+                    }
+                }
+
+                // add milliseconds to the current date
+                date.setTime(date.getTime()+milliseconds);
+            }
+
+            // parse optional timezone
+            if (pos+5 < source.length() &&
+                (source.charAt(pos)=='+' || (source.charAt(pos)=='-'))) {
+                    if (!Character.isDigit(source.charAt(pos+1)) ||
+                        !Character.isDigit(source.charAt(pos+2)) ||
+                        source.charAt(pos+3) != ':'              ||
+                        !Character.isDigit(source.charAt(pos+4)) ||
+                        !Character.isDigit(source.charAt(pos+5)))
+                    {
+                        throw new NumberFormatException();
+                                //Messages.getMessage("badTimezone00"));
+                    }
+
+                    int hours = (source.charAt(pos+1)-'0')*10
+                        +source.charAt(pos+2)-'0';
+                    int mins  = (source.charAt(pos+4)-'0')*10
+                        +source.charAt(pos+5)-'0';
+                    int milliseconds = (hours*60+mins)*60*1000;
+
+                    // subtract milliseconds from current date to obtain GMT
+                    if (source.charAt(pos)=='+') {
+                        milliseconds=-milliseconds;
+                    }
+                    date.setTime(date.getTime()+milliseconds);
+                    pos+=6;
+            }
+
+            if (pos < source.length() && source.charAt(pos)=='Z') {
+                pos++;
+                calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
+            }
+
+            if (pos < source.length()) {
+                throw new NumberFormatException();
+                        //Messages.getMessage("badChars00"));
+            }
+        }
+
+        calendar.setTime(date);
+        calendar.set(0,0,0);    // ignore year, month, date
+
+        return calendar;
+    }
+
+    private int getTimezoneNumberValue(char c) {
+        int n=c-'0';
+        if(n<0 || n>9) {
+            //oops, out of range
+            throw new NumberFormatException();
+                    //Messages.getMessage("badTimezone00"));
+        }
+        return n;
+    }
+
+    /**
+     * parse the hours, minutes and seconds of a string, by handing it off to
+     * the java runtime.
+     * The relevant code will return null if a null string is passed in, so this
+     * code may return a null date in response
+     * @param source
+     * @return
+     * @throws NumberFormatException in the event of trouble
+     */
+    private static Date ParseHoursMinutesSeconds(String source) {
+        Date date;
+        try {
+            synchronized (zulu) {
+                String fulltime = source == null ? null :
+                                                    (source.substring(0,8)+".000Z");
+                date = zulu.parse(fulltime);
+            }
+        } catch (Exception e) {
+            throw new NumberFormatException(e.toString());
+        }
+        return date;
+    }
+
+    /**
+     * validate the source
+     * @param source
+     */
+    private void validateSource(String source) {
+        // validate fixed portion of format
+        if ( source != null ) {
+            if (source.charAt(2) != ':' || source.charAt(5) != ':') {
+                throw new NumberFormatException();
+                        //Messages.getMessage("badTime00"));
+            }
+            if (source.length() < 8) {
+                throw new NumberFormatException();
+                        //Messages.getMessage("badTime00"));
+            }
+        }
+    }
+
+    /**
+     * stringify method returns the time as it would be in GMT, only accurate to the
+     * second...millis probably get lost.
+     * @return
+     */
+    public String toString() {
+        if(_value==null) {
+            return "unassigned Time";
+        }
+        synchronized (zulu) {
+            return zulu.format(_value.getTime());
+        }
+
+    }
+
+    public boolean equals(Object obj) {
+        if (obj == null) return false;
+        if (!(obj instanceof Time)) return false;
+        Time other = (Time) obj;
+        if (this == obj) return true;
+
+        boolean _equals;
+        _equals = true &&
+            ((_value ==null && other._value ==null) ||
+             (_value !=null &&
+              _value.getTime().equals(other._value.getTime())));
+
+        return _equals;
+
+    }
+
+    /**
+     * Returns the hashcode of the underlying calendar.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        return _value == null ? 0 : _value.hashCode();
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Token.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Token.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Token.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Token.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,108 @@
+/*
+ * 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 primitive XSD data type Token.
+ * token represents tokenized strings.
+ * The base type of token is normalizedString.
+ *
+ * @author Chris Haddad <ch...@cobia.net>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#token">XML Schema 3.3.2</a>
+ */
+public class Token extends NormalizedString {
+
+    public Token() {
+        super();
+    }
+
+    /**
+     * ctor for Token
+     * @exception IllegalArgumentException will be thrown if validation fails
+     */
+    public Token(String stValue) throws IllegalArgumentException {
+        try {
+            setValue(stValue);
+        }
+        catch (IllegalArgumentException e) {
+            // recast normalizedString exception as token exception
+            throw new IllegalArgumentException(
+                    //Messages.getMessage("badToken00") +
+                     "data=[" + stValue + "]");
+        }
+    }
+
+    /**
+     *
+     * validate the value against the xsd definition
+     *
+     * The value space of token is the set of strings that do not
+     * contain the line feed (#xA) nor tab (#x9) characters, that
+     * have no leading or trailing spaces (#x20) and that have no
+     * internal sequences of two or more spaces. The lexical space
+     * of token is the set of strings that do not contain the line
+     * feed (#xA) nor tab (#x9) characters, that have no leading or
+     * trailing spaces (#x20) and that have no internal sequences of two
+     * or more spaces.
+     */
+    public static boolean isValid(String stValue) {
+        int scan;
+        // check to see if we have a string to review
+        if (  (stValue == null) || (stValue.length() == 0)  )
+            return true;
+            
+        // no leading space
+        if (stValue.charAt(0) == 0x20)
+            return false;
+
+        // no trail space
+        if (stValue.charAt(stValue.length() - 1) == 0x20)
+            return false;
+
+        for (scan=0; scan < stValue.length(); scan++) {
+            char cDigit = stValue.charAt(scan);
+            switch (cDigit) {
+                case 0x09:
+                case 0x0A:
+                    return false;
+                case 0x20:
+                   // no doublspace
+                    if (scan+1 < stValue.length())
+                        if (stValue.charAt(scan + 1) == 0x20) {
+                            return false;
+                        }
+                default:
+                    break;
+            }
+        }
+        return true;
+    }
+    
+    /**
+     *
+     * 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 (Token.isValid(stValue) == false)
+            throw new IllegalArgumentException(
+               //Messages.getMessage("badToken00") +
+               " data=[" + stValue + "]");
+        m_value = stValue;
+    }
+
+}