01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.jaxp.validation;
19:
20: import org.apache.xerces.xni.grammars.Grammar;
21: import org.apache.xerces.xni.grammars.XMLGrammarDescription;
22: import org.apache.xerces.xni.grammars.XMLGrammarPool;
23:
24: /**
25: * <p>Implementation of Schema for W3C XML Schemas which
26: * contains schema components from one target namespace.</p>
27: *
28: * @author Michael Glavassevich, IBM
29: * @version $Id: SimpleXMLSchema.java 542516 2007-05-29 13:44:47Z mrglavas $
30: */
31: final class SimpleXMLSchema extends AbstractXMLSchema implements
32: XMLGrammarPool {
33:
34: /** Zero length grammar array. */
35: private static final Grammar[] ZERO_LENGTH_GRAMMAR_ARRAY = new Grammar[0];
36:
37: private final Grammar fGrammar;
38: private final Grammar[] fGrammars;
39: private final XMLGrammarDescription fGrammarDescription;
40:
41: public SimpleXMLSchema(Grammar grammar) {
42: fGrammar = grammar;
43: fGrammars = new Grammar[] { grammar };
44: fGrammarDescription = grammar.getGrammarDescription();
45: }
46:
47: /*
48: * XMLGrammarPool methods
49: */
50:
51: public Grammar[] retrieveInitialGrammarSet(String grammarType) {
52: return XMLGrammarDescription.XML_SCHEMA.equals(grammarType) ? (Grammar[]) fGrammars
53: .clone()
54: : ZERO_LENGTH_GRAMMAR_ARRAY;
55: }
56:
57: public void cacheGrammars(String grammarType, Grammar[] grammars) {
58: }
59:
60: public Grammar retrieveGrammar(XMLGrammarDescription desc) {
61: return fGrammarDescription.equals(desc) ? fGrammar : null;
62: }
63:
64: public void lockPool() {
65: }
66:
67: public void unlockPool() {
68: }
69:
70: public void clear() {
71: }
72:
73: /*
74: * XSGrammarPoolContainer methods
75: */
76:
77: public XMLGrammarPool getGrammarPool() {
78: return this ;
79: }
80:
81: public boolean isFullyComposed() {
82: return true;
83: }
84:
85: } // SimpleXMLSchema
|