1 57 58 package com.sun.org.apache.xerces.internal.impl.dv.xs; 59 60 import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory; 61 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType; 62 import com.sun.org.apache.xerces.internal.impl.dv.XSFacets; 63 import com.sun.org.apache.xerces.internal.xs.XSConstants; 64 import com.sun.org.apache.xerces.internal.xs.XSObjectList; 65 import com.sun.org.apache.xerces.internal.util.SymbolHash; 66 67 75 public class BaseDVFactory extends SchemaDVFactory { 76 77 static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema"; 78 79 static SymbolHash fBaseTypes = new SymbolHash(53); 81 static { 82 createBuiltInTypes(fBaseTypes); 83 } 84 85 96 public XSSimpleType getBuiltInType(String name) { 97 return (XSSimpleType)fBaseTypes.get(name); 98 } 99 100 106 public SymbolHash getBuiltInTypes() { 107 return (SymbolHash)fBaseTypes.makeClone(); 108 } 109 110 121 public XSSimpleType createTypeRestriction(String name, String targetNamespace, 122 short finalSet, XSSimpleType base, XSObjectList annotations) { 123 return new XSSimpleTypeDecl((XSSimpleTypeDecl)base, name, targetNamespace, finalSet, false, annotations); 124 } 125 126 137 public XSSimpleType createTypeList(String name, String targetNamespace, 138 short finalSet, XSSimpleType itemType, 139 XSObjectList annotations) { 140 return new XSSimpleTypeDecl(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType, false, annotations); 141 } 142 143 154 public XSSimpleType createTypeUnion(String name, String targetNamespace, 155 short finalSet, XSSimpleType[] memberTypes, 156 XSObjectList annotations) { 157 int typeNum = memberTypes.length; 158 XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum]; 159 System.arraycopy(memberTypes, 0, mtypes, 0, typeNum); 160 161 return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes, annotations); 162 } 163 164 static void createBuiltInTypes(SymbolHash types) { 166 final String ANYSIMPLETYPE = "anySimpleType"; 168 final String ANYURI = "anyURI"; 169 final String BASE64BINARY = "base64Binary"; 170 final String BOOLEAN = "boolean"; 171 final String BYTE = "byte"; 172 final String DATE = "date"; 173 final String DATETIME = "dateTime"; 174 final String DAY = "gDay"; 175 final String DECIMAL = "decimal"; 176 final String INT = "int"; 177 final String INTEGER = "integer"; 178 final String LONG = "long"; 179 final String NEGATIVEINTEGER = "negativeInteger"; 180 final String MONTH = "gMonth"; 181 final String MONTHDAY = "gMonthDay"; 182 final String NONNEGATIVEINTEGER= "nonNegativeInteger"; 183 final String NONPOSITIVEINTEGER= "nonPositiveInteger"; 184 final String POSITIVEINTEGER = "positiveInteger"; 185 final String SHORT = "short"; 186 final String STRING = "string"; 187 final String TIME = "time"; 188 final String UNSIGNEDBYTE = "unsignedByte"; 189 final String UNSIGNEDINT = "unsignedInt"; 190 final String UNSIGNEDLONG = "unsignedLong"; 191 final String UNSIGNEDSHORT = "unsignedShort"; 192 final String YEAR = "gYear"; 193 final String YEARMONTH = "gYearMonth"; 194 195 final XSFacets facets = new XSFacets(); 196 197 XSSimpleTypeDecl anySimpleType = XSSimpleTypeDecl.fAnySimpleType; 198 types.put(ANYSIMPLETYPE, anySimpleType); 199 XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_STRING, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.STRING_DT); 200 types.put(STRING, stringDV); 201 types.put(BOOLEAN, new XSSimpleTypeDecl(anySimpleType, BOOLEAN, XSSimpleTypeDecl.DV_BOOLEAN, XSSimpleType.ORDERED_FALSE, false, true, false, true, XSConstants.BOOLEAN_DT)); 202 XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(anySimpleType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.DECIMAL_DT); 203 types.put(DECIMAL, decimalDV); 204 205 types.put(ANYURI, new XSSimpleTypeDecl(anySimpleType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ANYURI_DT)); 206 types.put(BASE64BINARY, new XSSimpleTypeDecl(anySimpleType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.BASE64BINARY_DT)); 207 types.put(DATETIME, new XSSimpleTypeDecl(anySimpleType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATETIME_DT)); 208 types.put(TIME, new XSSimpleTypeDecl(anySimpleType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.TIME_DT)); 209 types.put(DATE, new XSSimpleTypeDecl(anySimpleType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATE_DT)); 210 types.put(YEARMONTH, new XSSimpleTypeDecl(anySimpleType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEARMONTH_DT)); 211 types.put(YEAR, new XSSimpleTypeDecl(anySimpleType, YEAR, XSSimpleTypeDecl.DV_GYEAR, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEAR_DT)); 212 types.put(MONTHDAY, new XSSimpleTypeDecl(anySimpleType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTHDAY_DT)); 213 types.put(DAY, new XSSimpleTypeDecl(anySimpleType, DAY, XSSimpleTypeDecl.DV_GDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GDAY_DT)); 214 types.put(MONTH, new XSSimpleTypeDecl(anySimpleType, MONTH, XSSimpleTypeDecl.DV_GMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTH_DT)); 215 216 XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, XSSimpleTypeDecl.DV_INTEGER, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.INTEGER_DT); 217 types.put(INTEGER, integerDV); 218 219 facets.maxInclusive = "0"; 220 XSSimpleTypeDecl nonPositiveDV = new XSSimpleTypeDecl(integerDV, NONPOSITIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONPOSITIVEINTEGER_DT); 221 nonPositiveDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0); 222 types.put(NONPOSITIVEINTEGER, nonPositiveDV); 223 224 facets.maxInclusive = "-1"; 225 XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(integerDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NEGATIVEINTEGER_DT); 226 negativeDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0); 227 types.put(NEGATIVEINTEGER, negativeDV); 228 229 facets.maxInclusive = "9223372036854775807"; 230 facets.minInclusive = "-9223372036854775808"; 231 XSSimpleTypeDecl longDV = new XSSimpleTypeDecl(integerDV, LONG, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LONG_DT); 232 longDV.applyFacets1(facets , (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 ); 233 types.put(LONG, longDV); 234 235 236 facets.maxInclusive = "2147483647"; 237 facets.minInclusive = "-2147483648"; 238 XSSimpleTypeDecl intDV = new XSSimpleTypeDecl(longDV, INT, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.INT_DT); 239 intDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 ); 240 types.put(INT, intDV); 241 242 facets.maxInclusive = "32767"; 243 facets.minInclusive = "-32768"; 244 XSSimpleTypeDecl shortDV = new XSSimpleTypeDecl(intDV, SHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.SHORT_DT); 245 shortDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 ); 246 types.put(SHORT, shortDV); 247 248 facets.maxInclusive = "127"; 249 facets.minInclusive = "-128"; 250 XSSimpleTypeDecl byteDV = new XSSimpleTypeDecl(shortDV, BYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.BYTE_DT); 251 byteDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 ); 252 types.put(BYTE, byteDV); 253 254 facets.minInclusive = "0" ; 255 XSSimpleTypeDecl nonNegativeDV = new XSSimpleTypeDecl(integerDV, NONNEGATIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONNEGATIVEINTEGER_DT); 256 nonNegativeDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 ); 257 types.put(NONNEGATIVEINTEGER, nonNegativeDV); 258 259 facets.maxInclusive = "18446744073709551615" ; 260 XSSimpleTypeDecl unsignedLongDV = new XSSimpleTypeDecl(nonNegativeDV, UNSIGNEDLONG , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDLONG_DT); 261 unsignedLongDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 ); 262 types.put(UNSIGNEDLONG, unsignedLongDV); 263 264 facets.maxInclusive = "4294967295" ; 265 XSSimpleTypeDecl unsignedIntDV = new XSSimpleTypeDecl(unsignedLongDV, UNSIGNEDINT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDINT_DT); 266 unsignedIntDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 ); 267 types.put(UNSIGNEDINT, unsignedIntDV); 268 269 facets.maxInclusive = "65535" ; 270 XSSimpleTypeDecl unsignedShortDV = new XSSimpleTypeDecl(unsignedIntDV, UNSIGNEDSHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDSHORT_DT); 271 unsignedShortDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 ); 272 types.put(UNSIGNEDSHORT, unsignedShortDV); 273 274 facets.maxInclusive = "255" ; 275 XSSimpleTypeDecl unsignedByteDV = new XSSimpleTypeDecl(unsignedShortDV, UNSIGNEDBYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDBYTE_DT); 276 unsignedByteDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 ); 277 types.put(UNSIGNEDBYTE, unsignedByteDV); 278 279 facets.minInclusive = "1" ; 280 XSSimpleTypeDecl positiveIntegerDV = new XSSimpleTypeDecl(nonNegativeDV, POSITIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.POSITIVEINTEGER_DT); 281 positiveIntegerDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 ); 282 types.put(POSITIVEINTEGER, positiveIntegerDV); 283 } 285 } | Popular Tags |