001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.dom;
019:
020: import java.util.Vector;
021:
022: import org.w3c.dom.DOMException;
023: import org.apache.xerces.dom3.as.*;
024: import org.apache.xerces.impl.xs.SchemaGrammar;
025:
026: /**
027: * To begin with, an abstract schema is a generic structure that could
028: * contain both internal and external subsets. An <code>ASModel</code> is an
029: * abstract object that could map to a DTD , an XML Schema , a database
030: * schema, etc. An <code>ASModel</code> could represent either an internal
031: * or an external subset; hence an abstract schema could be composed of an
032: * <code>ASModel</code> representing the internal subset and an
033: * <code>ASModel</code> representing the external subset. Note that the
034: * <code>ASModel</code> representing the external subset could consult the
035: * <code>ASModel</code> representing the internal subset. Furthermore, the
036: * <code>ASModel</code> representing the internal subset could be set to
037: * null by the <code>setInternalAS</code> method as a mechanism for
038: * "removal". In addition, only one <code>ASModel</code> representing the
039: * external subset can be specified as "active" and it is possible that none
040: * are "active". Finally, the <code>ASModel</code> contains the factory
041: * methods needed to create a various types of ASObjects like
042: * <code>ASElementDeclaration</code>, <code>ASAttributeDeclaration</code>,
043: * etc.
044: * <p>See also the <a href='http://www.w3.org/TR/2001/WD-DOM-Level-3-ASLS-20011025'>
045: * Document Object Model (DOM) Level 3 Abstract Schemas and Load and Save Specification</a>.
046: * @deprecated
047: * @author Pavani Mukthipudi
048: * @author Neil Graham
049: * @version $Id: ASModelImpl.java 447266 2006-09-18 05:57:49Z mrglavas $
050: */
051: public class ASModelImpl implements ASModel {
052:
053: //
054: // Data
055: //
056: boolean fNamespaceAware = true;
057:
058: // conceptually, an ASModel may contain grammar information and/or
059: // other ASModels. These two fields divide that function.
060: protected Vector fASModels;
061: protected SchemaGrammar fGrammar = null;
062:
063: //
064: // Constructors
065: //
066:
067: public ASModelImpl() {
068: fASModels = new Vector();
069: }
070:
071: public ASModelImpl(boolean isNamespaceAware) {
072: fASModels = new Vector();
073: fNamespaceAware = isNamespaceAware;
074: }
075:
076: //
077: // ASObject methods
078: //
079:
080: /**
081: * A code representing the underlying object as defined above.
082: */
083: public short getAsNodeType() {
084: String msg = DOMMessageFormatter.formatMessage(
085: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
086: null);
087: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
088: }
089:
090: /**
091: * The <code>ASModel</code> object associated with this
092: * <code>ASObject</code>. For a node of type <code>AS_MODEL</code>, this
093: * is <code>null</code>.
094: */
095: public ASModel getOwnerASModel() {
096: String msg = DOMMessageFormatter.formatMessage(
097: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
098: null);
099: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
100: }
101:
102: /**
103: * The <code>ASModel</code> object associated with this
104: * <code>ASObject</code>. For a node of type <code>AS_MODEL</code>, this
105: * is <code>null</code>.
106: */
107: public void setOwnerASModel(ASModel ownerASModel) {
108: String msg = DOMMessageFormatter.formatMessage(
109: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
110: null);
111: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
112: }
113:
114: /**
115: * The <code>name</code> of this <code>ASObject</code> depending on the
116: * <code>ASObject</code> type.
117: */
118: public String getNodeName() {
119: String msg = DOMMessageFormatter.formatMessage(
120: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
121: null);
122: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
123: }
124:
125: /**
126: * The <code>name</code> of this <code>ASObject</code> depending on the
127: * <code>ASObject</code> type.
128: */
129: public void setNodeName(String nodeName) {
130: String msg = DOMMessageFormatter.formatMessage(
131: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
132: null);
133: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
134: }
135:
136: /**
137: * The namespace prefix of this node, or <code>null</code> if it is
138: * unspecified.
139: */
140: public String getPrefix() {
141: String msg = DOMMessageFormatter.formatMessage(
142: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
143: null);
144: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
145: }
146:
147: /**
148: * The namespace prefix of this node, or <code>null</code> if it is
149: * unspecified.
150: */
151: public void setPrefix(String prefix) {
152: String msg = DOMMessageFormatter.formatMessage(
153: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
154: null);
155: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
156: }
157:
158: /**
159: * Returns the local part of the qualified name of this
160: * <code>ASObject</code>.
161: */
162: public String getLocalName() {
163: String msg = DOMMessageFormatter.formatMessage(
164: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
165: null);
166: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
167: }
168:
169: /**
170: * Returns the local part of the qualified name of this
171: * <code>ASObject</code>.
172: */
173: public void setLocalName(String localName) {
174: String msg = DOMMessageFormatter.formatMessage(
175: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
176: null);
177: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
178: }
179:
180: /**
181: * The namespace URI of this node, or <code>null</code> if it is
182: * unspecified. defines how a namespace URI is attached to schema
183: * components.
184: */
185: public String getNamespaceURI() {
186: String msg = DOMMessageFormatter.formatMessage(
187: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
188: null);
189: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
190: }
191:
192: /**
193: * The namespace URI of this node, or <code>null</code> if it is
194: * unspecified. defines how a namespace URI is attached to schema
195: * components.
196: */
197: public void setNamespaceURI(String namespaceURI) {
198: String msg = DOMMessageFormatter.formatMessage(
199: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
200: null);
201: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
202: }
203:
204: /**
205: * Creates a copy of this <code>ASObject</code>. See text for
206: * <code>cloneNode</code> off of <code>Node</code> but substitute AS
207: * functionality.
208: * @param deep Setting the <code>deep</code> flag on, causes the whole
209: * subtree to be duplicated. Setting it to <code>false</code> only
210: * duplicates its immediate child nodes.
211: * @return Cloned <code>ASObject</code>.
212: */
213: public ASObject cloneASObject(boolean deep) {
214: String msg = DOMMessageFormatter.formatMessage(
215: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
216: null);
217: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
218: }
219:
220: //
221: // ASModel methods
222: //
223:
224: /**
225: * <code>true</code> if this <code>ASModel</code> defines the document
226: * structure in terms of namespaces and local names ; <code>false</code>
227: * if the document structure is defined only in terms of
228: * <code>QNames</code>.
229: */
230: public boolean getIsNamespaceAware() {
231: return fNamespaceAware;
232: }
233:
234: /**
235: * 0 if used internally, 1 if used externally, 2 if not all. An exception
236: * will be raised if it is incompatibly shared or in use as an internal
237: * subset.
238: */
239: public short getUsageLocation() {
240: String msg = DOMMessageFormatter.formatMessage(
241: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
242: null);
243: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
244: }
245:
246: /**
247: * The URI reference.
248: */
249: public String getAsLocation() {
250: String msg = DOMMessageFormatter.formatMessage(
251: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
252: null);
253: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
254: }
255:
256: /**
257: * The URI reference.
258: */
259: public void setAsLocation(String asLocation) {
260: String msg = DOMMessageFormatter.formatMessage(
261: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
262: null);
263: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
264: }
265:
266: /**
267: * The hint to locating an ASModel.
268: */
269: public String getAsHint() {
270: String msg = DOMMessageFormatter.formatMessage(
271: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
272: null);
273: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
274: }
275:
276: /**
277: * The hint to locating an ASModel.
278: */
279: public void setAsHint(String asHint) {
280: String msg = DOMMessageFormatter.formatMessage(
281: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
282: null);
283: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
284: }
285:
286: /**
287: * If <code>usage</code> is EXTERNAL_SUBSET or NOT_USED, and the
288: * <code>ASModel</code> is simply a container of other ASModels.
289: */
290: public boolean getContainer() {
291: return (fGrammar != null);
292: }
293:
294: /**
295: * Instead of returning an all-in-one <code>ASObject</code> with
296: * <code>ASModel</code> methods, have discernible top-level/"global"
297: * element declarations. If one attempts to add, set, or remove a node
298: * type other than the intended one, a hierarchy exception (or
299: * equivalent is thrown).
300: */
301: public ASNamedObjectMap getElementDeclarations() {
302: String msg = DOMMessageFormatter.formatMessage(
303: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
304: null);
305: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
306: }
307:
308: /**
309: * Instead of returning an all-in-one <code>ASObject</code> with
310: * <code>ASModel</code> methods, have discernible top-level/"global"
311: * attribute declarations. If one attempts to add, set, or remove a node
312: * type other than the intended one, a hierarchy exception (or
313: * equivalent is thrown).
314: */
315: public ASNamedObjectMap getAttributeDeclarations() {
316: String msg = DOMMessageFormatter.formatMessage(
317: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
318: null);
319: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
320: }
321:
322: /**
323: * Instead of returning an all-in-one <code>ASObject</code> with
324: * <code>ASModel</code> methods, have discernible top-level/"global"
325: * notation declarations. If one attempts to add, set, or remove a node
326: * type other than the intended one, a hierarchy exception (or
327: * equivalent is thrown).
328: */
329: public ASNamedObjectMap getNotationDeclarations() {
330: String msg = DOMMessageFormatter.formatMessage(
331: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
332: null);
333: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
334: }
335:
336: /**
337: * Instead of returning an all-in-one <code>ASObject</code> with
338: * <code>ASModel</code> methods, have discernible top-level/"global"
339: * entity declarations. If one attempts to add, set, or remove a node
340: * type other than the intended one, a hierarchy exception (or
341: * equivalent is thrown).
342: */
343: public ASNamedObjectMap getEntityDeclarations() {
344: String msg = DOMMessageFormatter.formatMessage(
345: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
346: null);
347: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
348: }
349:
350: /**
351: * Instead of returning an all-in-one <code>ASObject</code> with
352: * <code>ASModel</code> methods, have discernible top-level/"global
353: * content model declarations. If one attempts to add, set, or remove a
354: * node type other than the intended one, a hierarchy exception (or
355: * equivalent is thrown).
356: */
357: public ASNamedObjectMap getContentModelDeclarations() {
358: String msg = DOMMessageFormatter.formatMessage(
359: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
360: null);
361: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
362: }
363:
364: /**
365: * This method will allow the nesting or "importation" of ASModels.
366: * @param abstractSchema ASModel to be set. Subsequent calls will nest
367: * the ASModels within the specified <code>ownerASModel</code>.
368: */
369: public void addASModel(ASModel abstractSchema) {
370: fASModels.addElement(abstractSchema);
371: }
372:
373: /**
374: * To retrieve a list of nested ASModels without reference to names.
375: * @return A list of ASModels.
376: */
377: public ASObjectList getASModels() {
378: String msg = DOMMessageFormatter.formatMessage(
379: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
380: null);
381: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
382: }
383:
384: /**
385: * Removes only the specified <code>ASModel</code> from the list of
386: * <code>ASModel</code>s.
387: * @param as AS to be removed.
388: */
389: public void removeAS(ASModel as) {
390: fASModels.removeElement(as);
391: }
392:
393: /**
394: * Determines if an <code>ASModel</code> itself is valid, i.e., confirming
395: * that it's well-formed and valid per its own formal grammar.
396: * @return <code>true</code> if the <code>ASModel</code> is valid,
397: * <code>false</code> otherwise.
398: */
399: public boolean validate() {
400: String msg = DOMMessageFormatter.formatMessage(
401: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
402: null);
403: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
404: }
405:
406: /**
407: * Imports <code>ASObject</code> into ASModel.
408: * @param asobject <code>ASObject</code> to be imported.
409: */
410: public void importASObject(ASObject asobject) {
411: String msg = DOMMessageFormatter.formatMessage(
412: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
413: null);
414: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
415: }
416:
417: /**
418: * Inserts <code>ASObject</code> into ASModel.
419: * @param asobject <code>ASObject</code> to be inserted.
420: */
421: public void insertASObject(ASObject asobject) {
422: String msg = DOMMessageFormatter.formatMessage(
423: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
424: null);
425: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
426: }
427:
428: /**
429: * Creates an element declaration for the element type specified.
430: * @param namespaceURI The <code>namespace URI</code> of the element type
431: * being declared.
432: * @param name The name of the element. The format of the name could be
433: * an NCName as defined by XML Namespaces or a Name as defined by XML
434: * 1.0; it's ASModel-dependent.
435: * @return A new <code>ASElementDeclaration</code> object with
436: * <code>name</code> attribute set to <code>tagname</code> and
437: * <code>namespaceURI</code> set to <code>systemId</code>. Other
438: * attributes of the element declaration are set through
439: * <code>ASElementDeclaration</code> interface methods.
440: * @exception DOMException
441: * INVALID_CHARACTER_ERR: Raised if the specified name contains an
442: * illegal character.
443: */
444: public ASElementDeclaration createASElementDeclaration(
445: String namespaceURI, String name) throws DOMException {
446: String msg = DOMMessageFormatter.formatMessage(
447: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
448: null);
449: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
450: }
451:
452: /**
453: * Creates an attribute declaration.
454: * @param namespaceURI The namespace URI of the attribute being declared.
455: * @param name The name of the attribute. The format of the name could be
456: * an NCName as defined by XML Namespaces or a Name as defined by XML
457: * 1.0; it's ASModel-dependent.
458: * @return A new <code>ASAttributeDeclaration</code> object with
459: * appropriate attributes set by input parameters.
460: * @exception DOMException
461: * INVALID_CHARACTER_ERR: Raised if the input <code>name</code>
462: * parameter contains an illegal character.
463: */
464: public ASAttributeDeclaration createASAttributeDeclaration(
465: String namespaceURI, String name) throws DOMException {
466: String msg = DOMMessageFormatter.formatMessage(
467: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
468: null);
469: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
470: }
471:
472: /**
473: * Creates a new notation declaration.
474: * @param namespaceURI The namespace URI of the notation being declared.
475: * @param name The name of the notation. The format of the name could be
476: * an NCName as defined by XML Namespaces or a Name as defined by XML
477: * 1.0; it's ASModel-dependent.
478: * @param systemId The system identifier for the notation declaration.
479: * @param publicId The public identifier for the notation declaration.
480: * @return A new <code>ASNotationDeclaration</code> object with
481: * <code>notationName</code> attribute set to <code>name</code> and
482: * <code>publicId</code> and <code>systemId</code> set to the
483: * corresponding fields.
484: * @exception DOMException
485: * INVALID_CHARACTER_ERR: Raised if the specified name contains an
486: * illegal character.
487: */
488: public ASNotationDeclaration createASNotationDeclaration(
489: String namespaceURI, String name, String systemId,
490: String publicId) throws DOMException {
491: String msg = DOMMessageFormatter.formatMessage(
492: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
493: null);
494: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
495: }
496:
497: /**
498: * Creates an ASEntityDeclaration.
499: * @param name The name of the entity being declared.
500: * @return A new <code>ASEntityDeclaration</code> object with
501: * <code>entityName</code> attribute set to name.
502: * @exception DOMException
503: * INVALID_CHARACTER_ERR: Raised if the specified name contains an
504: * illegal character.
505: */
506: public ASEntityDeclaration createASEntityDeclaration(String name)
507: throws DOMException {
508: String msg = DOMMessageFormatter.formatMessage(
509: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
510: null);
511: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
512: }
513:
514: /**
515: * Creates an object which describes part of an
516: * <code>ASElementDeclaration</code>'s content model.
517: * @param minOccurs The minimum occurrence for the subModels of this
518: * <code>ASContentModel</code>.
519: * @param maxOccurs The maximum occurrence for the subModels of this
520: * <code>ASContentModel</code>.
521: * @param operator operator of type <code>AS_CHOICE</code>,
522: * <code>AS_SEQUENCE</code>, <code>AS_ALL</code> or
523: * <code>AS_NONE</code>.
524: * @return A new <code>ASContentModel</code> object.
525: * @exception DOMASException
526: * A DOMASException, e.g., <code>minOccurs > maxOccurs</code>.
527: */
528: public ASContentModel createASContentModel(int minOccurs,
529: int maxOccurs, short operator) throws DOMASException {
530: String msg = DOMMessageFormatter.formatMessage(
531: DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR",
532: null);
533: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
534: }
535:
536: // convenience methods
537: public SchemaGrammar getGrammar() {
538: return fGrammar;
539: }
540:
541: public void setGrammar(SchemaGrammar grammar) {
542: fGrammar = grammar;
543: }
544:
545: public Vector getInternalASModels() {
546: return fASModels;
547: }
548:
549: }
|