1 /* 2 * Copyright (c) 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 */ 25 26 package jdk.internal.util.xml.impl; 27 28 import java.io.IOException; 29 import java.io.InputStream; 30 import jdk.internal.org.xml.sax.InputSource; 31 import jdk.internal.org.xml.sax.SAXException; 32 import jdk.internal.org.xml.sax.XMLReader; 33 import jdk.internal.org.xml.sax.helpers.DefaultHandler; 34 35 public class SAXParserImp 36 extends SAXParser 37 { 38 private ParserSAX parser; 39 40 public SAXParserImp() 41 { 42 super(); 43 parser = new ParserSAX(); 44 } 45 46 /** 47 * Returns the {@link org.xml.sax.XMLReader} that is encapsulated by the 48 * implementation of this class. 49 * 50 * @return The XMLReader that is encapsulated by the 51 * implementation of this class. 52 * 53 * @throws SAXException If any SAX errors occur during processing. 54 */ 55 56 public XMLReader getXMLReader() 57 throws SAXException 58 { 59 return parser; 60 } 61 62 /** 63 * Indicates whether or not this parser is configured to 64 * understand namespaces. 65 * 66 * @return true if this parser is configured to 67 * understand namespaces; false otherwise. 68 */ 69 public boolean isNamespaceAware() 70 { 71 return parser.mIsNSAware; 72 } 73 74 /** 75 * Indicates whether or not this parser is configured to validate 76 * XML documents. 77 * 78 * @return true if this parser is configured to validate XML 79 * documents; false otherwise. 80 */ 81 public boolean isValidating() 82 { 83 return false; 84 } 85 86 /** 87 * Parse the content of the given {@link java.io.InputStream} 88 * instance as XML using the specified 89 * {@link org.xml.sax.helpers.DefaultHandler}. 90 * 91 * @param src InputStream containing the content to be parsed. 92 * @param handler The SAX DefaultHandler to use. 93 * @exception IOException If any IO errors occur. 94 * @exception IllegalArgumentException If the given InputStream or handler is null. 95 * @exception SAXException If the underlying parser throws a 96 * SAXException while parsing. 97 * @see org.xml.sax.helpers.DefaultHandler 98 */ 99 public void parse(InputStream src, DefaultHandler handler) 100 throws SAXException, IOException 101 { 102 parser.parse(src, handler); 103 } 104 105 /** 106 * Parse the content given {@link org.xml.sax.InputSource} 107 * as XML using the specified 108 * {@link org.xml.sax.helpers.DefaultHandler}. 109 * 110 * @param is The InputSource containing the content to be parsed. 111 * @param handler The SAX DefaultHandler to use. 112 * @exception IOException If any IO errors occur. 113 * @exception IllegalArgumentException If the InputSource or handler is null. 114 * @exception SAXException If the underlying parser throws a 115 * SAXException while parsing. 116 * @see org.xml.sax.helpers.DefaultHandler 117 */ 118 public void parse(InputSource is, DefaultHandler handler) 119 throws SAXException, IOException 120 { 121 parser.parse(is, handler); 122 } 123 124 }