|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bluecast.xml.Piccolo
Piccolo is a small, high-performance SAX1 and SAX2 parser. As per the SAX2 specification, namespace handling is on by default. You can improve performance by turning it off. Note that if used in SAX1 mode, namespace handling is automatically turned off.
Field Summary | |
static short |
ANY
|
static short |
ATTLIST_START
|
static short |
CDATA
|
static short |
CLOSE_TAG
|
static short |
COMMA
|
static short |
COMMENT
|
static short |
CONDITIONAL_START
|
static short |
DOUBLE_RBRACKET_END
|
static short |
DTD_START
|
static short |
DTD_START_SKIPEXTERNAL
|
static short |
ELEMENT_DECL_START
|
static short |
EMPTY
|
static short |
EMPTY_TAG
|
static short |
ENTITIES
|
static short |
ENTITY
|
static short |
ENTITY_DECL_START
|
static short |
ENTITY_END
|
static short |
ENTITY_REF
|
static short |
ENUMERATION
|
static short |
EQ
|
static short |
EXTERNAL_ENTITY_REF
|
static short |
FIXED
|
static short |
ID
|
static short |
IDREF
|
static short |
IDREFS
|
static short |
IGNORE
|
static short |
IGNORED_CONDITIONAL_START
|
static short |
IMPLIED
|
static short |
INCLUDE
|
static short |
INTERNAL_ENTITY_REF
|
static short |
LBRACKET
|
static short |
LPAREN
|
static short |
MODIFIER
|
static short |
NAME
|
static short |
NDATA
|
static short |
NMTOKEN
|
static short |
NMTOKENS
|
static short |
NOTATION
|
static short |
NOTATION_START
|
static short |
OPEN_TAG
|
static short |
PCDATA
|
static short |
PERCENT
|
static short |
PI
|
static short |
PIPE
|
static short |
PLUS
|
static short |
PREFIXED_NAME
|
static short |
PUBLIC
|
static short |
QUESTION
|
static short |
RBRACKET_END
|
static short |
REQUIRED
|
static short |
RPAREN
|
static short |
SKIPPED_ENTITY_REF
|
static short |
STAR
|
static short |
STRING
|
static short |
SYSTEM
|
static short |
TAG_END
|
static short |
UNPREFIXED_NAME
|
static short |
WHITESPACE
|
static short |
XML_DOC_DECL
|
static short |
XML_DOC_OR_TEXT_DECL
|
static short |
XML_TEXT_DECL
|
static short |
YYERRCODE
|
Constructor Summary | |
Piccolo()
|
|
Piccolo(Piccolo template)
Create an instance with the same configuration as the given instance. |
Method Summary | |
int |
getColumnNumber()
Return the column number where the current document event ends. |
ContentHandler |
getContentHandler()
SAX2 methods |
DTDHandler |
getDTDHandler()
Return the current DTD handler. |
EntityResolver |
getEntityResolver()
Return the current entity resolver. |
ErrorHandler |
getErrorHandler()
Return the current error handler. |
boolean |
getFeature(java.lang.String name)
Look up the value of a feature flag. |
int |
getLineNumber()
Return the line number where the current document event ends. |
java.lang.Object |
getProperty(java.lang.String name)
Look up the value of a property. |
java.lang.String |
getPublicId()
Return the public identifier for the current document event. |
java.lang.String |
getSystemId()
Return the system identifier for the current document event. |
void |
parse(InputSource source)
Methods common to both SAX1 and SAX2 |
void |
parse(java.lang.String sysID)
Parse an XML document from a system identifier (URI). |
void |
setContentHandler(ContentHandler handler)
Allow an application to register a content event handler. |
void |
setDebug(boolean debug)
|
void |
setDocumentHandler(DocumentHandler handler)
SAX1 methods |
void |
setDTDHandler(DTDHandler handler)
Allow an application to register a DTD event handler. |
void |
setEntityResolver(EntityResolver resolver)
Allow an application to register a custom entity resolver. |
void |
setErrorHandler(ErrorHandler handler)
Allow an application to register an error event handler. |
void |
setFeature(java.lang.String name,
boolean value)
Set the value of a feature flag. |
void |
setLocale(java.util.Locale locale)
Allow an application to request a locale for errors and warnings. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Set the value of a property. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final short CDATA
public static final short TAG_END
public static final short PI
public static final short NAME
public static final short STRING
public static final short EQ
public static final short OPEN_TAG
public static final short CLOSE_TAG
public static final short EMPTY_TAG
public static final short WHITESPACE
public static final short DTD_START
public static final short DTD_START_SKIPEXTERNAL
public static final short SYSTEM
public static final short PUBLIC
public static final short REQUIRED
public static final short IMPLIED
public static final short FIXED
public static final short LPAREN
public static final short RPAREN
public static final short LBRACKET
public static final short PIPE
public static final short ENTITY_DECL_START
public static final short ATTLIST_START
public static final short NOTATION_START
public static final short RBRACKET_END
public static final short DOUBLE_RBRACKET_END
public static final short PERCENT
public static final short ENUMERATION
public static final short NOTATION
public static final short ID
public static final short IDREF
public static final short IDREFS
public static final short ENTITY
public static final short ENTITIES
public static final short NMTOKEN
public static final short NMTOKENS
public static final short ENTITY_REF
public static final short ENTITY_END
public static final short INTERNAL_ENTITY_REF
public static final short EXTERNAL_ENTITY_REF
public static final short SKIPPED_ENTITY_REF
public static final short PREFIXED_NAME
public static final short UNPREFIXED_NAME
public static final short NDATA
public static final short COMMENT
public static final short CONDITIONAL_START
public static final short IGNORED_CONDITIONAL_START
public static final short INCLUDE
public static final short IGNORE
public static final short MODIFIER
public static final short PCDATA
public static final short ELEMENT_DECL_START
public static final short EMPTY
public static final short ANY
public static final short STAR
public static final short COMMA
public static final short QUESTION
public static final short PLUS
public static final short XML_DOC_DECL
public static final short XML_TEXT_DECL
public static final short XML_DOC_OR_TEXT_DECL
public static final short YYERRCODE
Constructor Detail |
public Piccolo()
public Piccolo(Piccolo template)
Method Detail |
public void setDebug(boolean debug)
public void parse(InputSource source) throws java.io.IOException, SAXException
parse
in interface Parser
source
- The input source for the top-level of the
XML document.
java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.
SAXException
- Any SAX exception, possibly
wrapping another exception.InputSource
,
Parser.parse(java.lang.String)
,
Parser.setEntityResolver(org.xml.sax.EntityResolver)
,
Parser.setDTDHandler(org.xml.sax.DTDHandler)
,
Parser.setDocumentHandler(org.xml.sax.DocumentHandler)
,
Parser.setErrorHandler(org.xml.sax.ErrorHandler)
public void parse(java.lang.String sysID) throws java.io.IOException, SAXException
Parser
This method is a shortcut for the common case of reading a document from a system identifier. It is the exact equivalent of the following:
parse(new InputSource(systemId));
If the system identifier is a URL, it must be fully resolved by the application before it is passed to the parser.
parse
in interface Parser
sysID
- The system identifier (URI).
SAXException
- Any SAX exception, possibly
wrapping another exception.
java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.Parser.parse(org.xml.sax.InputSource)
public void setDocumentHandler(DocumentHandler handler)
setDocumentHandler
in interface Parser
handler
- The document handler.DocumentHandler
,
HandlerBase
public void setDTDHandler(DTDHandler handler)
Parser
If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored (this is the default behaviour implemented by HandlerBase).
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
setDTDHandler
in interface Parser
handler
- The DTD handler.DTDHandler
,
HandlerBase
public void setEntityResolver(EntityResolver resolver)
Parser
If the application does not register an entity resolver, the SAX parser will resolve system identifiers and open connections to entities itself (this is the default behaviour implemented in HandlerBase).
Applications may register a new or different entity resolver in the middle of a parse, and the SAX parser must begin using the new resolver immediately.
setEntityResolver
in interface Parser
resolver
- The object for resolving entities.EntityResolver
,
HandlerBase
public void setErrorHandler(ErrorHandler handler)
Parser
If the application does not register an error event handler, all error events reported by the SAX parser will be silently ignored, except for fatalError, which will throw a SAXException (this is the default behaviour implemented by HandlerBase).
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
setErrorHandler
in interface Parser
handler
- The error handler.ErrorHandler
,
SAXException
,
HandlerBase
public void setLocale(java.util.Locale locale)
Parser
SAX parsers are not required to provide localisation for errors and warnings; if they cannot support the requested locale, however, they must throw a SAX exception. Applications may not request a locale change in the middle of a parse.
setLocale
in interface Parser
locale
- A Java Locale object.SAXException
,
SAXParseException
public int getColumnNumber()
Locator
char
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.
getColumnNumber
in interface Locator
Locator.getLineNumber()
public int getLineNumber()
Locator
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.
getLineNumber
in interface Locator
Locator.getColumnNumber()
public java.lang.String getPublicId()
Locator
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.
getPublicId
in interface Locator
Locator.getSystemId()
public java.lang.String getSystemId()
Locator
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.
getSystemId
in interface Locator
Locator.getPublicId()
public ContentHandler getContentHandler()
getContentHandler
in interface XMLReader
XMLReader.setContentHandler(org.xml.sax.ContentHandler)
public void setContentHandler(ContentHandler handler)
XMLReader
If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
setContentHandler
in interface XMLReader
handler
- The content handler.XMLReader.getContentHandler()
public DTDHandler getDTDHandler()
XMLReader
getDTDHandler
in interface XMLReader
XMLReader.setDTDHandler(org.xml.sax.DTDHandler)
public EntityResolver getEntityResolver()
XMLReader
getEntityResolver
in interface XMLReader
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
public ErrorHandler getErrorHandler()
XMLReader
getErrorHandler
in interface XMLReader
XMLReader.setErrorHandler(org.xml.sax.ErrorHandler)
public boolean getFeature(java.lang.String name)
XMLReader
The feature name is any fully-qualified URI. It is
possible for an XMLReader to recognize a feature name but
temporarily be unable to return its value.
Some feature values may be available only in specific
contexts, such as before, during, or after a parse.
Also, some feature values may not be programmatically accessible.
(In the case of an adapter for SAX1 Parser
, there is no
implementation-independent way to expose whether the underlying
parser is performing validation, expanding external entities,
and so forth.)
All XMLReaders are required to recognize the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes feature names.
Typical usage is something like this:
XMLReader r = new MySAXDriver(); // try to activate validation try { r.setFeature("http://xml.org/sax/features/validation", true); } catch (SAXException e) { System.err.println("Cannot activate validation."); } // register event handlers r.setContentHandler(new MyContentHandler()); r.setErrorHandler(new MyErrorHandler()); // parse the first document try { r.parse("http://www.foo.com/mydoc.xml"); } catch (IOException e) { System.err.println("I/O exception reading XML document"); } catch (SAXException e) { System.err.println("XML exception reading document."); }
Implementors are free (and encouraged) to invent their own features, using names built on their own URIs.
getFeature
in interface XMLReader
name
- The feature name, which is a fully-qualified URI.
XMLReader.setFeature(java.lang.String, boolean)
public void setFeature(java.lang.String name, boolean value) throws SAXNotSupportedException, SAXNotRecognizedException
XMLReader
The feature name is any fully-qualified URI. It is possible for an XMLReader to expose a feature value but to be unable to change the current value. Some feature values may be immutable or mutable only in specific contexts, such as before, during, or after a parse.
All XMLReaders are required to support setting http://xml.org/sax/features/namespaces to true and http://xml.org/sax/features/namespace-prefixes to false.
setFeature
in interface XMLReader
name
- The feature name, which is a fully-qualified URI.value
- The requested value of the feature (true or false).
SAXNotRecognizedException
- If the feature
value can't be assigned or retrieved.
SAXNotSupportedException
- When the
XMLReader recognizes the feature name but
cannot set the requested value.XMLReader.getFeature(java.lang.String)
public java.lang.Object getProperty(java.lang.String name) throws SAXNotRecognizedException, SAXNotSupportedException
XMLReader
The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but temporarily be unable to return its value. Some property values may be available only in specific contexts, such as before, during, or after a parse.
XMLReaders are not required to recognize any specific property names, though an initial core set is documented for SAX2.
Implementors are free (and encouraged) to invent their own properties, using names built on their own URIs.
getProperty
in interface XMLReader
name
- The property name, which is a fully-qualified URI.
SAXNotSupportedException
- When the
XMLReader recognizes the property name but
cannot determine its value at this time.
SAXNotRecognizedException
- If the property
value can't be assigned or retrieved.XMLReader.setProperty(java.lang.String, java.lang.Object)
public void setProperty(java.lang.String name, java.lang.Object value) throws SAXNotRecognizedException, SAXNotSupportedException
XMLReader
The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but to be unable to change the current value. Some property values may be immutable or mutable only in specific contexts, such as before, during, or after a parse.
XMLReaders are not required to recognize setting any specific property names, though a core set is defined by SAX2.
This method is also the standard mechanism for setting extended handlers.
setProperty
in interface XMLReader
name
- The property name, which is a fully-qualified URI.value
- The requested value for the property.
SAXNotSupportedException
- When the
XMLReader recognizes the property name but
cannot set the requested value.
SAXNotRecognizedException
- If the property
value can't be assigned or retrieved.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |