This patch adds support for 2 new duration data types, adds new build targets for schema 1.1
and provides interfaces for data types like float, double, hexbinary etc.



Ankit Pasricha
XML Parser Development
IBM Toronto Lab
8200 Warden Avenue, Ontario L6G 1C7
Phone: (905) 413 4941
Index: build.xml
===================================================================
RCS file: /home/cvspublic/xml-xerces/java/build.xml,v
retrieving revision 1.171
diff -u -r1.171 build.xml
--- build.xml   23 Jul 2004 20:02:28 -0000      1.171
+++ build.xml   13 Sep 2004 21:35:53 -0000
@@ -1471,4 +1471,69 @@
     <copy file="${tools.dir}/${jar.resolver}" tofile="${build.dir}/${jar.resolver}"/>
   </target>
 
+  <!-- =================================================================== -->
+  <!-- Prepares the source code with Schema 1.1 support                    -->
+  <!-- =================================================================== -->
+  <target name="prepare-src-schema11" depends="prepare-src">
+       <replace file="${build.src}/org/apache/xerces/impl/Constants.java"
+               token="SCHEMA_1_1_SUPPORT = false" value="SCHEMA_1_1_SUPPORT = true"/>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Compiles the source directory with Schema 1.1 support               -->
+  <!-- =================================================================== -->
+  <target name="compile-schema11" depends="prepare-src-schema11">
+        <copy todir="${build.dest}">
+          <fileset dir="${build.src}"
+            includes="**/*.res, **/*.properties">
+          </fileset>
+        </copy>
+
+        <xjavac srcdir="${build.src}"
+               destdir="${build.dest}"
+               
classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}"
+               debug="${debug}"
+               deprecation="${deprecation}"
+               optimize="${optimize}"
+               includeAntRuntime="false"
+               includeJavaRuntime="false"
+               excludes="org/xml/sax/** 
+                    javax/xml/parsers/**
+                    org/w3c/dom/*
+                    org/w3c/dom/events/**
+                    org/w3c/dom/html/**
+                    org/w3c/dom/ranges/**
+                    org/w3c/dom/traversal/**"
+               />
+       </target>
+  
+  <!-- =================================================================== -->
+  <!-- Creates the implementation class package with Schema 1.1 support    -->
+  <!-- =================================================================== -->
+  <target name="jar-schema11" depends="compile-schema11">
+    <jar jarfile="${build.dir}/schema11-${jar.parser}"
+         basedir="${build.dest}"
+         compress="true"
+         includes="org/apache/**, META-INF/**
+                    org/w3c/dom/html/HTMLDOMImplementation.class
+                   org/w3c/dom/ls/**
+                   org/w3c/dom/DOMError.class
+                   org/w3c/dom/DOMErrorHandler.class
+                   org/w3c/dom/DOMImplementationSource.class
+                   org/w3c/dom/DOMImplementationRegistry.class
+                   org/w3c/dom/DOMLocator.class
+                   org/w3c/dom/UserDataHandler.class">
+    </jar>
+  </target>    
+
+  <!-- =================================================================== -->
+  <!-- Builds xercesImpl, xml-apis and sample jars with Schema 1.1 support -->
+  <!-- =================================================================== -->
+  <target name="jars-schema11" depends="jar-schema11, sampjar">
+    <!-- support xml-commons APIs -->
+    <copy file="${tools.dir}/${jar.apis}" tofile="${build.dir}/${jar.apis}"/>
+
+    <!-- support xml-commons resolver -->
+    <copy file="${tools.dir}/${jar.resolver}" tofile="${build.dir}/${jar.resolver}"/>
+  </target>
 </project>
Index: src/org/apache/xerces/impl/Constants.java
===================================================================
RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/Constants.java,v
retrieving revision 1.42
diff -u -r1.42 Constants.java
--- src/org/apache/xerces/impl/Constants.java   25 Apr 2004 02:08:53 -0000      1.42
+++ src/org/apache/xerces/impl/Constants.java   13 Sep 2004 21:35:53 -0000
@@ -379,6 +379,9 @@
     // XML version constants 
     public final static short XML_VERSION_1_0 = 1;
     public final static short XML_VERSION_1_1 = 2;
+    
+    // Constant to enable Schema 1.1 support
+    public final static boolean SCHEMA_1_1_SUPPORT = false;
 
     // private
 
Index: src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java,v
retrieving revision 1.5
diff -u -r1.5 Base64BinaryDV.java
--- src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java        24 Feb 2004 22:44:24 
-0000      1.5
+++ src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java        13 Sep 2004 21:35:53 
-0000
@@ -19,6 +19,7 @@
 import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
 import org.apache.xerces.impl.dv.ValidationContext;
 import org.apache.xerces.impl.dv.util.Base64;
+import org.apache.xerces.impl.dv.util.ByteListImpl;
 
 /**
  * Represent the schema type "base64Binary"
@@ -44,19 +45,16 @@
 
     // length of a binary type is the number of bytes
     public int getDataLength(Object value) {
-        return ((XBase64)value).length();
+        return ((XBase64)value).getLength();
     }
 
     /**
      * represent base64 data
      */
-    private static final class XBase64 {
-        // actually data stored in a byte array
-        final byte[] data;
-        // canonical representation of the data
-        private String canonical;
+    private static final class XBase64 extends ByteListImpl {
+
         public XBase64(byte[] data) {
-            this.data = data;
+            super(data);
         }
         public synchronized String toString() {
             if (canonical == null) {
@@ -64,9 +62,7 @@
             }
             return canonical;
         }
-        public int length() {
-            return data.length;
-        }
+        
         public boolean equals(Object obj) {
             if (!(obj instanceof XBase64))
                 return false;
Index: src/org/apache/xerces/impl/dv/xs/DoubleDV.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DoubleDV.java,v
retrieving revision 1.7
diff -u -r1.7 DoubleDV.java
--- src/org/apache/xerces/impl/dv/xs/DoubleDV.java      24 Feb 2004 22:44:24 -0000     
 1.7
+++ src/org/apache/xerces/impl/dv/xs/DoubleDV.java      13 Sep 2004 21:35:53 -0000
@@ -18,6 +18,7 @@
 
 import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
 import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.xs.datatypes.XSDouble;
 
 /**
  * Represent the schema type "double"
@@ -47,7 +48,7 @@
         return ((XDouble)value1).compareTo((XDouble)value2);
     }//compare()
 
-    private static final class XDouble {
+    private static final class XDouble implements XSDouble {
         private double value;
         public XDouble(String s) throws NumberFormatException {
             try {
@@ -196,5 +197,8 @@
             }
             return canonical;
         }
+               public double getValue() {
+                       return value;
+               }
     }
 } // class DoubleDV
Index: src/org/apache/xerces/impl/dv/xs/DurationDV.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DurationDV.java,v
retrieving revision 1.10
diff -u -r1.10 DurationDV.java
--- src/org/apache/xerces/impl/dv/xs/DurationDV.java    26 Aug 2004 02:14:40 -0000     
 1.10
+++ src/org/apache/xerces/impl/dv/xs/DurationDV.java    13 Sep 2004 21:35:53 -0000
@@ -28,6 +28,9 @@
  */
 public class DurationDV extends AbstractDateTimeDV {
 
+       public static final int DURATION_TYPE = 0;
+       public static final int YEARMONTHDURATION_TYPE = 1;
+       public static final int DAYTIMEDURATION_TYPE = 2;
     // order-relation on duration is a partial order. The dates below are used to
     // for comparison of 2 durations, based on the fact that
     // duration x and y is x<=y iff s+x<=s+y
@@ -42,7 +45,7 @@
 
     public Object getActualValue(String content, ValidationContext context) throws 
InvalidDatatypeValueException{
         try{
-            return parse(content);
+            return parse(content, DURATION_TYPE);
         } catch (Exception ex) {
             throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new 
Object[]{content, "duration"});
         }
@@ -56,7 +59,7 @@
      * @return normalized date representation
      * @exception SchemaDateTimeException Invalid lexical representation
      */
-    protected DateTimeData parse(String str) throws SchemaDateTimeException{
+    protected DateTimeData parse(String str, int durationType) throws 
SchemaDateTimeException{
         int len = str.length();
         DateTimeData date= new DateTimeData(this);
 
@@ -85,9 +88,18 @@
         if ( endDate == -1 ) {
             endDate = len;
         }
+        else if(durationType == YEARMONTHDURATION_TYPE) {
+               throw new SchemaDateTimeException();
+        }
+        
         //find 'Y'
         int end = indexOf (str, start, endDate, 'Y');
         if ( end!=-1 ) {
+               
+               if(durationType == DAYTIMEDURATION_TYPE) {
+                       throw new SchemaDateTimeException();
+               }
+               
             //scan year
             date.year=negate * parseInt(str,start,end);
             start = end+1;
@@ -96,6 +108,11 @@
 
         end = indexOf (str, start, endDate, 'M');
         if ( end!=-1 ) {
+               
+               if(durationType == DAYTIMEDURATION_TYPE) {
+                       throw new SchemaDateTimeException();
+               }
+               
             //scan month
             date.month=negate * parseInt(str,start,end);
             start = end+1;
@@ -104,6 +121,11 @@
 
         end = indexOf (str, start, endDate, 'D');
         if ( end!=-1 ) {
+               
+               if(durationType == YEARMONTHDURATION_TYPE) {
+                       throw new SchemaDateTimeException();
+               }
+               
             //scan day
             date.day=negate * parseInt(str,start,end);
             start = end+1;
Index: src/org/apache/xerces/impl/dv/xs/FloatDV.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/FloatDV.java,v
retrieving revision 1.7
diff -u -r1.7 FloatDV.java
--- src/org/apache/xerces/impl/dv/xs/FloatDV.java       24 Feb 2004 22:44:24 -0000     
 1.7
+++ src/org/apache/xerces/impl/dv/xs/FloatDV.java       13 Sep 2004 21:35:53 -0000
@@ -18,6 +18,7 @@
 
 import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
 import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.xs.datatypes.XSFloat;
 
 /**
  * Represent the schema type "float"
@@ -47,7 +48,8 @@
         return ((XFloat)value1).compareTo((XFloat)value2);
     }//compare()
 
-    private static final class XFloat {
+    private static final class XFloat implements XSFloat {
+
         private float value;
         public XFloat(String s) throws NumberFormatException {
             try {
@@ -196,5 +198,9 @@
             }
             return canonical;
         }
+        
+               public float getValue() {
+                       return value;
+               }
     }
 } // class FloatDV
Index: src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java,v
retrieving revision 1.5
diff -u -r1.5 HexBinaryDV.java
--- src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java   24 Feb 2004 22:44:24 -0000     
 1.5
+++ src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java   13 Sep 2004 21:35:53 -0000
@@ -18,6 +18,7 @@
 
 import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
 import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.impl.dv.util.ByteListImpl;
 import org.apache.xerces.impl.dv.util.HexBin;
 
 /**
@@ -44,16 +45,13 @@
 
     // length of a binary type is the number of bytes
     public int getDataLength(Object value) {
-        return ((XHex)value).length();
+        return ((XHex)value).getLength();
     }
 
-    private static final class XHex {
-        // actually data stored in a byte array
-        final byte[] data;
-        // canonical representation of the data
-        private String canonical;
+    private static final class XHex extends ByteListImpl {
+
         public XHex(byte[] data) {
-            this.data = data;
+            super(data);
         }
         public synchronized String toString() {
             if (canonical == null) {
@@ -61,9 +59,7 @@
             }
             return canonical;
         }
-        public int length() {
-            return data.length;
-        }
+        
         public boolean equals(Object obj) {
             if (!(obj instanceof XHex))
                 return false;
@@ -77,5 +73,6 @@
             }
             return true;
         }
+
     }
 }
Index: src/org/apache/xerces/impl/dv/xs/ListDV.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/ListDV.java,v
retrieving revision 1.6
diff -u -r1.6 ListDV.java
--- src/org/apache/xerces/impl/dv/xs/ListDV.java        24 Feb 2004 22:44:24 -0000     
 1.6
+++ src/org/apache/xerces/impl/dv/xs/ListDV.java        13 Sep 2004 21:35:53 -0000
@@ -18,6 +18,8 @@
 
 import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
 import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.xs.XSException;
+import org.apache.xerces.xs.datatypes.ObjectList;
 
 /**
  * Represent the schema list types
@@ -41,10 +43,10 @@
 
     // length of a list type is the number of items in the list
     public int getDataLength(Object value) {
-        return ((ListData)value).length();
+        return ((ListData)value).getLength();
     }
 
-    final static class ListData {
+    final static class ListData implements ObjectList {
         final Object[] data;
         private String canonical;
         public ListData(Object[] data) {
@@ -65,12 +67,9 @@
             }
             return canonical;
         }
-        public int length() {
+        public int getLength() {
             return data.length;
         }
-        public Object item(int index) {
-            return data[index];
-        }
         public boolean equals(Object obj) {
             if (!(obj instanceof ListData))
                 return false;
@@ -87,6 +86,20 @@
     
             //everything went fine.
             return true;
+        }
+        
+        public boolean contains(Object item) {
+               for(int i = 0;i < data.length; i++) {
+                       if(item == data[i])
+                               return true;
+               }
+               return false;
+        }
+        
+        public Object item(int index) throws XSException {
+               if(index < 0 || index > data.length - 1) 
+                       throw new XSException(XSException.INDEX_SIZE_ERR, null);
+               return data[index];
         }
     }
 } // class ListDV
Index: src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java,v
retrieving revision 1.15
diff -u -r1.15 SchemaDVFactoryImpl.java
--- src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java   24 Feb 2004 22:44:24 
-0000      1.15
+++ src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java   13 Sep 2004 21:35:54 
-0000
@@ -16,13 +16,14 @@
 
 package org.apache.xerces.impl.dv.xs;
 
+import org.apache.xerces.impl.Constants;
 import org.apache.xerces.impl.dv.SchemaDVFactory;
-import org.apache.xerces.impl.dv.XSSimpleType;
 import org.apache.xerces.impl.dv.XSFacets;
+import org.apache.xerces.impl.dv.XSSimpleType;
 import org.apache.xerces.impl.xs.XSDeclarationPool;
+import org.apache.xerces.util.SymbolHash;
 import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSObjectList;
-import org.apache.xerces.util.SymbolHash;
 
 /**
  * the factory to create/return built-in schema DVs and create user-defined DVs
@@ -183,6 +184,8 @@
         final String UNSIGNEDSHORT     = "unsignedShort";
         final String YEAR              = "gYear";
         final String YEARMONTH         = "gYearMonth";
+        final String YEARMONTHDURATION = "yearMonthDuration";
+        final String DAYTIMEDURATION   = "dayTimeDuration";
 
         final XSFacets facets = new XSFacets();
 
@@ -197,7 +200,15 @@
 
         fBuiltInTypes.put(ANYURI, new XSSimpleTypeDecl(anySimpleType, ANYURI, 
XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, false, false, true, 
XSConstants.ANYURI_DT));
         fBuiltInTypes.put(BASE64BINARY, new XSSimpleTypeDecl(anySimpleType, 
BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, 
false, false, true, XSConstants.BASE64BINARY_DT));
-        fBuiltInTypes.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION, 
XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, 
XSConstants.DURATION_DT));
+        
+        XSSimpleTypeDecl durationDV = new XSSimpleTypeDecl(anySimpleType, DURATION, 
XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, 
XSConstants.DURATION_DT);
+        fBuiltInTypes.put(DURATION, durationDV);
+        
+        if(Constants.SCHEMA_1_1_SUPPORT) {
+               fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, 
YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, 
XSSimpleType.ORDERED_PARTIAL, false, false, false, true, 
XSConstants.YEARMONTHDURATION_DT));
+               fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, 
DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, 
false, false, false, true, XSConstants.DAYTIMEDURATION_DT));
+        }
+        
         fBuiltInTypes.put(DATETIME, new XSSimpleTypeDecl(anySimpleType, DATETIME, 
XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, 
XSConstants.DATETIME_DT));
         fBuiltInTypes.put(TIME, new XSSimpleTypeDecl(anySimpleType, TIME, 
XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, 
XSConstants.TIME_DT));
         fBuiltInTypes.put(DATE, new XSSimpleTypeDecl(anySimpleType, DATE, 
XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, 
XSConstants.DATE_DT));
Index: src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v
retrieving revision 1.52
diff -u -r1.52 XSSimpleTypeDecl.java
--- src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java      19 May 2004 14:05:04 
-0000      1.52
+++ src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java      13 Sep 2004 21:35:54 
-0000
@@ -77,6 +77,8 @@
     static final short DV_INTEGER       = DV_NOTATION + 4;
     static final short DV_LIST          = DV_NOTATION + 5;
     static final short DV_UNION         = DV_NOTATION + 6;
+    static final short DV_YEARMONTHDURATION = DV_NOTATION + 7;
+    static final short DV_DAYTIMEDURATION      = DV_NOTATION + 8;
 
     static final TypeValidator[] fDVs = {
         new AnySimpleDV(),
@@ -104,7 +106,9 @@
         new EntityDV(),
         new IntegerDV(),
         new ListDV(),
-        new UnionDV()
+        new UnionDV(),
+               new YearMonthDurationDV(),
+               new DayTimeDurationDV()
     };
 
     static final short NORMALIZE_NONE = 0;
@@ -136,7 +140,9 @@
         NORMALIZE_TRIM, //EntityDV(),
         NORMALIZE_TRIM, //IntegerDV(),
         NORMALIZE_FULL, //ListDV(),
-        NORMALIZE_NONE, //UnionDV()
+        NORMALIZE_NONE, //UnionDV(),
+               NORMALIZE_TRIM, //YearMonthDurationDV()
+               NORMALIZE_TRIM, //DayTimeDurationDV()
     };
 
     static final short SPECIAL_PATTERN_NONE     = 0;
@@ -260,7 +266,7 @@
     // default constructor
     public XSSimpleTypeDecl(){}
 
-    //Create a new built-in primitive types (and id/idref/entity/integer)
+    //Create a new built-in primitive types (and 
id/idref/entity/integer/yearMonthDuration)
     protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV,
                                short ordered, boolean bounded, boolean finite,
                                boolean numeric, boolean isImmutable, short 
builtInKind) {
@@ -1607,7 +1613,7 @@
         } else if (fVariety == VARIETY_LIST) {
 
             ListDV.ListData values = (ListDV.ListData)ob;
-            int len = values.length();
+            int len = values.getLength();
             if (fItemType.fVariety == VARIETY_UNION) {
                 XSSimpleTypeDecl[] memberTypes = 
(XSSimpleTypeDecl[])validatedInfo.memberTypes;
                 XSSimpleType memberType = validatedInfo.memberType;
Index: src/org/apache/xerces/xs/XSConstants.java
===================================================================
RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/xs/XSConstants.java,v
retrieving revision 1.4
diff -u -r1.4 XSConstants.java
--- src/org/apache/xerces/xs/XSConstants.java   24 Feb 2004 23:15:55 -0000      1.4
+++ src/org/apache/xerces/xs/XSConstants.java   13 Sep 2004 21:35:54 -0000
@@ -316,10 +316,26 @@
     /**
      * The type represents a list type definition.
      */
-    public static final short LIST_DT                   = 44;
+    public static final short LIST_DT                   = 44;  
+    /**
+     * yearMonthDuration
+     * 
+     * The type represents a type derived from duration to
+     * represent a restricted duration containing only year
+     * and month from the duration value space.
+     */
+    public static final short YEARMONTHDURATION_DT             = 45;
+    /**
+     * dayTimeDuration
+     * 
+     * The type represents a type derived from duration to
+     * represent a restricted duration containing the day and 
+     * time portion of the duration value space.
+     */
+    public static final short DAYTIMEDURATION_DT               = 46;
     /**
      * The built-in type category is not available.
      */
-    public static final short UNAVAILABLE_DT            = 45;
+    public static final short UNAVAILABLE_DT            = 47;
 
 }
Index: src/org/apache/xerces/impl/dv/util/ByteListImpl.java
===================================================================
RCS file: src/org/apache/xerces/impl/dv/util/ByteListImpl.java
diff -N src/org/apache/xerces/impl/dv/util/ByteListImpl.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/org/apache/xerces/impl/dv/util/ByteListImpl.java        1 Jan 1970 00:00:00 
-0000
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2001, 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.xerces.impl.dv.util;
+
+import org.apache.xerces.xs.datatypes.ByteList;
+import org.apache.xerces.xs.XSException;
+
+/**
+ * Implementation of <code>org.apache.xerces.xs.datatypes.ByteList</code>.
+ * 
+ * @author Ankit Pasricha, IBM
+ */
+public class ByteListImpl implements ByteList {
+
+    // actually data stored in a byte array
+    protected final byte[] data;
+    
+    // canonical representation of the data
+    protected String canonical;
+    
+    public ByteListImpl(byte[] data) {
+        this.data = data;
+    }
+    
+    /**
+     * The number of <code>byte</code>s in the list. The range of 
+     * valid child object indices is 0 to <code>length-1</code> inclusive. 
+     */
+    public int getLength() {
+        return data.length;
+    }
+
+    /**
+     * Checks if the <code>byte</code> <code>item</code> is a 
+     * member of this list. 
+     * @param item  <code>byte</code> whose presence in this list 
+     *   is to be tested. 
+     * @return  True if this list contains the <code>byte</code> 
+     *   <code>item</code>. 
+     */
+    public boolean contains(byte item) {
+        for(int i = 0;i < data.length; i++)
+            if(data[i] == item)
+                return true;
+        return false;
+    }
+
+    /**
+     * Returns the <code>index</code>th item in the collection. The index 
+     * starts at 0. 
+     * @param index  index into the collection. 
+     * @return  The <code>byte</code> at the <code>index</code>th 
+     *   position in the <code>ByteList</code>. 
+     * @exception XSException
+     *   INDEX_SIZE_ERR: if <code>index</code> is greater than or equal to the 
+     *   number of objects in the list.
+     */
+    public byte item(int index)
+                      throws XSException {
+        if(index < 0 || index > data.length - 1) {
+            throw new XSException(XSException.INDEX_SIZE_ERR, null);
+        }
+        return data[index];
+    }
+    
+}
+
Index: src/org/apache/xerces/impl/dv/xs/DayTimeDurationDV.java
===================================================================
RCS file: src/org/apache/xerces/impl/dv/xs/DayTimeDurationDV.java
diff -N src/org/apache/xerces/impl/dv/xs/DayTimeDurationDV.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/org/apache/xerces/impl/dv/xs/DayTimeDurationDV.java     1 Jan 1970 00:00:00 
-0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2001, 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.xerces.impl.dv.xs;
+
+import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.xerces.impl.dv.ValidationContext;
+
+/**
+ * Used to validate the <dayTimeDuration> type
+ * 
+ * @author Ankit Pasricha, IBM
+ */
+public class DayTimeDurationDV extends DurationDV {
+    
+    public Object getActualValue(String content, ValidationContext context)
+        throws InvalidDatatypeValueException {
+        try {
+            return parse(content, DurationDV.DAYTIMEDURATION_TYPE);
+        } 
+        catch (Exception ex) {
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new 
Object[]{content, "dayTimeDuration"});
+        }
+    }
+}
Index: src/org/apache/xerces/impl/dv/xs/YearMonthDurationDV.java
===================================================================
RCS file: src/org/apache/xerces/impl/dv/xs/YearMonthDurationDV.java
diff -N src/org/apache/xerces/impl/dv/xs/YearMonthDurationDV.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/org/apache/xerces/impl/dv/xs/YearMonthDurationDV.java   1 Jan 1970 00:00:00 
-0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2001, 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.xerces.impl.dv.xs;
+
+import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.xerces.impl.dv.ValidationContext;
+
+/**
+ * Used to validate the <yearMonthDuration> type
+ * 
+ * @author Ankit Pasricha, IBM
+ */
+public class YearMonthDurationDV extends DurationDV {
+    
+    public Object getActualValue(String content, ValidationContext context)
+        throws InvalidDatatypeValueException {
+        try {
+            return parse(content, DurationDV.YEARMONTHDURATION_TYPE);
+        } 
+        catch (Exception ex) {
+            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new 
Object[]{content, "yearMonthDuration"});
+        }
+    }
+}
Index: src/org/apache/xerces/xs/datatypes/ByteList.java
===================================================================
RCS file: src/org/apache/xerces/xs/datatypes/ByteList.java
diff -N src/org/apache/xerces/xs/datatypes/ByteList.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/org/apache/xerces/xs/datatypes/ByteList.java    1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2001, 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.xerces.xs.datatypes;
+
+import org.apache.xerces.xs.XSException;
+
+/**
+ * EXPERIMENTAL: The <code>ByteList</code> is an immutable ordered collection of 
+ * <code>byte</code>. 
+ * 
+ * @author Ankit Pasricha, IBM
+ */
+public interface ByteList {
+
+    /**
+     * The number of <code>byte</code>s in the list. The range of 
+     * valid child object indices is 0 to <code>length-1</code> inclusive. 
+     */
+    public int getLength();
+
+    /**
+     *  Checks if the <code>byte</code> <code>item</code> is a 
+     * member of this list. 
+     * @param item  <code>byte</code> whose presence in this list 
+     *   is to be tested. 
+     * @return  True if this list contains the <code>byte</code> 
+     *   <code>item</code>. 
+     */
+    public boolean contains(byte item);
+
+    /**
+     *  Returns the <code>index</code>th item in the collection. The index 
+     * starts at 0. 
+     * @param index  index into the collection. 
+     * @return  The <code>byte</code> at the <code>index</code>th 
+     *   position in the <code>ByteList</code>. 
+     * @exception XSException
+     *   INDEX_SIZE_ERR: if <code>index</code> is greater than or equal to the 
+     *   number of objects in the list.
+     */
+    public byte item(int index) throws XSException;
+       
+}
Index: src/org/apache/xerces/xs/datatypes/ObjectList.java
===================================================================
RCS file: src/org/apache/xerces/xs/datatypes/ObjectList.java
diff -N src/org/apache/xerces/xs/datatypes/ObjectList.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/org/apache/xerces/xs/datatypes/ObjectList.java  1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2001, 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.xerces.xs.datatypes;
+
+import org.apache.xerces.xs.XSException;
+
+/**
+ * EXPERIMENTAL: The <code>ObjectList</code> is an immutable ordered collection of 
+ * <code>Object</code>. 
+ * 
+ * @author Ankit Pasricha, IBM
+ */
+public interface ObjectList {
+       
+    /**
+     *  The number of <code>Object</code>s in the list. The range of 
+     * valid child object indices is 0 to <code>length-1</code> inclusive. 
+     */
+    public int getLength();
+
+    /**
+     *  Checks if the <code>Object</code> <code>item</code> is a 
+     * member of this list. 
+     * @param item  <code>Object</code> whose presence in this list 
+     *   is to be tested. 
+     * @return  True if this list contains the <code>Object</code> 
+     *   <code>item</code>. 
+     */
+    public boolean contains(Object item);
+
+    /**
+     *  Returns the <code>index</code>th item in the collection. The index 
+     * starts at 0. 
+     * @param index  index into the collection. 
+     * @return  The <code>Object</code> at the <code>index</code>th 
+     *   position in the <code>ObjectList</code>. 
+     * @exception XSException
+     *   INDEX_SIZE_ERR: if <code>index</code> is greater than or equal to the 
+     *   number of objects in the list.
+     */
+    public Object item(int index)
+                      throws XSException;
+
+}
Index: src/org/apache/xerces/xs/datatypes/XSDouble.java
===================================================================
RCS file: src/org/apache/xerces/xs/datatypes/XSDouble.java
diff -N src/org/apache/xerces/xs/datatypes/XSDouble.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/org/apache/xerces/xs/datatypes/XSDouble.java    1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2001, 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.xerces.xs.datatypes;
+
+/**
+ * EXPERIMENTAL: Interface to expose the value of the 'double' datatype.
+ * 
+ * @author Ankit Pasricha, IBM
+ */
+public interface XSDouble {
+       
+       /**
+        * @return value
+        */
+       public double getValue();
+
+}
Index: src/org/apache/xerces/xs/datatypes/XSFloat.java
===================================================================
RCS file: src/org/apache/xerces/xs/datatypes/XSFloat.java
diff -N src/org/apache/xerces/xs/datatypes/XSFloat.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/org/apache/xerces/xs/datatypes/XSFloat.java     1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2001, 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.xerces.xs.datatypes;
+
+/**
+ * EXPERIMENTAL: Interface to expose value of the float datatype.
+ * 
+ * @author Ankit Pasricha, IBM
+ */
+public interface XSFloat {
+       
+       /**
+        * @return value
+        */
+       public float getValue();
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to