Thu, 31 Aug 2017 15:18:52 +0800
merge
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.xml.internal.xsom.impl.parser;
28 import com.sun.xml.internal.xsom.parser.XMLParser;
29 import org.xml.sax.InputSource;
30 import org.xml.sax.SAXException;
31 import org.xml.sax.XMLReader;
32 import org.xml.sax.helpers.XMLFilterImpl;
33 import org.xml.sax.helpers.XMLReaderAdapter;
35 import javax.xml.parsers.ParserConfigurationException;
36 import javax.xml.parsers.SAXParser;
37 import javax.xml.parsers.SAXParserFactory;
38 import java.io.IOException;
41 /**
42 * {@link SAXParserFactory} implementation that ultimately
43 * uses {@link XMLParser} to parse documents.
44 *
45 * @deprecated
46 *
47 * @author
48 * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
49 */
50 public class SAXParserFactoryAdaptor extends SAXParserFactory {
52 private final XMLParser parser;
54 public SAXParserFactoryAdaptor( XMLParser _parser ) {
55 this.parser = _parser;
56 }
58 public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
59 return new SAXParserImpl();
60 }
62 public void setFeature(String name, boolean value) {
63 throw new UnsupportedOperationException("XSOM parser does not support JAXP features.");
64 }
66 public boolean getFeature(String name) {
67 return false;
68 }
70 private class SAXParserImpl extends SAXParser
71 {
72 private final XMLReaderImpl reader = new XMLReaderImpl();
74 /**
75 * @deprecated
76 */
77 public org.xml.sax.Parser getParser() throws SAXException {
78 return new XMLReaderAdapter(reader);
79 }
81 public XMLReader getXMLReader() throws SAXException {
82 return reader;
83 }
85 public boolean isNamespaceAware() {
86 return true;
87 }
89 public boolean isValidating() {
90 return false;
91 }
93 public void setProperty(String name, Object value) {
94 }
96 public Object getProperty(String name) {
97 return null;
98 }
99 }
101 private class XMLReaderImpl extends XMLFilterImpl
102 {
103 public void parse(InputSource input) throws IOException, SAXException {
104 parser.parse(input,this,this,this);
105 }
107 public void parse(String systemId) throws IOException, SAXException {
108 parser.parse(new InputSource(systemId),this,this,this);
109 }
110 }
111 }