1 17 package org.apache.ws.jaxme.xs.xml.impl; 18 19 import javax.xml.parsers.ParserConfigurationException ; 20 import javax.xml.parsers.SAXParser ; 21 import javax.xml.parsers.SAXParserFactory ; 22 23 import org.xml.sax.ErrorHandler ; 24 import org.xml.sax.Locator ; 25 import org.xml.sax.SAXException ; 26 import org.xml.sax.SAXParseException ; 27 import org.xml.sax.XMLReader ; 28 import org.apache.ws.jaxme.xs.XSParser; 29 import org.apache.ws.jaxme.xs.parser.XSContext; 30 import org.apache.ws.jaxme.xs.parser.XsSAXParser; 31 import org.apache.ws.jaxme.xs.parser.impl.AbstractXsSAXParser; 32 import org.apache.ws.jaxme.xs.xml.*; 33 34 35 41 public class XsObjectFactoryImpl implements XsObjectFactory { 42 private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; 43 private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; 44 45 protected XSContext getContext() { 46 return XSParser.getRunningInstance().getContext(); 47 } 48 49 public Locator getLocator() { 50 return getContext().getLocator(); 51 } 52 53 public XsAGDefRef newXsAGDefRef(XsObject pOwner) { 54 return new XsAGDefRefImpl(pOwner); 55 } 56 57 public XsAGOccurs newXsAGOccurs(XsObject pOwner) { 58 return new XsAGOccursImpl(pOwner); 59 } 60 61 public XsEAnnotation newXsEAnnotation(XsObject pParent) { 62 return new XsEAnnotationImpl(pParent); 63 } 64 65 public XsEAny newXsEAny(XsObject pParent) { 66 return new XsEAnyImpl(pParent); 67 } 68 69 public XsEAppinfo newXsEAppinfo(XsObject pParent) { 70 return new XsEAppinfoImpl(pParent); 71 } 72 73 public XsEComplexContent newXsEComplexContent(XsObject pParent) { 74 return new XsEComplexContentImpl(pParent); 75 } 76 77 public XsEChoice newXsEChoice(XsObject pParent) { 78 return new XsEChoiceImpl(pParent); 79 } 80 81 public XsEDocumentation newXsEDocumentation(XsObject pParent) { 82 return new XsEDocumentationImpl(pParent); 83 } 84 85 public XsEEnumeration newXsEEnumeration(XsObject pParent) { 86 return new XsEEnumerationImpl(pParent); 87 } 88 89 public XsEFractionDigits newXsEFractionDigits(XsObject pParent) { 90 return new XsEFractionDigitsImpl(pParent); 91 } 92 93 public XsEField newXsEField(XsObject pParent) { 94 return new XsEFieldImpl(pParent); 95 } 96 97 public XsEImport newXsEImport(XsObject pParent) { 98 return new XsEImportImpl(pParent); 99 } 100 101 public XsEInclude newXsEInclude(XsObject pParent) { 102 return new XsEIncludeImpl(pParent); 103 } 104 105 public XsEKey newXsEKey(XsObject pParent) { 106 return new XsEKeyImpl(pParent); 107 } 108 109 public XsEKeyref newXsEKeyref(XsObject pParent) { 110 return new XsEKeyrefImpl(pParent); 111 } 112 113 public XsELength newXsELength(XsObject pParent) { 114 return new XsELengthImpl(pParent); 115 } 116 117 public XsEList newXsEList(XsObject pParent) { 118 return new XsEListImpl(pParent); 119 } 120 121 public XsEMaxExclusive newXsEMaxExclusive(XsObject pParent) { 122 return new XsEMaxExclusiveImpl(pParent); 123 } 124 125 public XsEMaxInclusive newXsEMaxInclusive(XsObject pParent) { 126 return new XsEMaxInclusiveImpl(pParent); 127 } 128 129 public XsEMaxLength newXsEMaxLength(XsObject pParent) { 130 return new XsEMaxLengthImpl(pParent); 131 } 132 133 public XsEMinExclusive newXsEMinExclusive(XsObject pParent) { 134 return new XsEMinExclusiveImpl(pParent); 135 } 136 137 public XsEMinInclusive newXsEMinInclusive(XsObject pParent) { 138 return new XsEMinInclusiveImpl(pParent); 139 } 140 141 public XsEMinLength newXsEMinLength(XsObject pParent) { 142 return new XsEMinLengthImpl(pParent); 143 } 144 145 public XsENotation newXsENotation(XsObject pParent) { 146 return new XsENotationImpl(pParent); 147 } 148 149 public XsEPattern newXsEPattern(XsObject pParent) { 150 return new XsEPatternImpl(pParent); 151 } 152 153 public XsERedefine newXsERedefine(XsObject pParent) { 154 return new XsERedefineImpl(pParent); 155 } 156 157 public XsERestriction newXsERestriction(XsObject pParent) { 158 return new XsERestrictionImpl(pParent); 159 } 160 161 public XsESequence newXsESequence(XsObject pParent) { 162 return new XsESequenceImpl(pParent); 163 } 164 165 public XsESelector newXsESelector(XsObject pParent) { 166 return new XsESelectorImpl(pParent); 167 } 168 169 public XsESimpleContent newXsESimpleContent(XsObject pParent) { 170 return new XsESimpleContentImpl(pParent); 171 } 172 173 public XsESchema newXsESchema() { 174 return new XsESchemaImpl(getContext()); 175 } 176 177 public XsETopLevelSimpleType newXsETopLevelSimpleType(XsObject pParent) { 178 return new XsETopLevelSimpleTypeImpl(pParent); 179 } 180 181 public XsETotalDigits newXsETotalDigits(XsObject pParent) { 182 return new XsETotalDigitsImpl(pParent); 183 } 184 185 public XsEUnion newXsEUnion(XsObject pParent) { 186 return new XsEUnionImpl(pParent); 187 } 188 189 public XsEUnique newXsEUnique(XsObject pParent) { 190 return new XsEUniqueImpl(pParent); 191 } 192 193 public XsEWhiteSpace newXsEWhiteSpace(XsObject pParent) { 194 return new XsEWhiteSpaceImpl(pParent); 195 } 196 197 public XsGAllModel newXsGAllModel(XsObject pParent) { 198 return new XsGAllModelImpl(pParent); 199 } 200 201 public XsGAttrDecls newXsGAttrDecls(XsObject pOwner) { 202 return new XsGAttrDeclsImpl(pOwner); 203 } 204 205 public XsGIdentityConstraint newXsGIdentityConstraint(XsObject pOwner) { 206 return new XsGIdentityConstraintImpl(pOwner); 207 } 208 209 public XsGParticle newXsGParticle(XsObject pOwner) { 210 return new XsGParticleImpl(pOwner); 211 } 212 213 public XsGComplexTypeModel newXsGComplexTypeModel(XsObject pOwner) { 214 return new XsGComplexTypeModelImpl(pOwner); 215 } 216 217 public XsGSimpleRestrictionModel newXsGSimpleRestrictionModel(XsObject pOwner) { 218 return new XsGSimpleRestrictionModelImpl(pOwner); 219 } 220 221 public XsGTypeDefParticle newXsGTypeDefParticle(XsObject pOwner) { 222 return new XsGTypeDefParticleImpl(pOwner); 223 } 224 225 public XsTAll newXsTAll(XsObject pParent) { 226 return new XsTAllImpl(pParent); 227 } 228 229 public XsTAnnotated newXsTAnnotated(XsObject pParent) { 230 return new XsTAnnotatedImpl(pParent); 231 } 232 233 public XsTAttribute newXsTAttribute(XsObject pParent) { 234 return new XsTAttributeImpl(pParent); 235 } 236 237 public XsTAttributeGroup newXsTAttributeGroup(XsObject pParent) { 238 return new XsTAttributeGroupImpl(pParent); 239 } 240 241 public XsTAttributeGroupRef newXsTAttributeGroupRef(XsObject pParent) { 242 return new XsTAttributeGroupRefImpl(pParent); 243 } 244 245 public XsTComplexRestrictionType newXsTComplexRestrictionType(XsObject pParent) { 246 return new XsTComplexRestrictionTypeImpl(pParent); 247 } 248 249 public XsTComplexType newXsTComplexType(XsObject pParent) { 250 return new XsTComplexTypeImpl(pParent); 251 } 252 253 public XsTExtensionType newXsTExtensionType(XsObject pParent) { 254 return new XsTExtensionTypeImpl(pParent); 255 } 256 257 public XsTLocalElement newXsTLocalElement(XsObject pParent) { 258 return new XsTLocalElementImpl(pParent); 259 } 260 261 266 public XsTLocalElement newXsTLocalAllElement(XsObject pParent) { 267 return new XsTLocalAllElementImpl(pParent); 268 } 269 270 public XsTLocalComplexType newXsTLocalComplexType(XsObject pParent) { 271 return new XsTLocalComplexTypeImpl(pParent); 272 } 273 274 public XsTLocalSimpleType newXsTLocalSimpleType(XsObject pParent) { 275 return new XsTLocalSimpleTypeImpl(pParent); 276 } 277 278 public XsTNamedGroup newXsTNamedGroup(XsObject pParent) { 279 return new XsTNamedGroupImpl(pParent); 280 } 281 282 public XsTGroup newXsTGroup(XsObject pParent) { 283 return new XsTGroupImpl(pParent); 284 } 285 286 public XsTGroupRef newXsTGroupRef(XsObject pParent) { 287 return new XsTGroupRefImpl(pParent); 288 } 289 290 public XsTSimpleExplicitGroup newXsTSimpleExplicitGroup(XsObject pParent) { 291 return new XsTSimpleExplicitGroupImpl(pParent); 292 } 293 294 public XsTSimpleExtensionType newXsTSimpleExtensionType(XsObject pParent) { 295 return new XsTSimpleExtensionTypeImpl(pParent); 296 } 297 298 public XsTSimpleRestrictionType newXsTSimpleRestrictionType(XsObject pParent) { 299 return new XsTSimpleRestrictionTypeImpl(pParent); 300 } 301 302 public XsTTopLevelElement newXsTTopLevelElement(XsObject pParent) { 303 return new XsTTopLevelElementImpl(pParent); 304 } 305 306 public XsTWildcard newXsTWildcard(XsObject pParent) { 307 return new XsTWildcardImpl(pParent); 308 } 309 310 public XMLReader newXMLReader(boolean pValidating) throws ParserConfigurationException , SAXException { 311 SAXParserFactory spf = SAXParserFactory.newInstance(); 312 spf.setNamespaceAware(true); 313 spf.setValidating(pValidating); 314 SAXParser sp = spf.newSAXParser(); 315 if (pValidating) { 316 sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); 317 } 318 XMLReader xr = sp.getXMLReader(); 319 xr.setErrorHandler(new ErrorHandler (){ 320 public void error(SAXParseException e) throws SAXException { throw e; } 321 public void fatalError(SAXParseException fe) throws SAXException { throw fe; } 322 public void warning(SAXParseException w) throws SAXException { throw w; } 323 }); 324 return xr; 325 } 326 327 public XsSAXParser newXsSAXParser() { 328 return newXsSAXParser(newXsESchema()); 329 } 330 331 public XsSAXParser newXsSAXParser(Object pBean) { 332 return new AbstractXsSAXParser(pBean){ 333 public XSContext getData(){ 334 return XSParser.getRunningInstance().getContext(); 335 } 336 }; 337 } 338 } 339 | Popular Tags |