2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.xerces.impl.dtd;
20
import org.apache.xerces.xni.grammars.XMLGrammarDescription;
21
import java.util.Hashtable;
24
* This very simple class is the skeleton of what the DTDValidator could use
25
* to store various grammars that it gets from the GrammarPool. As in the
26
* case of XSGrammarBucket, one thinks of this object as being closely
27
* associated with its validator; when fully mature, this class will be
28
* filled from the GrammarPool when the DTDValidator is invoked on a
29
* document, and, if a new DTD grammar is parsed, the new set will be
30
* offered back to the GrammarPool for possible inclusion.
34
* @author Neil Graham, IBM
36
* @version $Id: DTDGrammarBucket.java,v 1.2 2009/12/10 03:18:34 matthewoliver Exp $
38
public class DTDGrammarBucket {
40
// REVISIT: make this class smarter and *way* more complete!
46
/** Grammars associated with element root name. */
47
protected final Hashtable fGrammars;
49
// the unique grammar from fGrammars (or that we're
50
// building) that is used in validation.
51
protected DTDGrammar fActiveGrammar;
53
// is the "active" grammar standalone?
54
protected boolean fIsStandalone;
60
/** Default constructor. */
61
public DTDGrammarBucket() {
62
fGrammars = new Hashtable();
70
* Puts the specified grammar into the grammar pool and associate it to
71
* a root element name (this being internal, the lack of generality is irrelevant).
73
* @param grammar The grammar.
75
public void putGrammar(DTDGrammar grammar) {
76
XMLDTDDescription desc = (XMLDTDDescription)grammar.getGrammarDescription();
77
fGrammars.put(desc, grammar);
78
} // putGrammar(DTDGrammar)
80
// retrieve a DTDGrammar given an XMLDTDDescription
81
public DTDGrammar getGrammar(XMLGrammarDescription desc) {
82
return (DTDGrammar)(fGrammars.get((XMLDTDDescription)desc));
83
} // putGrammar(DTDGrammar)
87
fActiveGrammar = null;
88
fIsStandalone = false;
91
// is the active grammar standalone? This must live here because
92
// at the time the validator discovers this we don't yet know
93
// what the active grammar should be (no info about root)
94
void setStandalone(boolean standalone) {
95
fIsStandalone = standalone;
98
boolean getStandalone() {
102
// set the "active" grammar:
103
void setActiveGrammar (DTDGrammar grammar) {
104
fActiveGrammar = grammar;
106
DTDGrammar getActiveGrammar () {
107
return fActiveGrammar;
109
} // class DTDGrammarBucket