KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > dtd > DTDGrammarBucket


1 /*
2  * Copyright 1999-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.impl.dtd;
18
19 import org.apache.xerces.xni.grammars.XMLGrammarDescription;
20 import java.util.Hashtable JavaDoc;
21
22 /**
23  * This very simple class is the skeleton of what the DTDValidator could use
24  * to store various grammars that it gets from the GrammarPool. As in the
25  * case of XSGrammarBucket, one thinks of this object as being closely
26  * associated with its validator; when fully mature, this class will be
27  * filled from the GrammarPool when the DTDValidator is invoked on a
28  * document, and, if a new DTD grammar is parsed, the new set will be
29  * offered back to the GrammarPool for possible inclusion.
30  *
31  * @xerces.internal
32  *
33  * @author Neil Graham, IBM
34  *
35  * @version $Id: DTDGrammarBucket.java,v 1.7 2004/10/04 21:57:30 mrglavas Exp $
36  */

37 public class DTDGrammarBucket {
38
39     // REVISIT: make this class smarter and *way* more complete!
40

41     //
42
// Data
43
//
44

45     /** Grammars associated with element root name. */
46     protected Hashtable JavaDoc fGrammars;
47
48     // the unique grammar from fGrammars (or that we're
49
// building) that is used in validation.
50
protected DTDGrammar fActiveGrammar;
51
52     // is the "active" grammar standalone?
53
protected boolean fIsStandalone;
54
55     //
56
// Constructors
57
//
58

59     /** Default constructor. */
60     public DTDGrammarBucket() {
61         fGrammars = new Hashtable JavaDoc();
62     } // <init>()
63

64     //
65
// Public methods
66
//
67

68     /**
69      * Puts the specified grammar into the grammar pool and associate it to
70      * a root element name (this being internal, the lack of generality is irrelevant).
71      *
72      * @param grammar The grammar.
73      */

74     public void putGrammar(DTDGrammar grammar) {
75         XMLDTDDescription desc = (XMLDTDDescription)grammar.getGrammarDescription();
76         fGrammars.put(desc, grammar);
77     } // putGrammar(DTDGrammar)
78

79     // retrieve a DTDGrammar given an XMLDTDDescription
80
public DTDGrammar getGrammar(XMLGrammarDescription desc) {
81         return (DTDGrammar)(fGrammars.get((XMLDTDDescription)desc));
82     } // putGrammar(DTDGrammar)
83

84     public void clear() {
85         fGrammars.clear();
86         fActiveGrammar = null;
87         fIsStandalone = false;
88     } // clear()
89

90     // is the active grammar standalone? This must live here because
91
// at the time the validator discovers this we don't yet know
92
// what the active grammar should be (no info about root)
93
void setStandalone(boolean standalone) {
94         fIsStandalone = standalone;
95     }
96
97     boolean getStandalone() {
98         return fIsStandalone;
99     }
100
101     // set the "active" grammar:
102
void setActiveGrammar (DTDGrammar grammar) {
103         fActiveGrammar = grammar;
104     }
105     DTDGrammar getActiveGrammar () {
106         return fActiveGrammar;
107     }
108 } // class DTDGrammarBucket
109
Popular Tags