1 /*
2  * reserved comment block
3  * DO NOT REMOVE OR ALTER!
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.opti;
23 import org.w3c.dom.DOMException;
24 import org.w3c.dom.DOMImplementation;
25 import org.w3c.dom.Document;
26 import org.w3c.dom.DocumentType;
27 
28 /**
29  * @xerces.internal
30  *
31  * @version $Id: SchemaDOMImplementation.java,v 1.2 2010-10-26 23:01:18 joehw Exp $
32  */
33 final class SchemaDOMImplementation implements DOMImplementation {
34 
35     private static final SchemaDOMImplementation singleton = new SchemaDOMImplementation();
36 
37     /** NON-DOM: Obtain and return the single shared object */
getDOMImplementation()38     public static DOMImplementation getDOMImplementation() {
39         return singleton;
40     }
41 
SchemaDOMImplementation()42     private SchemaDOMImplementation() {}
43 
createDocument(String namespaceURI, String qualifiedName, DocumentType doctype)44     public Document createDocument(String namespaceURI, String qualifiedName, DocumentType doctype)
45             throws DOMException {
46         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
47     }
48 
createDocumentType(String qualifiedName, String publicId, String systemId)49     public DocumentType createDocumentType(String qualifiedName, String publicId, String systemId)
50             throws DOMException {
51         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
52     }
53 
getFeature(String feature, String version)54     public Object getFeature(String feature, String version) {
55         if (singleton.hasFeature(feature, version)) {
56             return singleton;
57         }
58         return null;
59     }
60 
hasFeature(String feature, String version)61     public boolean hasFeature(String feature, String version) {
62         final boolean anyVersion = version == null || version.length() == 0;
63         return (feature.equalsIgnoreCase("Core") || feature.equalsIgnoreCase("XML")) &&
64             (anyVersion || version.equals("1.0") || version.equals("2.0") || version.equals("3.0"));
65     }
66 
67 }
68