KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > ASModelImpl


1 /*
2  * Copyright 2001, 2002,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.xerces.dom;
18
19 import java.util.Vector JavaDoc;
20
21 import org.w3c.dom.DOMException JavaDoc;
22 import org.apache.xerces.dom3.as.*;
23 import org.apache.xerces.impl.xs.SchemaGrammar;
24
25 /**
26  * To begin with, an abstract schema is a generic structure that could
27  * contain both internal and external subsets. An <code>ASModel</code> is an
28  * abstract object that could map to a DTD , an XML Schema , a database
29  * schema, etc. An <code>ASModel</code> could represent either an internal
30  * or an external subset; hence an abstract schema could be composed of an
31  * <code>ASModel</code> representing the internal subset and an
32  * <code>ASModel</code> representing the external subset. Note that the
33  * <code>ASModel</code> representing the external subset could consult the
34  * <code>ASModel</code> representing the internal subset. Furthermore, the
35  * <code>ASModel</code> representing the internal subset could be set to
36  * null by the <code>setInternalAS</code> method as a mechanism for
37  * "removal". In addition, only one <code>ASModel</code> representing the
38  * external subset can be specified as "active" and it is possible that none
39  * are "active". Finally, the <code>ASModel</code> contains the factory
40  * methods needed to create a various types of ASObjects like
41  * <code>ASElementDeclaration</code>, <code>ASAttributeDeclaration</code>,
42  * etc.
43  * <p>See also the <a HREF='http://www.w3.org/TR/2001/WD-DOM-Level-3-ASLS-20011025'>
44  * Document Object Model (DOM) Level 3 Abstract Schemas and Load and Save Specification</a>.
45  * @deprecated
46  * @author Pavani Mukthipudi
47  * @author Neil Graham
48  * @version $Id: ASModelImpl.java,v 1.6 2004/02/24 23:23:18 mrglavas Exp $
49  */

50 public class ASModelImpl implements ASModel {
51
52     //
53
// Data
54
//
55
boolean fNamespaceAware = true;
56
57     // conceptually, an ASModel may contain grammar information and/or
58
// other ASModels. These two fields divide that function.
59
protected Vector JavaDoc fASModels;
60     protected SchemaGrammar fGrammar = null;
61     
62     //
63
// Constructors
64
//
65

66     public ASModelImpl() {
67         fASModels = new Vector JavaDoc();
68     }
69
70     public ASModelImpl(boolean isNamespaceAware) {
71         fASModels = new Vector JavaDoc();
72         fNamespaceAware = isNamespaceAware;
73     }
74     
75     //
76
// ASObject methods
77
//
78

79     /**
80      * A code representing the underlying object as defined above.
81      */

82     public short getAsNodeType() {
83         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
84         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
85     }
86
87     /**
88      * The <code>ASModel</code> object associated with this
89      * <code>ASObject</code>. For a node of type <code>AS_MODEL</code>, this
90      * is <code>null</code>.
91      */

92     public ASModel getOwnerASModel() {
93         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
94         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
95     }
96     
97     /**
98      * The <code>ASModel</code> object associated with this
99      * <code>ASObject</code>. For a node of type <code>AS_MODEL</code>, this
100      * is <code>null</code>.
101      */

102     public void setOwnerASModel(ASModel ownerASModel) {
103         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
104         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
105     }
106
107     /**
108      * The <code>name</code> of this <code>ASObject</code> depending on the
109      * <code>ASObject</code> type.
110      */

111     public String JavaDoc getNodeName() {
112         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
113         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
114     }
115     
116     /**
117      * The <code>name</code> of this <code>ASObject</code> depending on the
118      * <code>ASObject</code> type.
119      */

120     public void setNodeName(String JavaDoc nodeName) {
121         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
122         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
123     }
124
125     /**
126      * The namespace prefix of this node, or <code>null</code> if it is
127      * unspecified.
128      */

129     public String JavaDoc getPrefix() {
130         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
131         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
132     }
133     
134     /**
135      * The namespace prefix of this node, or <code>null</code> if it is
136      * unspecified.
137      */

138     public void setPrefix(String JavaDoc prefix) {
139         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
140         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
141     }
142
143     /**
144      * Returns the local part of the qualified name of this
145      * <code>ASObject</code>.
146      */

147     public String JavaDoc getLocalName() {
148         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
149         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
150     }
151     
152     /**
153      * Returns the local part of the qualified name of this
154      * <code>ASObject</code>.
155      */

156     public void setLocalName(String JavaDoc localName) {
157         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
158         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
159     }
160
161     /**
162      * The namespace URI of this node, or <code>null</code> if it is
163      * unspecified. defines how a namespace URI is attached to schema
164      * components.
165      */

166     public String JavaDoc getNamespaceURI() {
167         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
168         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
169     }
170     
171     /**
172      * The namespace URI of this node, or <code>null</code> if it is
173      * unspecified. defines how a namespace URI is attached to schema
174      * components.
175      */

176     public void setNamespaceURI(String JavaDoc namespaceURI) {
177         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
178         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
179     }
180
181     /**
182      * Creates a copy of this <code>ASObject</code>. See text for
183      * <code>cloneNode</code> off of <code>Node</code> but substitute AS
184      * functionality.
185      * @param deep Setting the <code>deep</code> flag on, causes the whole
186      * subtree to be duplicated. Setting it to <code>false</code> only
187      * duplicates its immediate child nodes.
188      * @return Cloned <code>ASObject</code>.
189      */

190     public ASObject cloneASObject(boolean deep) {
191         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
192         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
193     }
194     
195     //
196
// ASModel methods
197
//
198

199     /**
200      * <code>true</code> if this <code>ASModel</code> defines the document
201      * structure in terms of namespaces and local names ; <code>false</code>
202      * if the document structure is defined only in terms of
203      * <code>QNames</code>.
204      */

205     public boolean getIsNamespaceAware() {
206         return fNamespaceAware;
207     }
208
209     /**
210      * 0 if used internally, 1 if used externally, 2 if not all. An exception
211      * will be raised if it is incompatibly shared or in use as an internal
212      * subset.
213      */

214     public short getUsageLocation() {
215         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
216         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
217     }
218
219     /**
220      * The URI reference.
221      */

222     public String JavaDoc getAsLocation() {
223         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
224         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
225     }
226     
227     /**
228      * The URI reference.
229      */

230     public void setAsLocation(String JavaDoc asLocation) {
231         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
232         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
233     }
234
235     /**
236      * The hint to locating an ASModel.
237      */

238     public String JavaDoc getAsHint() {
239         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
240         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
241     }
242     
243     /**
244      * The hint to locating an ASModel.
245      */

246     public void setAsHint(String JavaDoc asHint) {
247         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
248         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
249     }
250     
251     /**
252      * If <code>usage</code> is EXTERNAL_SUBSET or NOT_USED, and the
253      * <code>ASModel</code> is simply a container of other ASModels.
254      */

255     public boolean getContainer() {
256         return (fGrammar != null);
257     }
258
259     /**
260      * Instead of returning an all-in-one <code>ASObject</code> with
261      * <code>ASModel</code> methods, have discernible top-level/"global"
262      * element declarations. If one attempts to add, set, or remove a node
263      * type other than the intended one, a hierarchy exception (or
264      * equivalent is thrown).
265      */

266     public ASNamedObjectMap getElementDeclarations() {
267         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
268         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
269     }
270
271     /**
272      * Instead of returning an all-in-one <code>ASObject</code> with
273      * <code>ASModel</code> methods, have discernible top-level/"global"
274      * attribute declarations. If one attempts to add, set, or remove a node
275      * type other than the intended one, a hierarchy exception (or
276      * equivalent is thrown).
277      */

278     public ASNamedObjectMap getAttributeDeclarations() {
279         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
280         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
281     }
282
283     /**
284      * Instead of returning an all-in-one <code>ASObject</code> with
285      * <code>ASModel</code> methods, have discernible top-level/"global"
286      * notation declarations. If one attempts to add, set, or remove a node
287      * type other than the intended one, a hierarchy exception (or
288      * equivalent is thrown).
289      */

290     public ASNamedObjectMap getNotationDeclarations() {
291         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
292         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
293     }
294
295     /**
296      * Instead of returning an all-in-one <code>ASObject</code> with
297      * <code>ASModel</code> methods, have discernible top-level/"global"
298      * entity declarations. If one attempts to add, set, or remove a node
299      * type other than the intended one, a hierarchy exception (or
300      * equivalent is thrown).
301      */

302     public ASNamedObjectMap getEntityDeclarations() {
303         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
304         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
305     }
306
307     /**
308      * Instead of returning an all-in-one <code>ASObject</code> with
309      * <code>ASModel</code> methods, have discernible top-level/"global
310      * content model declarations. If one attempts to add, set, or remove a
311      * node type other than the intended one, a hierarchy exception (or
312      * equivalent is thrown).
313      */

314     public ASNamedObjectMap getContentModelDeclarations() {
315         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
316         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
317     }
318
319     /**
320      * This method will allow the nesting or "importation" of ASModels.
321      * @param abstractSchema ASModel to be set. Subsequent calls will nest
322      * the ASModels within the specified <code>ownerASModel</code>.
323      */

324     public void addASModel(ASModel abstractSchema) {
325         fASModels.addElement(abstractSchema);
326     }
327
328     /**
329      * To retrieve a list of nested ASModels without reference to names.
330      * @return A list of ASModels.
331      */

332     public ASObjectList getASModels() {
333         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
334         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
335     }
336
337     /**
338      * Removes only the specified <code>ASModel</code> from the list of
339      * <code>ASModel</code>s.
340      * @param as AS to be removed.
341      */

342     public void removeAS(ASModel as) {
343         fASModels.removeElement(as);
344     }
345
346     /**
347      * Determines if an <code>ASModel</code> itself is valid, i.e., confirming
348      * that it's well-formed and valid per its own formal grammar.
349      * @return <code>true</code> if the <code>ASModel</code> is valid,
350      * <code>false</code> otherwise.
351      */

352     public boolean validate() {
353         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
354         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
355     }
356
357     /**
358      * Imports <code>ASObject</code> into ASModel.
359      * @param asobject <code>ASObject</code> to be imported.
360      */

361     public void importASObject(ASObject asobject) {
362         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
363         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
364     }
365
366     /**
367      * Inserts <code>ASObject</code> into ASModel.
368      * @param asobject <code>ASObject</code> to be inserted.
369      */

370     public void insertASObject(ASObject asobject) {
371         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
372         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
373     }
374     
375     /**
376      * Creates an element declaration for the element type specified.
377      * @param namespaceURI The <code>namespace URI</code> of the element type
378      * being declared.
379      * @param name The name of the element. The format of the name could be
380      * an NCName as defined by XML Namespaces or a Name as defined by XML
381      * 1.0; it's ASModel-dependent.
382      * @return A new <code>ASElementDeclaration</code> object with
383      * <code>name</code> attribute set to <code>tagname</code> and
384      * <code>namespaceURI</code> set to <code>systemId</code>. Other
385      * attributes of the element declaration are set through
386      * <code>ASElementDeclaration</code> interface methods.
387      * @exception DOMException
388      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
389      * illegal character.
390      */

391     public ASElementDeclaration createASElementDeclaration(String JavaDoc namespaceURI,
392                                                            String JavaDoc name)
393                                                            throws DOMException JavaDoc {
394         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
395         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
396     }
397
398     /**
399      * Creates an attribute declaration.
400      * @param namespaceURI The namespace URI of the attribute being declared.
401      * @param name The name of the attribute. The format of the name could be
402      * an NCName as defined by XML Namespaces or a Name as defined by XML
403      * 1.0; it's ASModel-dependent.
404      * @return A new <code>ASAttributeDeclaration</code> object with
405      * appropriate attributes set by input parameters.
406      * @exception DOMException
407      * INVALID_CHARACTER_ERR: Raised if the input <code>name</code>
408      * parameter contains an illegal character.
409      */

410     public ASAttributeDeclaration createASAttributeDeclaration(String JavaDoc namespaceURI,
411                                                                String JavaDoc name)
412                                                                throws DOMException JavaDoc {
413         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
414         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
415     }
416
417     /**
418      * Creates a new notation declaration.
419      * @param namespaceURI The namespace URI of the notation being declared.
420      * @param name The name of the notation. The format of the name could be
421      * an NCName as defined by XML Namespaces or a Name as defined by XML
422      * 1.0; it's ASModel-dependent.
423      * @param systemId The system identifier for the notation declaration.
424      * @param publicId The public identifier for the notation declaration.
425      * @return A new <code>ASNotationDeclaration</code> object with
426      * <code>notationName</code> attribute set to <code>name</code> and
427      * <code>publicId</code> and <code>systemId</code> set to the
428      * corresponding fields.
429      * @exception DOMException
430      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
431      * illegal character.
432      */

433     public ASNotationDeclaration createASNotationDeclaration(String JavaDoc namespaceURI, String JavaDoc name,
434                                                              String JavaDoc systemId, String JavaDoc publicId)
435                                                              throws DOMException JavaDoc {
436         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
437         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
438     }
439     
440     /**
441      * Creates an ASEntityDeclaration.
442      * @param name The name of the entity being declared.
443      * @return A new <code>ASEntityDeclaration</code> object with
444      * <code>entityName</code> attribute set to name.
445      * @exception DOMException
446      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
447      * illegal character.
448      */

449     public ASEntityDeclaration createASEntityDeclaration(String JavaDoc name)
450                                                          throws DOMException JavaDoc {
451         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
452         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
453     }
454
455     /**
456      * Creates an object which describes part of an
457      * <code>ASElementDeclaration</code>'s content model.
458      * @param minOccurs The minimum occurrence for the subModels of this
459      * <code>ASContentModel</code>.
460      * @param maxOccurs The maximum occurrence for the subModels of this
461      * <code>ASContentModel</code>.
462      * @param operator operator of type <code>AS_CHOICE</code>,
463      * <code>AS_SEQUENCE</code>, <code>AS_ALL</code> or
464      * <code>AS_NONE</code>.
465      * @return A new <code>ASContentModel</code> object.
466      * @exception DOMASException
467      * A DOMASException, e.g., <code>minOccurs &gt; maxOccurs</code>.
468      */

469     public ASContentModel createASContentModel(int minOccurs, int maxOccurs,
470                                                short operator) throws DOMASException {
471         String JavaDoc msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
472         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, msg);
473     }
474
475
476     // convenience methods
477
public SchemaGrammar getGrammar() {
478         return fGrammar;
479     }
480     public void setGrammar(SchemaGrammar grammar) {
481         fGrammar = grammar;
482     }
483
484     public Vector JavaDoc getInternalASModels() {
485         return fASModels;
486     }
487
488 }
489
Popular Tags