gnu.xml.stream

Class SAXParser

Implemented Interfaces:
Attributes2, Locator2, XMLReader, XMLReporter, XMLResolver

public class SAXParser
extends SAXParser
implements XMLReader, Attributes2, Locator2, XMLReporter, XMLResolver

JAXP SAX parser using an underlying StAX parser. This parser supports the following additional SAX features and properties:
Features
http://gnu.org/sax/features/xml-baseread/writeIndicates or sets whether XML Base processing is enabled
Properties
http://gnu.org/sax/properties/base-uriread-onlyStringReturns the base URI of the current event
http://gnu.org/sax/properties/document-xml-encodingread-onlyStringReturns the encoding specified in the XML declaration

Constructor Summary

SAXParser()

Method Summary

int
getColumnNumber()
ContentHandler
getContentHandler()
DTDHandler
getDTDHandler()
String
getEncoding()
EntityResolver
getEntityResolver()
ErrorHandler
getErrorHandler()
boolean
getFeature(String name)
int
getIndex(String qName)
int
getIndex(String uri, String localName)
int
getLength()
int
getLineNumber()
String
getLocalName(int index)
Parser
getParser()
Returns the underlying SAX1 parser.
Object
getProperty(String name)
Returns the value of the specified SAX2 parser property.
String
getPublicId()
String
getQName(int index)
String
getSystemId()
String
getType(int index)
String
getType(String qName)
String
getType(String uri, String localName)
String
getURI(int index)
String
getValue(int index)
String
getValue(String qName)
String
getValue(String uri, String localName)
XMLReader
getXMLReader()
Returns the underlying SAX2 parser.
String
getXMLVersion()
boolean
isDeclared(int index)
boolean
isDeclared(String qName)
boolean
isDeclared(String uri, String localName)
boolean
isNamespaceAware()
Indicates whether this parser is XML Namespace aware.
boolean
isSpecified(int index)
boolean
isSpecified(String qName)
boolean
isSpecified(String uri, String localName)
boolean
isValidating()
Indicates whether this parser will validate its input.
boolean
isXIncludeAware()
Indicates whether this parser is XInclude-aware.
static void
main(String[] args)
void
parse(InputSource input)
void
parse(String systemId)
void
report(String message, String errorType, Object relatedInformation, Location location)
void
reset()
Resets this parser to its original configuration.
XMLEventReader
resolveAsXMLEventReader(String uri)
XMLStreamReader
resolveAsXMLStreamReader(String uri)
Object
resolveEntity(String publicId, String systemId, String baseURI, String namespace)
Returns an input source from which the specified external entity can be read.
void
setContentHandler(ContentHandler handler)
void
setDTDHandler(DTDHandler handler)
void
setEntityResolver(EntityResolver resolver)
void
setErrorHandler(ErrorHandler handler)
void
setFeature(String name, boolean value)
void
setProperty(String name, Object value)
Sets the specified SAX2 parser property.

Methods inherited from class javax.xml.parsers.SAXParser

getParser, getProperty, getSchema, getXMLReader, isNamespaceAware, isValidating, isXIncludeAware, parse, parse, parse, parse, parse, parse, parse, parse, parse, parse, reset, setProperty

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

SAXParser

public SAXParser()

Method Details

getColumnNumber

public int getColumnNumber()

getContentHandler

public ContentHandler getContentHandler()

getDTDHandler

public DTDHandler getDTDHandler()

getEncoding

public String getEncoding()

getEntityResolver

public EntityResolver getEntityResolver()

getErrorHandler

public ErrorHandler getErrorHandler()

getFeature

public boolean getFeature(String name)
            throws SAXNotRecognizedException,
                   SAXNotSupportedException

getIndex

public int getIndex(String qName)

getIndex

public int getIndex(String uri,
                    String localName)

getLength

public int getLength()

getLineNumber

public int getLineNumber()

getLocalName

public String getLocalName(int index)

getParser

public Parser getParser()
            throws SAXException
Returns the underlying SAX1 parser.
Overrides:
getParser in interface SAXParser

getProperty

public Object getProperty(String name)
            throws SAXNotRecognizedException,
                   SAXNotSupportedException
Returns the value of the specified SAX2 parser property.
Overrides:
getProperty in interface SAXParser
Parameters:
name - the name of the property

getPublicId

public String getPublicId()

getQName

public String getQName(int index)

getSystemId

public String getSystemId()

getType

public String getType(int index)

getType

public String getType(String qName)

getType

public String getType(String uri,
                      String localName)

getURI

public String getURI(int index)

getValue

public String getValue(int index)

getValue

public String getValue(String qName)

getValue

public String getValue(String uri,
                       String localName)

getXMLReader

public XMLReader getXMLReader()
            throws SAXException
Returns the underlying SAX2 parser.
Overrides:
getXMLReader in interface SAXParser
Since:
1.1

getXMLVersion

public String getXMLVersion()

isDeclared

public boolean isDeclared(int index)

isDeclared

public boolean isDeclared(String qName)

isDeclared

public boolean isDeclared(String uri,
                          String localName)

isNamespaceAware

public boolean isNamespaceAware()
Indicates whether this parser is XML Namespace aware.
Overrides:
isNamespaceAware in interface SAXParser

isSpecified

public boolean isSpecified(int index)

isSpecified

public boolean isSpecified(String qName)

isSpecified

public boolean isSpecified(String uri,
                           String localName)

isValidating

public boolean isValidating()
Indicates whether this parser will validate its input.
Overrides:
isValidating in interface SAXParser

isXIncludeAware

public boolean isXIncludeAware()
Indicates whether this parser is XInclude-aware.
Overrides:
isXIncludeAware in interface SAXParser
Since:
1.3

main

public static void main(String[] args)
            throws Exception

parse

public void parse(InputSource input)
            throws IOException,
                   SAXException

parse

public void parse(String systemId)
            throws IOException,
                   SAXException

report

public void report(String message,
                   String errorType,
                   Object relatedInformation,
                   Location location)
            throws XMLStreamException
Specified by:
report in interface XMLReporter

reset

public void reset()
Resets this parser to its original configuration.
Overrides:
reset in interface SAXParser
Since:
1.3

resolveAsXMLEventReader

public XMLEventReader resolveAsXMLEventReader(String uri)
            throws XMLStreamException

resolveAsXMLStreamReader

public XMLStreamReader resolveAsXMLStreamReader(String uri)
            throws XMLStreamException

resolveEntity

public Object resolveEntity(String publicId,
                            String systemId,
                            String baseURI,
                            String namespace)
            throws XMLStreamException
Returns an input source from which the specified external entity can be read. The following return types are possible:
  1. java.io.InputStream
  2. javax.xml.stream.XMLStreamReader
  3. java.xml.stream.XMLEventReader
If null is returned, the processor will attempt to resolve the entity itself.
Specified by:
resolveEntity in interface XMLResolver
Parameters:
baseURI - the absolute base URI of the referring entity
namespace - the namespace of the external entity

setContentHandler

public void setContentHandler(ContentHandler handler)

setDTDHandler

public void setDTDHandler(DTDHandler handler)

setEntityResolver

public void setEntityResolver(EntityResolver resolver)

setErrorHandler

public void setErrorHandler(ErrorHandler handler)

setFeature

public void setFeature(String name,
                       boolean value)
            throws SAXNotRecognizedException,
                   SAXNotSupportedException

setProperty

public void setProperty(String name,
                        Object value)
            throws SAXNotRecognizedException,
                   SAXNotSupportedException
Sets the specified SAX2 parser property.
Overrides:
setProperty in interface SAXParser
Parameters:
name - the name of the property
value - the value of the property

SAXParser.java -- Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.