|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.co.wilson.xml.MinML
public class MinML
Field Summary | |
---|---|
static int |
change
|
static int |
decLevel
|
static int |
discardAndChange
|
static int |
discardSaveAndChange
|
static int |
emitCharacters
|
static int |
emitCharactersSave
|
static int |
emitEndElement
|
static int |
emitStartElement
|
static int |
endCDATA
|
static int |
endComment
|
static int |
endStartName
|
static int |
exitParser
|
static int |
inAttribute
|
static int |
inAttribute1
|
static int |
inAttributeQuotesValue
|
static int |
inAttributeQuoteValue
|
static int |
inAttributeValue
|
static int |
inCDATA
|
static int |
inCDATA1
|
static int |
inCharData
|
static int |
incLevel
|
static int |
inComment
|
static int |
inDTD
|
static int |
inETag
|
static int |
inETag1
|
static int |
inMTTag
|
static int |
inNextAttribute
|
static int |
inPI
|
static int |
inPI1
|
static int |
inPossiblyAttribute
|
static int |
inPossiblySkipping
|
static int |
inSkipping
|
static int |
inSTag
|
static int |
inTag
|
static int |
inTag1
|
static int |
parseError
|
static int |
possiblyEmitCharacters
|
static int |
processCharRef
|
static int |
saveAndChange
|
static int |
saveAttributeName
|
static int |
saveAttributeValue
|
static int |
startCDATA
|
static int |
startComment
|
static int |
writeCdata
|
Constructor Summary | |
---|---|
MinML()
|
|
MinML(int initialBufferSize,
int bufferIncrement)
|
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data. |
void |
endDocument()
Receive notification of the end of a document. |
void |
endElement(java.lang.String name)
Receive notification of the end of an element. |
void |
error(SAXParseException e)
Receive notification of a recoverable error. |
void |
fatalError(SAXParseException e)
Receive notification of a non-recoverable error. |
int |
getColumnNumber()
Return the column number where the current document event ends. |
int |
getLineNumber()
Return the line number where the current document event ends. |
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 |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
void |
parse(InputSource source)
Parse an XML document. |
void |
parse(java.io.Reader in)
|
void |
parse(java.lang.String systemId)
Parse an XML document from a system identifier (URI). |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
void |
setDocumentHandler(DocumentHandler handler)
Allow an application to register a document event handler. |
void |
setDocumentHandler(DocumentHandler handler)
|
void |
setDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events. |
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 |
setLocale(java.util.Locale locale)
Allow an application to request a locale for errors and warnings. |
void |
startDocument()
Receive notification of the beginning of a document. |
java.io.Writer |
startDocument(java.io.Writer writer)
|
void |
startElement(java.lang.String name,
AttributeList attributes)
Receive notification of the beginning of an element. |
java.io.Writer |
startElement(java.lang.String name,
AttributeList attributes,
java.io.Writer writer)
|
void |
warning(SAXParseException e)
Receive notification of a warning. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int endStartName
public static final int emitStartElement
public static final int emitEndElement
public static final int possiblyEmitCharacters
public static final int emitCharacters
public static final int emitCharactersSave
public static final int saveAttributeName
public static final int saveAttributeValue
public static final int startComment
public static final int endComment
public static final int incLevel
public static final int decLevel
public static final int startCDATA
public static final int endCDATA
public static final int processCharRef
public static final int writeCdata
public static final int exitParser
public static final int parseError
public static final int discardAndChange
public static final int discardSaveAndChange
public static final int saveAndChange
public static final int change
public static final int inSkipping
public static final int inSTag
public static final int inPossiblyAttribute
public static final int inNextAttribute
public static final int inAttribute
public static final int inAttribute1
public static final int inAttributeValue
public static final int inAttributeQuoteValue
public static final int inAttributeQuotesValue
public static final int inETag
public static final int inETag1
public static final int inMTTag
public static final int inTag
public static final int inTag1
public static final int inPI
public static final int inPI1
public static final int inPossiblySkipping
public static final int inCharData
public static final int inCDATA
public static final int inCDATA1
public static final int inComment
public static final int inDTD
Constructor Detail |
---|
public MinML(int initialBufferSize, int bufferIncrement)
public MinML()
Method Detail |
---|
public void parse(java.io.Reader in) throws SAXException, java.io.IOException
SAXException
java.io.IOException
public void parse(InputSource source) throws SAXException, java.io.IOException
Parser
The application can use this method to instruct the SAX parser to begin parsing an XML document from any valid input source (a character stream, a byte stream, or a URI).
Applications may not invoke this method while a parse is in progress (they should create a new Parser instead for each additional XML document). Once a parse is complete, an application may reuse the same Parser object, possibly with a different input source.
parse
in interface Parser
source
- The input source for the top-level of the
XML document.
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.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 systemId) throws SAXException, java.io.IOException
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
systemId
- 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 setLocale(java.util.Locale locale) throws SAXException
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
- Throws an exception
(using the previous or default locale) if the
requested locale is not supported.SAXException
,
SAXParseException
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 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 setDocumentHandler(DocumentHandler handler)
Parser
If the application does not register a document handler, all document 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.
setDocumentHandler
in interface Parser
handler
- The document handler.DocumentHandler
,
HandlerBase
public void setDocumentHandler(DocumentHandler handler)
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 setDocumentLocator(Locator locator)
DocumentHandler
SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.
The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine.
Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.
setDocumentLocator
in interface DocumentHandler
locator
- An object that can return the location of
any SAX document event.Locator
public void startDocument() throws SAXException
DocumentHandler
The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).
startDocument
in interface DocumentHandler
SAXException
- Any SAX exception, possibly
wrapping another exception.public java.io.Writer startDocument(java.io.Writer writer) throws SAXException
SAXException
public void endDocument() throws SAXException
DocumentHandler
The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.
endDocument
in interface DocumentHandler
SAXException
- Any SAX exception, possibly
wrapping another exception.public void startElement(java.lang.String name, AttributeList attributes) throws SAXException
DocumentHandler
The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement() event for every startElement() event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement() event.
If the element name has a namespace prefix, the prefix will still be attached. Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted.
startElement
in interface DocumentHandler
name
- The element type name.attributes
- The attributes attached to the element, if any.
SAXException
- Any SAX exception, possibly
wrapping another exception.DocumentHandler.endElement(java.lang.String)
,
AttributeList
public java.io.Writer startElement(java.lang.String name, AttributeList attributes, java.io.Writer writer) throws SAXException
SAXException
public void endElement(java.lang.String name) throws SAXException
DocumentHandler
The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding startElement() event for every endElement() event (even when the element is empty).
If the element name has a namespace prefix, the prefix will still be attached to the name.
endElement
in interface DocumentHandler
name
- The element type name
SAXException
- Any SAX exception, possibly
wrapping another exception.public void characters(char[] ch, int start, int length) throws SAXException
DocumentHandler
The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The application must not attempt to read from the array outside of the specified range.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
characters
in interface DocumentHandler
ch
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.
SAXException
- Any SAX exception, possibly
wrapping another exception.DocumentHandler.ignorableWhitespace(char[], int, int)
,
Locator
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
DocumentHandler
Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.
SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The application must not attempt to read from the array outside of the specified range.
ignorableWhitespace
in interface DocumentHandler
ch
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.
SAXException
- Any SAX exception, possibly
wrapping another exception.DocumentHandler.characters(char[], int, int)
public void processingInstruction(java.lang.String target, java.lang.String data) throws SAXException
DocumentHandler
The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.
A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.
processingInstruction
in interface DocumentHandler
target
- The processing instruction target.data
- The processing instruction data, or null if
none was supplied.
SAXException
- Any SAX exception, possibly
wrapping another exception.public void warning(SAXParseException e) throws SAXException
ErrorHandler
SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.
warning
in interface ErrorHandler
e
- The warning information encapsulated in a
SAX parse exception.
SAXException
- Any SAX exception, possibly
wrapping another exception.SAXParseException
public void error(SAXParseException e) throws SAXException
ErrorHandler
This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML 1.0 recommendation does not require it to do so.
error
in interface ErrorHandler
e
- The error information encapsulated in a
SAX parse exception.
SAXException
- Any SAX exception, possibly
wrapping another exception.SAXParseException
public void fatalError(SAXParseException e) throws SAXException
ErrorHandler
This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.
The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting addition error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.
fatalError
in interface ErrorHandler
e
- The error information encapsulated in a
SAX parse exception.
SAXException
- Any SAX exception, possibly
wrapping another exception.SAXParseException
public java.lang.String getPublicId()
Locator
This will be the public identifier
getPublicId
in interface Locator
Locator.getSystemId()
public java.lang.String getSystemId()
Locator
If the system identifier is a URL, the parser must resolve it fully before passing it to the application.
getSystemId
in interface Locator
Locator.getPublicId()
public int getLineNumber()
Locator
getLineNumber
in interface Locator
Locator.getColumnNumber()
public int getColumnNumber()
Locator
getColumnNumber
in interface Locator
Locator.getLineNumber()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |