~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/xerces-2_9_1/src/org/apache/xerces/impl/xs/XSImplementationImpl.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 * 
 
9
 *      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.impl.xs;
 
19
 
 
20
import org.apache.xerces.dom.CoreDOMImplementationImpl;
 
21
import org.apache.xerces.dom.DOMMessageFormatter;
 
22
import org.apache.xerces.impl.xs.util.StringListImpl;
 
23
import org.apache.xerces.xs.StringList;
 
24
import org.apache.xerces.xs.XSException;
 
25
import org.apache.xerces.xs.XSImplementation;
 
26
import org.apache.xerces.xs.XSLoader;
 
27
import org.w3c.dom.DOMImplementation;
 
28
 
 
29
 
 
30
/**
 
31
 * Implements XSImplementation interface that allows one to retrieve an instance of <code>XSLoader</code>. 
 
32
 * This interface should be implemented on the same object that implements 
 
33
 * DOMImplementation.
 
34
 *
 
35
 * @xerces.internal 
 
36
 *
 
37
 * @author Elena Litani, IBM
 
38
 * @version $Id: XSImplementationImpl.java,v 1.2 2009/12/10 03:18:27 matthewoliver Exp $
 
39
 */
 
40
public class XSImplementationImpl extends CoreDOMImplementationImpl 
 
41
                                                                  implements XSImplementation {
 
42
 
 
43
    //
 
44
    // Data
 
45
    //
 
46
 
 
47
    // static
 
48
 
 
49
    /** Dom implementation singleton. */
 
50
    static XSImplementationImpl singleton = new XSImplementationImpl();
 
51
 
 
52
    //
 
53
    // Public methods
 
54
    //
 
55
 
 
56
    /** NON-DOM: Obtain and return the single shared object */
 
57
    public static DOMImplementation getDOMImplementation() {
 
58
        return singleton;
 
59
    }  
 
60
 
 
61
    //
 
62
    // DOMImplementation methods
 
63
    //
 
64
 
 
65
    /** 
 
66
     * Test if the DOM implementation supports a specific "feature" --
 
67
     * currently meaning language and level thereof.
 
68
     * 
 
69
     * @param feature      The package name of the feature to test.
 
70
     * In Level 1, supported values are "HTML" and "XML" (case-insensitive).
 
71
     * At this writing, org.apache.xerces.dom supports only XML.
 
72
     *
 
73
     * @param version      The version number of the feature being tested.
 
74
     * This is interpreted as "Version of the DOM API supported for the
 
75
     * specified Feature", and in Level 1 should be "1.0"
 
76
     *
 
77
     * @return    true iff this implementation is compatable with the specified
 
78
     * feature and version.
 
79
     */
 
80
    public boolean hasFeature(String feature, String version) {
 
81
        
 
82
        return (feature.equalsIgnoreCase("XS-Loader") && (version == null || version.equals("1.0")) ||
 
83
                super.hasFeature(feature, version));
 
84
    } // hasFeature(String,String):boolean
 
85
    
 
86
 
 
87
 
 
88
    /* (non-Javadoc)
 
89
     * @see org.apache.xerces.xs.XSImplementation#createXSLoader(org.apache.xerces.xs.StringList)
 
90
     */
 
91
    public XSLoader createXSLoader(StringList versions) throws XSException {
 
92
        XSLoader loader = new XSLoaderImpl();
 
93
        if (versions == null){
 
94
                        return loader;
 
95
        }
 
96
        for (int i=0; i<versions.getLength();i++){
 
97
                if (!versions.item(i).equals("1.0")){
 
98
                                String msg =
 
99
                                        DOMMessageFormatter.formatMessage(
 
100
                                                DOMMessageFormatter.DOM_DOMAIN,
 
101
                                                "FEATURE_NOT_SUPPORTED",
 
102
                                                new Object[] { versions.item(i) });
 
103
                                throw new XSException(XSException.NOT_SUPPORTED_ERR, msg);
 
104
                }
 
105
        }
 
106
        return loader;
 
107
    }
 
108
 
 
109
    /* (non-Javadoc)
 
110
     * @see org.apache.xerces.xs.XSImplementation#getRecognizedVersions()
 
111
     */
 
112
    public StringList getRecognizedVersions() {
 
113
        StringListImpl list = new StringListImpl(new String[]{"1.0"}, 1);
 
114
        return list;
 
115
    }
 
116
 
 
117
} // class XSImplementationImpl