Driver
Stay organized with collections
Save and categorize content based on your preferences.
outlined_flag
The Driver
class is a SAX2 driver that converts XmlPullParser events into SAX2 callbacks.
It implements the Locator
, XMLReader
, and Attributes
interfaces, providing methods for parsing XML documents.
The Driver
class supports features like namespaces, validation, and lexical handling.
It includes public methods for setting content handlers, error handlers, DTD handlers, entity resolvers, and features.
Developers can use the parse()
method to initiate parsing of an XML document from a system ID or an InputSource
.
SAX2 Driver that pulls events from XmlPullParser
and converts them into SAX2 callbacks.
Public Constructor Summary
Public Method Summary
int
ContentHandler
DTDHandler
EntityResolver
ErrorHandler
boolean
int
int
int
int
String
Object
String
String
String
String
String
getType (String uri, String localName)
String
String
String
String
String
void
void
parse (InputSource source)
void
void
void
void
void
void
void
Protected Method Summary
void
startElement (String namespace, String localName, String qName)
Inherited Method Summary
From class
java.lang.Object
Object
clone ()
boolean
equals (Object arg0)
void
finalize ()
final
Class<?>
getClass ()
int
hashCode ()
final
void
notify ()
final
void
notifyAll ()
String
toString ()
final
void
wait (long arg0, int arg1)
final
void
wait (long arg0)
final
void
wait ()
From interface
org.xml.sax.Locator
abstract
int
getColumnNumber ()
abstract
int
getLineNumber ()
abstract
String
getPublicId ()
abstract
String
getSystemId ()
From interface
org.xml.sax.XMLReader
abstract
ContentHandler
getContentHandler ()
abstract
DTDHandler
getDTDHandler ()
abstract
EntityResolver
getEntityResolver ()
abstract
ErrorHandler
getErrorHandler ()
abstract
boolean
getFeature (String arg0)
abstract
Object
getProperty (String arg0)
abstract
void
parse (InputSource arg0)
abstract
void
parse (String arg0)
abstract
void
setContentHandler (ContentHandler arg0)
abstract
void
setDTDHandler (DTDHandler arg0)
abstract
void
setEntityResolver (EntityResolver arg0)
abstract
void
setErrorHandler (ErrorHandler arg0)
abstract
void
setFeature (String arg0, boolean arg1)
abstract
void
setProperty (String arg0, Object arg1)
From interface
org.xml.sax.Attributes
abstract
int
getIndex (String arg0)
abstract
int
getIndex (String arg0, String arg1)
abstract
int
getLength ()
abstract
String
getLocalName (int arg0)
abstract
String
getQName (int arg0)
abstract
String
getType (String arg0)
abstract
String
getType (int arg0)
abstract
String
getType (String arg0, String arg1)
abstract
String
getURI (int arg0)
abstract
String
getValue (String arg0)
abstract
String
getValue (int arg0)
abstract
String
getValue (String arg0, String arg1)
Constants
protected
static
final
String
APACHE_DYNAMIC_VALIDATION_FEATURE
Constant Value:
"http://apache.org/xml/features/validation/dynamic"
protected
static
final
String
APACHE_SCHEMA_VALIDATION_FEATURE
Constant Value:
"http://apache.org/xml/features/validation/schema"
protected
static
final
String
DECLARATION_HANDLER_PROPERTY
Constant Value:
"http://xml.org/sax/properties/declaration-handler"
protected
static
final
String
LEXICAL_HANDLER_PROPERTY
Constant Value:
"http://xml.org/sax/properties/lexical-handler"
protected
static
final
String
NAMESPACES_FEATURE
Constant Value:
"http://xml.org/sax/features/namespaces"
protected
static
final
String
NAMESPACE_PREFIXES_FEATURE
Constant Value:
"http://xml.org/sax/features/namespace-prefixes"
protected
static
final
String
VALIDATION_FEATURE
Constant Value:
"http://xml.org/sax/features/validation"
Fields
protected
ContentHandler
contentHandler
protected
ErrorHandler
errorHandler
protected
String
systemId
Public Methods
public
int
getColumnNumber
()
public
ContentHandler
getContentHandler
()
public
DTDHandler
getDTDHandler
()
public
EntityResolver
getEntityResolver
()
public
ErrorHandler
getErrorHandler
()
public
boolean
getFeature
(String name)
Throws
SAXNotRecognizedException
SAXNotSupportedException
public
int
getIndex
(String qName)
public
int
getIndex
(String uri, String localName)
public
int
getLineNumber
()
public
String
getLocalName
(int index)
public
Object
getProperty
(String name)
Throws
SAXNotRecognizedException
SAXNotSupportedException
public
String
getPublicId
()
public
String
getQName
(int index)
public
String
getSystemId
()
public
String
getType
(int index)
public
String
getType
(String uri, String localName)
public
String
getType
(String qName)
public
String
getURI
(int index)
public
String
getValue
(int index)
public
String
getValue
(String qName)
public
String
getValue
(String uri, String localName)
public
void
parse
(String systemId)
public
void
setContentHandler
(ContentHandler handler)
public
void
setDTDHandler
(DTDHandler handler)
public
void
setEntityResolver
(EntityResolver resolver)
public
void
setErrorHandler
(ErrorHandler handler)
public
void
setFeature
(String name, boolean value)
Throws
SAXNotRecognizedException
SAXNotSupportedException
public
void
setProperty
(String name, Object value)
Throws
SAXNotRecognizedException
SAXNotSupportedException
Protected Methods
protected
void
startElement
(String namespace, String localName, String qName)
Calls startElement
on the ContentHandler
with this
driver object as the
Attributes
implementation. In default implementation
Attributes
object is valid only during this method call and may not
be stored. Sub-classes can overwrite this method to cache attributes.
Parameters
namespace
localName
qName
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[],["The `Driver` class is a SAX2 driver that converts events from `XmlPullParser` into SAX2 callbacks. It implements `Locator`, `XMLReader`, and `Attributes`. Key actions include parsing XML using `parse` methods, and managing handlers for content, DTD, entities, and errors with `set` methods (e.g., `setContentHandler`). It retrieves information such as line and column numbers, feature and property values with `get` methods(e.g., `getLineNumber`). It also defines constants for XML features and properties and allows sub-classes to interact with the `ContentHandler` through the method `startElement`.\n"]]