~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/xerces-2_9_1/src/org/apache/xerces/impl/dtd/DTDGrammarBucket.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
8
 * 
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 * 
 
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.
 
16
 */
 
17
 
 
18
package org.apache.xerces.impl.dtd;
 
19
 
 
20
import org.apache.xerces.xni.grammars.XMLGrammarDescription;
 
21
import java.util.Hashtable;
 
22
 
 
23
/**
 
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.
 
31
 * 
 
32
 * @xerces.internal
 
33
 *
 
34
 * @author Neil Graham, IBM
 
35
 *
 
36
 * @version $Id: DTDGrammarBucket.java,v 1.2 2009/12/10 03:18:34 matthewoliver Exp $
 
37
 */
 
38
public class DTDGrammarBucket {
 
39
 
 
40
    // REVISIT:  make this class smarter and *way* more complete!
 
41
 
 
42
    //
 
43
    // Data
 
44
    //
 
45
 
 
46
    /** Grammars associated with element root name. */
 
47
    protected final Hashtable fGrammars;
 
48
 
 
49
    // the unique grammar from fGrammars (or that we're
 
50
    // building) that is used in validation.
 
51
    protected DTDGrammar fActiveGrammar;
 
52
 
 
53
    // is the "active" grammar standalone?
 
54
    protected boolean fIsStandalone;
 
55
 
 
56
    //
 
57
    // Constructors
 
58
    //
 
59
 
 
60
    /** Default constructor. */
 
61
    public DTDGrammarBucket() {
 
62
        fGrammars = new Hashtable();
 
63
    } // <init>()
 
64
 
 
65
    //
 
66
    // Public methods
 
67
    //
 
68
 
 
69
    /**
 
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).
 
72
     * 
 
73
     * @param grammar     The grammar.
 
74
     */
 
75
    public void putGrammar(DTDGrammar grammar) {
 
76
        XMLDTDDescription desc = (XMLDTDDescription)grammar.getGrammarDescription();
 
77
        fGrammars.put(desc, grammar);
 
78
    } // putGrammar(DTDGrammar)
 
79
 
 
80
    // retrieve a DTDGrammar given an XMLDTDDescription
 
81
    public DTDGrammar getGrammar(XMLGrammarDescription desc) {
 
82
        return (DTDGrammar)(fGrammars.get((XMLDTDDescription)desc));
 
83
    } // putGrammar(DTDGrammar)
 
84
 
 
85
    public void clear() {
 
86
        fGrammars.clear();
 
87
        fActiveGrammar = null;
 
88
        fIsStandalone = false;
 
89
    } // clear()
 
90
 
 
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;
 
96
    }
 
97
 
 
98
    boolean getStandalone() {
 
99
        return fIsStandalone;
 
100
    }
 
101
 
 
102
    // set the "active" grammar:
 
103
    void setActiveGrammar (DTDGrammar grammar) {
 
104
        fActiveGrammar = grammar;
 
105
    }
 
106
    DTDGrammar getActiveGrammar () {
 
107
        return fActiveGrammar;
 
108
    }
 
109
} // class DTDGrammarBucket