1 package net.sf.saxon.type; 2 import net.sf.saxon.om.NamespaceConstant; 3 import net.sf.saxon.style.StandardNames; 4 5 import java.io.Serializable ; 6 import java.util.HashMap ; 7 8 12 13 public abstract class BuiltInSchemaFactory implements Serializable { 14 15 18 19 private static HashMap lookup = new HashMap (100); 20 21 private BuiltInSchemaFactory() { 22 } 23 24 static { 25 26 final String XS = NamespaceConstant.SCHEMA; 27 final String XDT = NamespaceConstant.XDT; 28 29 AnySimpleType anySimpleType = AnySimpleType.getInstance(); 30 lookup.put(new Integer (StandardNames.XS_ANY_SIMPLE_TYPE), anySimpleType); 31 32 BuiltInAtomicType anyAtomicType = 33 makeAtomicType(XDT, "anyAtomicType", anySimpleType); 34 BuiltInAtomicType numeric = 35 makeAtomicType(XDT, "numeric", anyAtomicType); 36 BuiltInAtomicType string = 37 makeAtomicType(XS, "string", anyAtomicType); 38 BuiltInAtomicType xsboolean = 39 makeAtomicType(XS, "boolean", anyAtomicType); 40 BuiltInAtomicType duration = 41 makeAtomicType(XS, "duration", anyAtomicType); 42 BuiltInAtomicType dateTime = 43 makeAtomicType(XS, "dateTime", anyAtomicType); 44 BuiltInAtomicType date = 45 makeAtomicType(XS, "date", anyAtomicType); 46 BuiltInAtomicType time = 47 makeAtomicType(XS, "time", anyAtomicType); 48 BuiltInAtomicType gYearMonth = 49 makeAtomicType(XS, "gYearMonth", anyAtomicType); 50 BuiltInAtomicType gMonth = 51 makeAtomicType(XS, "gMonth", anyAtomicType); 52 BuiltInAtomicType gMonthDay = 53 makeAtomicType(XS, "gMonthDay", anyAtomicType); 54 BuiltInAtomicType gYear = 55 makeAtomicType(XS, "gYear", anyAtomicType); 56 BuiltInAtomicType gDay = 57 makeAtomicType(XS, "gDay", anyAtomicType); 58 BuiltInAtomicType hexBinary = 59 makeAtomicType(XS, "hexBinary", anyAtomicType); 60 BuiltInAtomicType base64Binary = 61 makeAtomicType(XS, "base64Binary", anyAtomicType); 62 BuiltInAtomicType anyURI = 63 makeAtomicType(XS, "anyURI", anyAtomicType); 64 BuiltInAtomicType qName = 65 makeAtomicType(XS, "QName", anyAtomicType); 66 BuiltInAtomicType notation = 67 makeAtomicType(XS, "NOTATION", anyAtomicType); 68 69 BuiltInAtomicType untypedAtomic = 70 makeAtomicType(XDT, "untypedAtomic", anyAtomicType); 71 72 75 BuiltInAtomicType decimal = 76 makeAtomicType(XS, "decimal", numeric); 77 BuiltInAtomicType xsfloat = 78 makeAtomicType(XS, "float", numeric); 79 BuiltInAtomicType xsdouble = 80 makeAtomicType(XS, "double", numeric); 81 82 BuiltInAtomicType xsinteger = 83 makeAtomicType(XS, "integer", decimal); 84 85 BuiltInAtomicType nonPositiveInteger = 86 makeAtomicType(XS, "nonPositiveInteger", xsinteger); 87 BuiltInAtomicType negativeInteger = 88 makeAtomicType(XS, "negativeInteger", nonPositiveInteger); 89 BuiltInAtomicType xslong = 90 makeAtomicType(XS, "long", xsinteger); 91 BuiltInAtomicType xsint = 92 makeAtomicType(XS, "int", xslong); 93 BuiltInAtomicType xsshort = 94 makeAtomicType(XS, "short", xsint); 95 BuiltInAtomicType xsbyte = 96 makeAtomicType(XS, "byte", xsshort); 97 BuiltInAtomicType nonNegativeInteger = 98 makeAtomicType(XS, "nonNegativeInteger", xsinteger); 99 BuiltInAtomicType positiveInteger = 100 makeAtomicType(XS, "positiveInteger", nonNegativeInteger); 101 BuiltInAtomicType unsignedLong = 102 makeAtomicType(XS, "unsignedLong", nonNegativeInteger); 103 BuiltInAtomicType unsignedInt = 104 makeAtomicType(XS, "unsignedInt", unsignedLong); 105 BuiltInAtomicType unsignedShort = 106 makeAtomicType(XS, "unsignedShort", unsignedInt); 107 BuiltInAtomicType unsignedByte = 108 makeAtomicType(XS, "unsignedByte", unsignedShort); 109 110 BuiltInAtomicType ymd = 111 makeAtomicType(XDT, "yearMonthDuration", duration); 112 BuiltInAtomicType dtd = 113 makeAtomicType(XDT, "dayTimeDuration", duration); 114 115 BuiltInAtomicType normalizedString = 116 makeAtomicType(XS, "normalizedString", string); 117 BuiltInAtomicType token = 118 makeAtomicType(XS, "token", normalizedString); 119 BuiltInAtomicType language = 120 makeAtomicType(XS, "language", token); 121 BuiltInAtomicType name = 122 makeAtomicType(XS, "Name", token); 123 BuiltInAtomicType nmtoken = 124 makeAtomicType(XS, "NMTOKEN", token); 125 BuiltInAtomicType ncname = 126 makeAtomicType(XS, "NCName", name); 127 BuiltInAtomicType id = 128 makeAtomicType(XS, "ID", ncname); 129 BuiltInAtomicType idref = 130 makeAtomicType(XS, "IDREF", ncname); 131 BuiltInAtomicType entity = 132 makeAtomicType(XS, "ENTITY", ncname); 133 134 makeListType(XS, "NMTOKENS"); 135 makeListType(XS, "IDREFS"); 136 makeListType(XS, "ENTITIES"); 137 138 lookup.put(new Integer (StandardNames.XS_ANY_TYPE), AnyType.getInstance()); 139 lookup.put(new Integer (StandardNames.XDT_UNTYPED), Untyped.getInstance()); 140 } 141 142 private static BuiltInAtomicType makeAtomicType(String namespace, 143 String lname, 144 SimpleType baseType) { 145 BuiltInAtomicType t = new BuiltInAtomicType(StandardNames.getFingerprint(namespace, lname)); 146 t.setBaseTypeFingerprint(baseType.getFingerprint()); 147 lookup.put(new Integer (t.getFingerprint()), t); 148 return t; 149 } 150 151 private static BuiltInListType makeListType(String namespace, 152 String lname) { 153 BuiltInListType t = new BuiltInListType(StandardNames.getFingerprint(namespace, lname)); 154 lookup.put(new Integer (t.getFingerprint()), t); 155 return t; 156 } 157 158 public static SchemaType getSchemaType(int fingerprint) { 159 return (SchemaType)lookup.get(new Integer (fingerprint)); 160 } 161 162 163 } 164 165 | Popular Tags |