Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.xml.parsers.SAXParser
gnu.xml.stream.SAXParser
public class SAXParser
extends SAXParser
implements XMLReader, Attributes2, Locator2, XMLReporter, XMLResolver
Features | |||
---|---|---|---|
http://gnu.org/sax/features/xml-base | read/write | Indicates or sets whether XML Base processing is enabled | |
Properties | |||
http://gnu.org/sax/properties/base-uri | read-only | String | Returns the base URI of the current event |
http://gnu.org/sax/properties/document-xml-encoding | read-only | String | Returns the encoding specified in the XML declaration |
Constructor Summary | |
|
Method Summary | |
int |
|
ContentHandler | |
DTDHandler | |
String | |
EntityResolver | |
ErrorHandler | |
boolean |
|
int | |
int | |
int | |
int |
|
String |
|
Parser |
|
Object |
|
String |
|
String |
|
String |
|
String |
|
String | |
String | |
String |
|
String |
|
String | |
String | |
XMLReader |
|
String | |
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
static void | |
void | |
void |
|
void | |
void |
|
XMLEventReader | |
XMLStreamReader | |
Object |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
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 , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public int getColumnNumber()
Return the column number where the current document event ends. This is one-based number of Javachar
values since the last line end.Warning: The return value from the method is intended only as an approximation for the sake of diagnostics; it is not intended to provide sufficient information to edit the character content of the original XML document. For example, when lines contain combining character sequences, wide characters, surrogate pairs, or bi-directional text, the value may not correspond to the column in a text editor's display.
The return value is an approximation of the column number in the document entity or external parsed entity where the markup triggering the event appears.
If possible, the SAX driver should provide the line position of the first character after the text associated with the document event. The first column in each line is column 1.
- Specified by:
- getColumnNumber in interface Locator
- Returns:
- The column number, or -1 if none is available.
- See Also:
Locator.getLineNumber()
public ContentHandler getContentHandler()
- Specified by:
- getContentHandler in interface XMLReader
public EntityResolver getEntityResolver()
- Specified by:
- getEntityResolver in interface XMLReader
public ErrorHandler getErrorHandler()
- Specified by:
- getErrorHandler in interface XMLReader
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
- getFeature in interface XMLReader
public int getIndex(String uri, String localName)
- Specified by:
- getIndex in interface Attributes
public int getLineNumber()
Return the line number where the current document event ends. Lines are delimited by line ends, which are defined in the XML specification.Warning: The return value from the method is intended only as an approximation for the sake of diagnostics; it is not intended to provide sufficient information to edit the character content of the original XML document. In some cases, these "line" numbers match what would be displayed as columns, and in others they may not match the source text due to internal entity expansion.
The return value is an approximation of the line number in the document entity or external parsed entity where the markup triggering the event appears.
If possible, the SAX driver should provide the line position of the first character after the text associated with the document event. The first line is line 1.
- Specified by:
- getLineNumber in interface Locator
- Returns:
- The line number, or -1 if none is available.
- See Also:
Locator.getColumnNumber()
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
Returns the value of the specified SAX2 parser property.
- Specified by:
- getProperty in interface XMLReader
- Overrides:
- getProperty in interface SAXParser
- Parameters:
name
- the name of the property
public String getPublicId()
Return the public identifier for the current document event.The return value is the public identifier of the document entity or of the external parsed entity in which the markup triggering the event appears.
- Specified by:
- getPublicId in interface Locator
- Returns:
- A string containing the public identifier, or null if none is available.
- See Also:
Locator.getSystemId()
public String getSystemId()
Return the system identifier for the current document event.The return value is the system identifier of the document entity or of the external parsed entity in which the markup triggering the event appears.
If the system identifier is a URL, the parser must resolve it fully before passing it to the application. For example, a file name must always be provided as a file:... URL, and other kinds of relative URI are also resolved against their bases.
- Specified by:
- getSystemId in interface Locator
- Returns:
- A string containing the system identifier, or null if none is available.
- See Also:
Locator.getPublicId()
public String getType(String uri, String localName)
- Specified by:
- getType in interface Attributes
public String getValue(String uri, String localName)
- Specified by:
- getValue in interface Attributes
public XMLReader getXMLReader() throws SAXException
Returns the underlying SAX2 parser.
- Overrides:
- getXMLReader in interface SAXParser
- Since:
- 1.1
public boolean isDeclared(int index)
Returns false unless the attribute was declared in the DTD. This helps distinguish two kinds of attributes that SAX reports as CDATA: ones that were declared (and hence are usually valid), and those that were not (and which are never valid).
- Specified by:
- isDeclared in interface Attributes2
- Parameters:
index
- The attribute index (zero-based).
- Returns:
- true if the attribute was declared in the DTD, false otherwise.
- Throws:
ArrayIndexOutOfBoundsException
- When the supplied index does not identify an attribute.
public boolean isDeclared(String qName)
Returns false unless the attribute was declared in the DTD. This helps distinguish two kinds of attributes that SAX reports as CDATA: ones that were declared (and hence are usually valid), and those that were not (and which are never valid).
- Specified by:
- isDeclared in interface Attributes2
- Parameters:
qName
- The XML qualified (prefixed) name.
- Returns:
- true if the attribute was declared in the DTD, false otherwise.
- Throws:
IllegalArgumentException
- When the supplied name does not identify an attribute.
public boolean isDeclared(String uri, String localName)
Returns false unless the attribute was declared in the DTD. This helps distinguish two kinds of attributes that SAX reports as CDATA: ones that were declared (and hence are usually valid), and those that were not (and which are never valid).Remember that since DTDs do not "understand" namespaces, the namespace URI associated with an attribute may not have come from the DTD. The declaration will have applied to the attribute's qName.
- Specified by:
- isDeclared in interface Attributes2
- Parameters:
uri
- The Namespace URI, or the empty string if the name has no Namespace URI.localName
- The attribute's local name.
- Returns:
- true if the attribute was declared in the DTD, false otherwise.
- Throws:
IllegalArgumentException
- When the supplied names do not identify an attribute.
public boolean isNamespaceAware()
Indicates whether this parser is XML Namespace aware.
- Overrides:
- isNamespaceAware in interface SAXParser
public boolean isSpecified(int index)
Returns true unless the attribute value was provided by DTD defaulting.
- Specified by:
- isSpecified in interface Attributes2
- Parameters:
index
- The attribute index (zero-based).
- Returns:
- true if the value was found in the XML text, false if the value was provided by DTD defaulting.
- Throws:
ArrayIndexOutOfBoundsException
- When the supplied index does not identify an attribute.
public boolean isSpecified(String qName)
Returns true unless the attribute value was provided by DTD defaulting.
- Specified by:
- isSpecified in interface Attributes2
- Parameters:
qName
- The XML qualified (prefixed) name.
- Returns:
- true if the value was found in the XML text, false if the value was provided by DTD defaulting.
- Throws:
IllegalArgumentException
- When the supplied name does not identify an attribute.
public boolean isSpecified(String uri, String localName)
Returns true unless the attribute value was provided by DTD defaulting.Remember that since DTDs do not "understand" namespaces, the namespace URI associated with an attribute may not have come from the DTD. The declaration will have applied to the attribute's qName.
- Specified by:
- isSpecified in interface Attributes2
- Parameters:
uri
- The Namespace URI, or the empty string if the name has no Namespace URI.localName
- The attribute's local name.
- Returns:
- true if the value was found in the XML text, false if the value was provided by DTD defaulting.
- Throws:
IllegalArgumentException
- When the supplied names do not identify an attribute.
public boolean isValidating()
Indicates whether this parser will validate its input.
- Overrides:
- isValidating in interface SAXParser
public boolean isXIncludeAware()
Indicates whether this parser is XInclude-aware.
- Overrides:
- isXIncludeAware in interface SAXParser
- Since:
- 1.3
public void report(String message, String errorType, Object relatedInformation, Location location) throws XMLStreamException
- Specified by:
- report in interface XMLReporter
public XMLEventReader resolveAsXMLEventReader(String uri) throws XMLStreamException
public XMLStreamReader resolveAsXMLStreamReader(String uri) throws XMLStreamException
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:If
java.io.InputStream
javax.xml.stream.XMLStreamReader
java.xml.stream.XMLEventReader
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 entitynamespace
- the namespace of the external entity
public void setContentHandler(ContentHandler handler)
- Specified by:
- setContentHandler in interface XMLReader
public void setDTDHandler(DTDHandler handler)
- Specified by:
- setDTDHandler in interface XMLReader
public void setEntityResolver(EntityResolver resolver)
- Specified by:
- setEntityResolver in interface XMLReader
public void setErrorHandler(ErrorHandler handler)
- Specified by:
- setErrorHandler in interface XMLReader
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
- setFeature in interface XMLReader
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
Sets the specified SAX2 parser property.
- Specified by:
- setProperty in interface XMLReader
- Overrides:
- setProperty in interface SAXParser
- Parameters:
name
- the name of the propertyvalue
- the value of the property