1/* 2 * Copyright (c) 1997, 2013, 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 */ 25 26package com.sun.xml.internal.xsom.impl.parser; 27 28import com.sun.xml.internal.xsom.parser.XMLParser; 29import org.xml.sax.InputSource; 30import org.xml.sax.SAXException; 31import org.xml.sax.XMLReader; 32import org.xml.sax.helpers.XMLFilterImpl; 33import org.xml.sax.helpers.XMLReaderAdapter; 34 35import javax.xml.parsers.ParserConfigurationException; 36import javax.xml.parsers.SAXParser; 37import javax.xml.parsers.SAXParserFactory; 38import java.io.IOException; 39 40 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 */ 50public class SAXParserFactoryAdaptor extends SAXParserFactory { 51 52 private final XMLParser parser; 53 54 public SAXParserFactoryAdaptor( XMLParser _parser ) { 55 this.parser = _parser; 56 } 57 58 public SAXParser newSAXParser() throws ParserConfigurationException, SAXException { 59 return new SAXParserImpl(); 60 } 61 62 public void setFeature(String name, boolean value) { 63 throw new UnsupportedOperationException("XSOM parser does not support JAXP features."); 64 } 65 66 public boolean getFeature(String name) { 67 return false; 68 } 69 70 private class SAXParserImpl extends SAXParser 71 { 72 private final XMLReaderImpl reader = new XMLReaderImpl(); 73 74 /** 75 * @deprecated 76 */ 77 public org.xml.sax.Parser getParser() throws SAXException { 78 return new XMLReaderAdapter(reader); 79 } 80 81 public XMLReader getXMLReader() throws SAXException { 82 return reader; 83 } 84 85 public boolean isNamespaceAware() { 86 return true; 87 } 88 89 public boolean isValidating() { 90 return false; 91 } 92 93 public void setProperty(String name, Object value) { 94 } 95 96 public Object getProperty(String name) { 97 return null; 98 } 99 } 100 101 private class XMLReaderImpl extends XMLFilterImpl 102 { 103 public void parse(InputSource input) throws IOException, SAXException { 104 parser.parse(input,this,this,this); 105 } 106 107 public void parse(String systemId) throws IOException, SAXException { 108 parser.parse(new InputSource(systemId),this,this,this); 109 } 110 } 111} 112