KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > jaxp > validation > SimpleXMLSchema


1 /*
2  * Copyright 2005 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 com.sun.org.apache.xerces.internal.jaxp.validation;
18
19 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
20 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
21 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
22
23 /**
24  * <p>Implementation of Schema for W3C XML Schemas which
25  * contains schema components from one target namespace.</p>
26  *
27  * @author Michael Glavassevich, IBM
28  * @version $Id: SimpleXMLSchema.java,v 1.1.4.1 2005/09/05 11:41:40 sunithareddy Exp $
29  */

30 final class SimpleXMLSchema extends AbstractXMLSchema implements XMLGrammarPool {
31     
32     /** Zero length grammar array. */
33     private static final Grammar [] ZERO_LENGTH_GRAMMAR_ARRAY = new Grammar [0];
34
35     private Grammar fGrammar;
36     private Grammar[] fGrammars;
37     private XMLGrammarDescription fGrammarDescription;
38     
39     public SimpleXMLSchema(Grammar grammar) {
40         fGrammar = grammar;
41         fGrammars = new Grammar[] {grammar};
42         fGrammarDescription = grammar.getGrammarDescription();
43     }
44     
45     /*
46      * XMLGrammarPool methods
47      */

48
49     public Grammar[] retrieveInitialGrammarSet(String JavaDoc grammarType) {
50         return XMLGrammarDescription.XML_SCHEMA.equals(grammarType) ?
51                 (Grammar[]) fGrammars.clone() : ZERO_LENGTH_GRAMMAR_ARRAY;
52     }
53
54     public void cacheGrammars(String JavaDoc grammarType, Grammar[] grammars) {}
55
56     public Grammar retrieveGrammar(XMLGrammarDescription desc) {
57         return fGrammarDescription.equals(desc) ? fGrammar : null;
58     }
59
60     public void lockPool() {}
61
62     public void unlockPool() {}
63
64     public void clear() {}
65     
66     /*
67      * XSGrammarPoolContainer methods
68      */

69
70     public XMLGrammarPool getGrammarPool() {
71         return this;
72     }
73
74     public boolean isFullyComposed() {
75         return true;
76     }
77
78 } // SimpleXMLSchema
79
Popular Tags