KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > xml > impl > XsObjectFactoryImpl


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.xs.xml.impl;
18
19 import javax.xml.parsers.ParserConfigurationException JavaDoc;
20 import javax.xml.parsers.SAXParser JavaDoc;
21 import javax.xml.parsers.SAXParserFactory JavaDoc;
22
23 import org.xml.sax.ErrorHandler JavaDoc;
24 import org.xml.sax.Locator JavaDoc;
25 import org.xml.sax.SAXException JavaDoc;
26 import org.xml.sax.SAXParseException JavaDoc;
27 import org.xml.sax.XMLReader JavaDoc;
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 /** <p>The XsObjectFactory, which allows to extend the parser.
36  * The various elements and/or attributes use this factory to
37  * create new objects.</p>
38  *
39  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
40  */

41 public class XsObjectFactoryImpl implements XsObjectFactory {
42   private static final String JavaDoc JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
43   private static final String JavaDoc W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
44
45   protected XSContext getContext() {
46     return XSParser.getRunningInstance().getContext();
47   }
48
49   public Locator JavaDoc 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   /** <p>Creates a new instance of {@link XsTLocalElement}, which
262    * is located inside of an <code>xs:all</code> group. The
263    * element ensures that its <code>minOccurs</code> and
264    * <code>maxOccurs</code> values are 0 or 1.</p>
265    */

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 JavaDoc newXMLReader(boolean pValidating) throws ParserConfigurationException JavaDoc, SAXException JavaDoc {
311     SAXParserFactory JavaDoc spf = SAXParserFactory.newInstance();
312     spf.setNamespaceAware(true);
313     spf.setValidating(pValidating);
314     SAXParser JavaDoc sp = spf.newSAXParser();
315     if (pValidating) {
316       sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
317     }
318     XMLReader JavaDoc xr = sp.getXMLReader();
319     xr.setErrorHandler(new ErrorHandler JavaDoc(){
320       public void error(SAXParseException JavaDoc e) throws SAXException JavaDoc { throw e; }
321       public void fatalError(SAXParseException JavaDoc fe) throws SAXException JavaDoc { throw fe; }
322       public void warning(SAXParseException JavaDoc w) throws SAXException JavaDoc { throw w; }
323     });
324     return xr;
325   }
326
327   public XsSAXParser newXsSAXParser() {
328     return newXsSAXParser(newXsESchema());
329   }
330
331   public XsSAXParser newXsSAXParser(Object JavaDoc pBean) {
332     return new AbstractXsSAXParser(pBean){
333       public XSContext getData(){
334         return XSParser.getRunningInstance().getContext();
335       }
336     };
337   }
338 }
339
Popular Tags