|
XML Parser for Java 1.1.16 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.xml.parser.Parser
Parser is the XML4J parser that examines an XML document and generates an object tree of Document Object Model (DOM) Nodes. Details of these Nodes are provided by the references below.
TXDocument
,
TXElement
,
TXText
,
TXComment
,
TXPI
,
StylesheetPI
,
TXCDATASection
,
TXNotation
,
TXAttributeList
,
TXAttribute
,
DTD
,
ElementDecl
,
Attlist
,
AttDef
,
EntityDecl
Constructor Summary | |
Parser(java.lang.String name)
Constructor when using the default ErrorListener and StreamProducer . |
|
Parser(java.lang.String name,
ErrorListener errorListener,
StreamProducer streamProducer)
Constructor when NOT using the default ErrorListener or StreamProducer . |
Method Summary | |
void |
addElementHandler(ElementHandler elementHandler)
Register a handler for receiving control when ANY element tag is recognized by this parser. |
void |
addElementHandler(ElementHandler elementHandler,
java.lang.String elementTagName)
Register a handler for receiving control when the specified elementTagName element tag is recognized by this parser. |
void |
addNoRequiredAttributeHandler(NoRequiredAttributeHandler noRequiredAttributeHandler)
Register a handler for receiving control when a "no required attribute" event is recognized by this parser. |
void |
addPIHandler(PIHandler piHandler)
Register a handler for receiving control when PIs are recognized by this parser. |
void |
addPreRootHandler(PreRootHandler preRootHandler)
Register a handler for receiving control from this parser after the internal and/or external DTD subsets are parsed, but before the document's root Element is parsed. |
void |
closeInputStream(Source source)
Removes the input stream currently in use. |
Source |
getInputStream(java.lang.String name,
java.lang.String publicID,
java.lang.String systemID)
Returns the source of the input stream (could be a character stream or a byte stream) based on the entity specified by the system ID and/or public ID, and the streamProducer specified when this parser was constructed. |
int |
getNumberOfErrors()
Returns the number of errors and exceptions currently encountered by this parser. |
int |
getNumberOfWarnings()
Returns the number of warnings currently encountered by this parser. |
int |
getReaderBufferSize()
Returns the size of this parser's character-stream-oriented input source buffer. |
void |
loadCatalog(java.io.Reader reader)
Loads a catalog which provides mapping between public IDs and system IDs. |
DTD |
readDTDStream(java.io.InputStream inputStream)
Returns a parsed external DTD subset based on the specified inputStream. |
DTD |
readDTDStream(java.io.Reader reader)
Returns a parsed external DTD subset based on the specified reader. |
DTD |
readDTDStream(Source source)
Returns a parsed external DTD subset based on the specified source. |
TXDocument |
readStream(java.io.InputStream inputStream)
Returns a parsed XML document based on the specified inputStream. |
TXDocument |
readStream(java.io.Reader reader)
Returns a parsed XML document based on the specified reader. |
TXDocument |
readStream(Source source)
Returns a parsed XML document based on the specified source. |
void |
setAllowJavaEncodingName(boolean isAllowJavaEncodingName)
Sets whether this parser allows Java encoding names to be specified in place of MIME charset names on xmlEncoding parameters. |
void |
setElementFactory(TXDocument elementFactory)
Sets the code to receive control when the various components of the Document Object Model (DOM) and XML4J need to be created and initialized. |
void |
setEndBy1stError(boolean isEndBy1stError)
Sets whether this parser terminates processing when an initial error or exception occurs. |
void |
setErrorNoByteMark(boolean isErrorNoByteMark)
Sets whether this parser treats missing byte marks in the input stream as an error, and reports this condition through the defined ErrorListener . |
void |
setExpandEntityReferences(boolean isExpandEntityReferences)
Sets whether EntityReference Nodes are expanded by this parser. |
void |
setKeepComment(boolean isKeepComment)
Sets whether TXComment Nodes are created by this parser when XML
comments are encountered. |
void |
setLocale(java.util.Locale locale)
Sets a locale for error and warning messages. |
void |
setPreserveSpace(boolean isPreserveSpace)
Sets, at the document level, whether space is to be preserved in the parsed document. |
void |
setProcessExternalDTD(boolean isProcessExternalDTD)
Sets whether this parser reads an external subset of DTD, pointed in an ExternalID in DOCTYPE declaration. |
void |
setProcessNamespace(boolean isProcessNamespace)
Sets whether namespaces are respected by this parser. |
void |
setReaderBufferSize(int readerBufferSize)
Sets the size of this parser's character-stream-oriented input source buffer. |
void |
setReferenceHandler(ReferenceHandler referenceHandler)
Register a handler for receiving control when a General Reference is recognized by this parser. |
void |
setTagHandler(TagHandler tagHandler)
Register a handler for receiving control when tag start and tag end events are recognized by this parser. |
void |
setWarningNoDoctypeDecl(boolean isWarningNoDoctypeDecl)
Sets whether this parser treats a missing DTD declaration as a warning, and reports this condition through the defined ErrorListener . |
void |
setWarningNoXMLDecl(boolean isWarningNoXMLDecl)
Sets whether this parser treats a missing XML prolog PIs as a warning, and reports this condition through the defined ErrorListener . |
void |
setWarningRedefinedEntity(boolean isWarningRedefinedEntity)
Sets whether this parser treats redefined entities as a warning, and reports this condition through the defined ErrorListener . |
void |
stop()
Stops a Parser.readStream() operation. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Parser(java.lang.String name)
ErrorListener
and StreamProducer
.
The default ErrorListener
and StreamProducer
are defined by
the Stderr
class.name
- URL or filespec to use as the default input stream; if a filespec is
provided, this value can include a drive and directory spec.
This value is also used to associate a name with errors reported to the
default error listener that have a file parameter
=null
.Stderr
,
ErrorListener
,
StreamProducer
public Parser(java.lang.String name, ErrorListener errorListener, StreamProducer streamProducer)
ErrorListener
or StreamProducer
.
The default ErrorListener
and StreamProducer
are defined by
the Stderr
class.name
- This parameter is only used if either errorListener or
streamProducer are allowed to default. If streamProducer
is allowed to default, this value is the URL or filespec to use as
the default input stream; if a filespec is provided, this value can
include a drive and directory spec. If errorListener is
allowed to default, this value is used to associate a name with
errors reported to the default error listener that have a
file parameter =null
.errorListener
- Handler for error and warning events that are recognized by this
parser, or null if to use the default listener.streamProducer
- Mechanism for manipulating this parser's input stream, or
null if to use the default stream producer.Stderr
,
ErrorListener
,
StreamProducer
Method Detail |
public void setLocale(java.util.Locale locale)
By default, the current user locale's resource bundle is used. If no messages exist for the requested locale, US English messages are used.
locale
- A Java Locale object.public void setElementFactory(TXDocument elementFactory)
TXDocument
is used.
When this method is called, readStream() returns the elementFactory.
elementFactory
- Factory to use to create and initialize objects. This must be an instance of TXDocument or a subclass of TXDocument.TXDocument
public Source getInputStream(java.lang.String name, java.lang.String publicID, java.lang.String systemID) throws java.io.IOException
Returns the source of the input stream (could be a character stream or a byte stream) based on the entity specified by the system ID and/or public ID, and the streamProducer specified when this parser was constructed.
name
- The name to be associated with the input stream. For example,
this name could be the public ID of an external ID, or a local filename.publicID
- Entity's public ID, or null if no public ID (see ExternalID for details).systemID
- Entity's system ID.ExternalID
,
closeInputStream(com.ibm.xml.parser.Source)
,
StreamProducer.getInputStream(java.lang.String, java.lang.String, java.lang.String)
public void closeInputStream(Source source)
Removes the input stream currently in use.
source
- Source of the input stream to be closed.getInputStream(java.lang.String, java.lang.String, java.lang.String)
,
StreamProducer.closeInputStream(com.ibm.xml.parser.Source)
public void loadCatalog(java.io.Reader reader) throws java.io.IOException
reader
- Character input stream reader.getInputStream(java.lang.String, java.lang.String, java.lang.String)
,
ExternalID
,
Stderr.loadCatalog(java.io.Reader)
,
StreamProducer.loadCatalog(java.io.Reader)
public void setTagHandler(TagHandler tagHandler)
tagHandler
- Handler to be registered.TagHandler
public void setReferenceHandler(ReferenceHandler referenceHandler)
referenceHandler
- Handler to be registered.ReferenceHandler
public void addPreRootHandler(PreRootHandler preRootHandler)
preRootHandler
- Handler to be registered.PreRootHandler
public void addPIHandler(PIHandler piHandler)
piHandler
- Handler to be registered.PIHandler
public void addElementHandler(ElementHandler elementHandler)
elementHandler
- Handler to be registered.ElementHandler
public void addElementHandler(ElementHandler elementHandler, java.lang.String elementTagName)
elementHandler
- Handler to be registered for the specified elementTagName.elementTagName
- Element name to be watched for by this parser. If the
Element's name has a namespace prefix, that prefix should
be included.ElementHandler
public void addNoRequiredAttributeHandler(NoRequiredAttributeHandler noRequiredAttributeHandler)
By default, no required attribute handlers are registered to this parser.
noRequiredAttributeHandler
- Handler to be registered.NoRequiredAttributeHandler
public int getNumberOfErrors()
ErrorListener
public int getNumberOfWarnings()
ErrorListener
public void setKeepComment(boolean isKeepComment)
TXComment
Nodes are created by this parser when XML
comments are encountered.
By default, TXComment
Nodes are created by this parser.
isKeepComment
- =true
means maintain parsed comments;
=false
means drop comments when creating object tree.TXComment
public void setExpandEntityReferences(boolean isExpandEntityReferences)
EntityReference
Nodes are expanded by this parser.
By default, EntityReference
Nodes are kept.
isKeepComment
- =true
means expanding entity references;
=false
means maintain entity references.EntityReference
,
GeneralReference
public void setProcessNamespace(boolean isProcessNamespace)
TXElement, TXPI, and TXAttribute
Nodes. If namespaces
are respected, the methods defined by the Namespace
interface will
function properly in these Nodes.
By default, namespaces are NOT respected by this parser.
isProcessNamespace
- =true
means parse for namespaces;
=false
means ignore namespaces when parsing.Namespace
,
TXElement
,
TXAttribute
public void setAllowJavaEncodingName(boolean isAllowJavaEncodingName)
MIME2Java
class is provided to facilitate conversion when Java encoding names are not allowed.
By default, Java encoding names are NOT allowed on xmlEncoding parameters by this parser.
isAllowJavaEncodingName
- =true
means Java encoding names are allowed;
=false
means MIME charset names must be used.TXDocument.setEncoding(java.lang.String)
,
DTD.setEncoding(java.lang.String)
,
MIME2Java
public void setProcessExternalDTD(boolean isProcessExternalDTD)
By default, this parser reads an external subset of DTD.
isProcessExternalDTD
- =true
means process an external DTD;
=false
means ignore an external DTD.DTD
public void setPreserveSpace(boolean isPreserveSpace)
xml:space
attribute.
By default, space is not to be preserved in the parsed document.
isPreserveSpace
- =true
space is to be preserved;
=false
space is to be ignored.TXElement.setPreserveSpace(boolean)
,
TXText.setIsIgnorableWhitespace(boolean)
,
TXDocument.printWithFormat(java.io.Writer)
public void setErrorNoByteMark(boolean isErrorNoByteMark)
ErrorListener
.
By default, this condition is reported by this parser as an error.
isErrorNoByteMark
- =true
means report condition as an error;
=false
means ignore this condition.public void setWarningRedefinedEntity(boolean isWarningRedefinedEntity)
ErrorListener
.
By default, this condition is reported by this parser as a warning.
isWarningRedefinedEntity
- =true
means report condition as a warning;
=false
means ignore this condition.EntityDecl
public void setWarningNoXMLDecl(boolean isWarningNoXMLDecl)
ErrorListener
.
By default, this condition is reported by this parser as a warning.
isWarningNoXMLDecl
- =true
means report condition as a warning;
=false
means ignore this condition.TXPI
public void setWarningNoDoctypeDecl(boolean isWarningNoDoctypeDecl)
ErrorListener
.
By default, this condition is NOT reported by this parser as a warning.
isWarningNoXMLDecl
- =true
means report condition as a warning;
=false
means ignore this condition.DTD
public void setEndBy1stError(boolean isEndBy1stError)
By default, this parser stops parsing after an error occurs, as required by the XML specification.
isEndBy1stError
- =true
means initial error or exception ends processing;
=false
means processing continues until document is fully parsed.public void stop()
Parser.readStream()
operation.
The calling thread will signal that the thread executing in this.readStream()
should clean up and return as soon as practical. The calling thread will return immediately.
The effect of stop()
is sticky, meaning that after stop()
has been
called, a thread entering readStream() will return immediately.
(This helps in the case where the UI thread invokes stop
before the processing
thread actually enters readStream
stop
affects only the specific instance of the parser (this) on which
it is invoked. It is not global; readStream
on other parser instances
will not be affected.
public TXDocument readStream(java.io.InputStream inputStream)
TXDocument#getDocumentElement
.
Once this method is invoked, the parser instance is of no further use, and should NOT be reused.
inputStream
- Byte-stream-oriented data source.Source
,
TXDocument.getDocumentElement()
,
readDTDStream(java.io.InputStream)
public TXDocument readStream(java.io.Reader reader)
TXDocument#getDocumentElement
.
Once this method is invoked, the parser instance is of no further use, and should NOT be reused.
reader
- Character-stream-oriented data source.Source
,
TXDocument.getDocumentElement()
,
readDTDStream(java.io.InputStream)
public TXDocument readStream(Source source)
TXDocument#getDocumentElement
.
Once this method is invoked, the parser instance is of no further use, and should NOT be reused.
source
- Byte-stream-oriented or character-stream-oriented data source.Source
,
TXDocument.getDocumentElement()
,
readDTDStream(java.io.InputStream)
public DTD readDTDStream(java.io.InputStream inputStream) throws java.io.IOException
DTD#externalElements
.
Once this method is invoked, the parser instance is of no further use, and should NOT be reused.
inputStream
- Byte-stream-oriented data source.Source
,
DTD
,
readStream(java.io.InputStream)
public DTD readDTDStream(java.io.Reader reader) throws java.io.IOException
DTD#externalElements
.
Once this method is invoked, the parser instance is of no further use, and should NOT be reused.
reader
- Character-stream-oriented data source.Source
,
DTD
,
readStream(java.io.InputStream)
public DTD readDTDStream(Source source) throws java.io.IOException
DTD#externalElements
.
Once this method is invoked, the parser instance is of no further use, and should NOT be reused.
source
- Byte-stream-oriented or character-stream-oriented data source.Source
,
DTD
,
readStream(java.io.InputStream)
public int getReaderBufferSize()
setReaderBufferSize(int)
public void setReaderBufferSize(int readerBufferSize)
The default buffer size is large enough for most purposes.
readerBufferSize
- Size of this parser's character-stream-oriented input buffer.getReaderBufferSize()
|
XML Parser for Java 1.1.16 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |