KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > util > XSGrammarPool


1 /*
2  * Copyright 2003,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.xs.util;
18
19 import org.apache.xerces.impl.xs.SchemaGrammar;
20 import org.apache.xerces.impl.xs.XSModelImpl;
21 import org.apache.xerces.xs.XSModel;
22 import org.apache.xerces.util.XMLGrammarPoolImpl;
23 import org.apache.xerces.xni.grammars.XMLGrammarDescription;
24
25
26 /**
27  * Add a method that return an <code>XSModel</code> that represents components in
28  * the schema grammars in this pool implementation.
29  *
30  * @xerces.internal
31  *
32  * @version $Id: XSGrammarPool.java,v 1.4 2004/10/06 15:14:50 mrglavas Exp $
33  */

34 public class XSGrammarPool extends XMLGrammarPoolImpl {
35     /**
36      * Return an <code>XSModel</code> that represents components in
37      * the schema grammars in this pool implementation.
38      *
39      * @return an <code>XSModel</code> representing this schema grammar
40      */

41     public XSModel toXSModel() {
42         java.util.Vector JavaDoc list = new java.util.Vector JavaDoc();
43         for (int i = 0; i < fGrammars.length; i++) {
44             for (Entry entry = fGrammars[i] ; entry != null ; entry = entry.next) {
45                 if (entry.desc.getGrammarType().equals(XMLGrammarDescription.XML_SCHEMA))
46                     list.addElement(entry.grammar);
47             }
48         }
49
50         int size = list.size();
51         if (size == 0)
52             return null;
53         SchemaGrammar[] gs = new SchemaGrammar[size];
54         for (int i = 0; i < size; i++)
55             gs[i] = (SchemaGrammar)list.elementAt(i);
56         return new XSModelImpl(gs);
57     }
58
59
60 } // class XSGrammarPool
61
Popular Tags