1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Nov 2017
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.xerces.internal.impl.xs.util;
23
24 import com.sun.org.apache.xerces.internal.impl.Constants;
25 import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
26 import com.sun.org.apache.xerces.internal.impl.xs.XSModelImpl;
27 import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl;
28 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
29 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
30 import com.sun.org.apache.xerces.internal.xs.XSModel;
31 import java.util.ArrayList;
32 import java.util.List;
33
34
35 /**
36 * Add a method that return an <code>XSModel</code> that represents components in
37 * the schema grammars in this pool implementation.
38 *
39 * @xerces.internal
40 *
41 */
42 public class XSGrammarPool extends XMLGrammarPoolImpl {
43
44 /**
45 * Return an <code>XSModel</code> that represents components in
46 * the schema grammars in this pool implementation.
47 *
48 * @return an <code>XSModel</code> representing this schema grammar
49 */
50 public XSModel toXSModel() {
51 return toXSModel(Constants.SCHEMA_VERSION_1_0);
52 }
53
54 public XSModel toXSModel(short schemaVersion) {
55 List<Grammar> list = new ArrayList<>();
56 for (int i = 0; i < fGrammars.length; i++) {
57 for (Entry entry = fGrammars[i] ; entry != null ; entry = entry.next) {
58 if (entry.desc.getGrammarType().equals(XMLGrammarDescription.XML_SCHEMA)) {
59 list.add(entry.grammar);
60 }
|
1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 package com.sun.org.apache.xerces.internal.impl.xs.util;
22
23 import com.sun.org.apache.xerces.internal.impl.Constants;
24 import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
25 import com.sun.org.apache.xerces.internal.impl.xs.XSModelImpl;
26 import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl;
27 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
28 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
29 import com.sun.org.apache.xerces.internal.xs.XSModel;
30 import java.util.ArrayList;
31 import java.util.List;
32
33
34 /**
35 * Add a method that return an <code>XSModel</code> that represents components in
36 * the schema grammars in this pool implementation.
37 *
38 * @xerces.internal
39 *
40 * @LastModified: Nov 2017
41 */
42 public class XSGrammarPool extends XMLGrammarPoolImpl {
43
44 /**
45 * Return an <code>XSModel</code> that represents components in
46 * the schema grammars in this pool implementation.
47 *
48 * @return an <code>XSModel</code> representing this schema grammar
49 */
50 public XSModel toXSModel() {
51 return toXSModel(Constants.SCHEMA_VERSION_1_0);
52 }
53
54 public XSModel toXSModel(short schemaVersion) {
55 List<Grammar> list = new ArrayList<>();
56 for (int i = 0; i < fGrammars.length; i++) {
57 for (Entry entry = fGrammars[i] ; entry != null ; entry = entry.next) {
58 if (entry.desc.getGrammarType().equals(XMLGrammarDescription.XML_SCHEMA)) {
59 list.add(entry.grammar);
60 }
|