KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > DOMXSImplementationSourceImpl


1 /*
2  * Copyright 2001, 2002,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.dom;
18
19 import org.apache.xerces.impl.xs.XSImplementationImpl;
20 import org.w3c.dom.DOMImplementationList JavaDoc;
21 import org.w3c.dom.DOMImplementation JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 /**
25  * Allows to retrieve <code>XSImplementation</code>, DOM Level 3 Core and LS implementations
26  * and PSVI implementation.
27  * <p>See also the <a HREF='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMImplementationSource'>Document Object Model (DOM) Level 3 Core Specification</a>.
28  *
29  * @xerces.internal
30  *
31  * @author Elena Litani, IBM
32  * @version $Id: DOMXSImplementationSourceImpl.java,v 1.5 2005/05/02 22:02:22 mrglavas Exp $
33  */

34 public class DOMXSImplementationSourceImpl
35     extends DOMImplementationSourceImpl {
36     
37     /**
38      * A method to request a DOM implementation.
39      * @param features A string that specifies which features are required.
40      * This is a space separated list in which each feature is specified
41      * by its name optionally followed by a space and a version number.
42      * This is something like: "XML 1.0 Traversal Events 2.0"
43      * @return An implementation that has the desired features, or
44      * <code>null</code> if this source has none.
45      */

46     public DOMImplementation JavaDoc getDOMImplementation(String JavaDoc features) {
47         DOMImplementation JavaDoc impl = super.getDOMImplementation(features);
48         if (impl != null){
49             return impl;
50         }
51         // if not try the PSVIDOMImplementation
52
impl = PSVIDOMImplementationImpl.getDOMImplementation();
53         if (testImpl(impl, features)) {
54             return impl;
55         }
56         // if not try the XSImplementation
57
impl = XSImplementationImpl.getDOMImplementation();
58         if (testImpl(impl, features)) {
59             return impl;
60         }
61         
62         return null;
63     }
64     
65     /**
66      * A method to request a list of DOM implementations that support the
67      * specified features and versions, as specified in .
68      * @param features A string that specifies which features and versions
69      * are required. This is a space separated list in which each feature
70      * is specified by its name optionally followed by a space and a
71      * version number. This is something like: "XML 3.0 Traversal +Events
72      * 2.0"
73      * @return A list of DOM implementations that support the desired
74      * features.
75      */

76     public DOMImplementationList JavaDoc getDOMImplementationList(String JavaDoc features) {
77         final Vector JavaDoc implementations = new Vector JavaDoc();
78         
79         // first check whether the CoreDOMImplementation would do
80
DOMImplementationList JavaDoc list = super.getDOMImplementationList(features);
81         //Add core DOMImplementations
82
for (int i=0; i < list.getLength(); i++ ) {
83             implementations.addElement(list.item(i));
84         }
85         
86         DOMImplementation JavaDoc impl = PSVIDOMImplementationImpl.getDOMImplementation();
87         if (testImpl(impl, features)) {
88             implementations.addElement(impl);
89         }
90         
91         impl = XSImplementationImpl.getDOMImplementation();
92         if (testImpl(impl, features)) {
93             implementations.addElement(impl);
94         }
95         return new DOMImplementationListImpl(implementations);
96     }
97 }
98
Popular Tags