1 16 17 package org.apache.xerces.impl.dv.xs; 18 19 import org.apache.xerces.impl.dv.SchemaDVFactory; 20 import org.apache.xerces.impl.dv.XSSimpleType; 21 import org.apache.xerces.impl.dv.XSFacets; 22 import org.apache.xerces.xs.XSConstants; 23 import org.apache.xerces.xs.XSObjectList; 24 import org.apache.xerces.util.SymbolHash; 25 26 36 public class BaseDVFactory extends SchemaDVFactory { 37 38 static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema"; 39 40 static SymbolHash fBaseTypes = new SymbolHash(53); 42 static { 43 createBuiltInTypes(fBaseTypes); 44 } 45 46 57 public XSSimpleType getBuiltInType(String name) { 58 return (XSSimpleType)fBaseTypes.get(name); 59 } 60 61 67 public SymbolHash getBuiltInTypes() { 68 return (SymbolHash)fBaseTypes.makeClone(); 69 } 70 71 82 public XSSimpleType createTypeRestriction(String name, String targetNamespace, 83 short finalSet, XSSimpleType base, XSObjectList annotations) { 84 return new XSSimpleTypeDecl((XSSimpleTypeDecl)base, name, targetNamespace, finalSet, false, annotations); 85 } 86 87 98 public XSSimpleType createTypeList(String name, String targetNamespace, 99 short finalSet, XSSimpleType itemType, 100 XSObjectList annotations) { 101 return new XSSimpleTypeDecl(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType, false, annotations); 102 } 103 104 115 public XSSimpleType createTypeUnion(String name, String targetNamespace, 116 short finalSet, XSSimpleType[] memberTypes, 117 XSObjectList annotations) { 118 int typeNum = memberTypes.length; 119 XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum]; 120 System.arraycopy(memberTypes, 0, mtypes, 0, typeNum); 121 122 return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes, annotations); 123 } 124 125 static void createBuiltInTypes(SymbolHash types) { 127 final String ANYSIMPLETYPE = "anySimpleType"; 129 final String ANYURI = "anyURI"; 130 final String BASE64BINARY = "base64Binary"; 131 final String BOOLEAN = "boolean"; 132 final String BYTE = "byte"; 133 final String DATE = "date"; 134 final String DATETIME = "dateTime"; 135 final String DAY = "gDay"; 136 final String DECIMAL = "decimal"; 137 final String INT = "int"; 138 final String INTEGER = "integer"; 139 final String LONG = "long"; 140 final String NEGATIVEINTEGER = "negativeInteger"; 141 final String MONTH = "gMonth"; 142 final String MONTHDAY = "gMonthDay"; 143 final String NONNEGATIVEINTEGER= "nonNegativeInteger"; 144 final String NONPOSITIVEINTEGER= "nonPositiveInteger"; 145 final String POSITIVEINTEGER = "positiveInteger"; 146 final String SHORT = "short"; 147 final String STRING = "string"; 148 final String TIME = "time"; 149 final String UNSIGNEDBYTE = "unsignedByte"; 150 final String UNSIGNEDINT = "unsignedInt"; 151 final String UNSIGNEDLONG = "unsignedLong"; 152 final String UNSIGNEDSHORT = "unsignedShort"; 153 final String YEAR = "gYear"; 154 final String YEARMONTH = "gYearMonth"; 155 156 final XSFacets facets = new XSFacets(); 157 158 XSSimpleTypeDecl anySimpleType = XSSimpleTypeDecl.fAnySimpleType; 159 types.put(ANYSIMPLETYPE, anySimpleType); 160 XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_STRING, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.STRING_DT); 161 types.put(STRING, stringDV); 162 types.put(BOOLEAN, new XSSimpleTypeDecl(anySimpleType, BOOLEAN, XSSimpleTypeDecl.DV_BOOLEAN, XSSimpleType.ORDERED_FALSE, false, true, false, true, XSConstants.BOOLEAN_DT)); 163 XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(anySimpleType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.DECIMAL_DT); 164 types.put(DECIMAL, decimalDV); 165 166 types.put(ANYURI, new XSSimpleTypeDecl(anySimpleType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ANYURI_DT)); 167 types.put(BASE64BINARY, new XSSimpleTypeDecl(anySimpleType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.BASE64BINARY_DT)); 168 types.put(DATETIME, new XSSimpleTypeDecl(anySimpleType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATETIME_DT)); 169 types.put(TIME, new XSSimpleTypeDecl(anySimpleType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.TIME_DT)); 170 types.put(DATE, new XSSimpleTypeDecl(anySimpleType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATE_DT)); 171 types.put(YEARMONTH, new XSSimpleTypeDecl(anySimpleType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEARMONTH_DT)); 172 types.put(YEAR, new XSSimpleTypeDecl(anySimpleType, YEAR, XSSimpleTypeDecl.DV_GYEAR, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEAR_DT)); 173 types.put(MONTHDAY, new XSSimpleTypeDecl(anySimpleType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTHDAY_DT)); 174 types.put(DAY, new XSSimpleTypeDecl(anySimpleType, DAY, XSSimpleTypeDecl.DV_GDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GDAY_DT)); 175 types.put(MONTH, new XSSimpleTypeDecl(anySimpleType, MONTH, XSSimpleTypeDecl.DV_GMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTH_DT)); 176 177 XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, XSSimpleTypeDecl.DV_INTEGER, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.INTEGER_DT); 178 types.put(INTEGER, integerDV); 179 180 facets.maxInclusive = "0"; 181 XSSimpleTypeDecl nonPositiveDV = new XSSimpleTypeDecl(integerDV, NONPOSITIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONPOSITIVEINTEGER_DT); 182 nonPositiveDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0); 183 types.put(NONPOSITIVEINTEGER, nonPositiveDV); 184 185 facets.maxInclusive = "-1"; 186 XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(integerDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NEGATIVEINTEGER_DT); 187 negativeDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0); 188 types.put(NEGATIVEINTEGER, negativeDV); 189 190 facets.maxInclusive = "9223372036854775807"; 191 facets.minInclusive = "-9223372036854775808"; 192 XSSimpleTypeDecl longDV = new XSSimpleTypeDecl(integerDV, LONG, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LONG_DT); 193 longDV.applyFacets1(facets , (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 ); 194 types.put(LONG, longDV); 195 196 197 facets.maxInclusive = "2147483647"; 198 facets.minInclusive = "-2147483648"; 199 XSSimpleTypeDecl intDV = new XSSimpleTypeDecl(longDV, INT, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.INT_DT); 200 intDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 ); 201 types.put(INT, intDV); 202 203 facets.maxInclusive = "32767"; 204 facets.minInclusive = "-32768"; 205 XSSimpleTypeDecl shortDV = new XSSimpleTypeDecl(intDV, SHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.SHORT_DT); 206 shortDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 ); 207 types.put(SHORT, shortDV); 208 209 facets.maxInclusive = "127"; 210 facets.minInclusive = "-128"; 211 XSSimpleTypeDecl byteDV = new XSSimpleTypeDecl(shortDV, BYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.BYTE_DT); 212 byteDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 ); 213 types.put(BYTE, byteDV); 214 215 facets.minInclusive = "0" ; 216 XSSimpleTypeDecl nonNegativeDV = new XSSimpleTypeDecl(integerDV, NONNEGATIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONNEGATIVEINTEGER_DT); 217 nonNegativeDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 ); 218 types.put(NONNEGATIVEINTEGER, nonNegativeDV); 219 220 facets.maxInclusive = "18446744073709551615" ; 221 XSSimpleTypeDecl unsignedLongDV = new XSSimpleTypeDecl(nonNegativeDV, UNSIGNEDLONG , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDLONG_DT); 222 unsignedLongDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 ); 223 types.put(UNSIGNEDLONG, unsignedLongDV); 224 225 facets.maxInclusive = "4294967295" ; 226 XSSimpleTypeDecl unsignedIntDV = new XSSimpleTypeDecl(unsignedLongDV, UNSIGNEDINT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDINT_DT); 227 unsignedIntDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 ); 228 types.put(UNSIGNEDINT, unsignedIntDV); 229 230 facets.maxInclusive = "65535" ; 231 XSSimpleTypeDecl unsignedShortDV = new XSSimpleTypeDecl(unsignedIntDV, UNSIGNEDSHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDSHORT_DT); 232 unsignedShortDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 ); 233 types.put(UNSIGNEDSHORT, unsignedShortDV); 234 235 facets.maxInclusive = "255" ; 236 XSSimpleTypeDecl unsignedByteDV = new XSSimpleTypeDecl(unsignedShortDV, UNSIGNEDBYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDBYTE_DT); 237 unsignedByteDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 ); 238 types.put(UNSIGNEDBYTE, unsignedByteDV); 239 240 facets.minInclusive = "1" ; 241 XSSimpleTypeDecl positiveIntegerDV = new XSSimpleTypeDecl(nonNegativeDV, POSITIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.POSITIVEINTEGER_DT); 242 positiveIntegerDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 ); 243 types.put(POSITIVEINTEGER, positiveIntegerDV); 244 } 246 } | Popular Tags |