|
XML for Java Compatibility API 2.0.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.xml.framework.XMLParser | +--com.ibm.xml.parsers.NonValidatingTXDOMParser | +--com.ibm.xml.parsers.TXDOMParser | +--com.ibm.xml.parser.Parser
This parser provides a backward compatibile API on top of the new parser architecture. This parser should behave the same as the old parser, with the exceptions listed below.
Users of this parser instance should not call any functions in the new parser architecture. Calling methods outside of the old parser API can have unexpected results.
Users who are moving to the new parser architecture but want to use the catalog file format supported by the old parser should use the com.ibm.xml.internal.TXCatalog class.
Not supported: Calling these methods will throw java.lang.IllegalArgumentException.
Not implemented: These methods are present but should not be expected to function the same as in the old parser.
TXCatalog
Fields inherited from class com.ibm.xml.parsers.NonValidatingTXDOMParser |
DEBUG,
fCurrentNode,
fCurrentParent,
fDocument,
fDocumentClass,
fDocumentType,
fEntityPool,
fExpandEntityReferences,
fNodeStack,
fNormalizeTextNodes,
fRootElementName,
fWithinElement |
Fields inherited from class com.ibm.xml.framework.XMLParser |
fLocale,
fNeedReset,
fParseInProgress,
fResourceBundle,
fScanner |
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 handler)
Register a handler for receiving control when ANY element tag is recognized by this parser. |
void |
addElementHandler(ElementHandler handler,
java.lang.String elementName)
Register a handler for receiving control when the specified elementTagName element tag is recognized by this parser. |
void |
addNoRequiredAttributeHandler(NoRequiredAttributeHandler handler)
This method is not supported. Register a handler for receiving control when a "no required attribute" event is recognized by this parser. |
void |
addPIHandler(PIHandler handler)
Register a handler for receiving control when PIs are recognized by this parser. |
void |
addPreRootHandler(PreRootHandler handler)
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()
This method is not supported. Returns the size of this parser's character-stream-oriented input source buffer. |
protected void |
handleError(java.lang.String errorKey,
java.lang.String errorMsg)
This method is the basic error handler. |
void |
loadCatalog(java.io.Reader reader)
Loads a catalog which provides mapping between public IDs and system IDs. |
void |
parseDTD(org.xml.sax.InputSource source)
Parses the specified input source. |
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 |
reset()
This method is not part of the Parser API and is called automatically by the parser internals. Resets the parser between calls to parse. |
void |
setAllowJavaEncodingName(boolean allow)
Sets whether this parser allows Java encoding names to be specified in place of MIME charset names on xmlEncoding parameters. |
void |
setElementFactory(TXDocument factory)
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 end)
Sets whether this parser terminates processing when an initial error or exception occurs. |
void |
setErrorNoByteMark(boolean error)
This method is not supported. 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 expand)
Sets whether EntityReference Nodes are expanded by this parser. |
void |
setKeepComment(boolean keep)
Sets whether TXComment Nodes are created by this
parser when XML comments are encountered. |
void |
setPreserveSpace(boolean preserve)
This method is not supported. Sets, at the document level, whether space is to be preserved in the parsed document. |
void |
setProcessExternalDTD(boolean process)
This method is not implemented. Sets whether this parser reads an external subset of DTD, pointed in an ExternalID in DOCTYPE declaration. |
void |
setProcessNamespace(boolean process)
Sets whether namespaces are respected by this parser. |
void |
setReaderBufferSize(int size)
This method is not supported. Sets the size of this parser's character-stream-oriented input source buffer. |
void |
setReferenceHandler(ReferenceHandler handler)
Register a handler for receiving control when a General Reference is recognized by this parser. |
void |
setTagHandler(TagHandler handler)
Register a handler for receiving control when tag start and tag end events are recognized by this parser. |
void |
setWarningNoDoctypeDecl(boolean warning)
This method is not implemented. Sets whether this parser treats a missing DTD declaration as a warning, and reports this condition through the defined ErrorListener. |
void |
setWarningNoXMLDecl(boolean warning)
This method is not implemented. Sets whether this parser treats a missing XML prolog PIs as a warning, and reports this condition through the defined ErrorListener. |
void |
setWarningRedefinedEntity(boolean warning)
This method is not implemented. 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 com.ibm.xml.parsers.TXDOMParser |
resetOrCopy |
Methods inherited from class com.ibm.xml.parsers.NonValidatingTXDOMParser |
attlistDecl,
buildCMNode,
characters,
characters,
checkHandlers,
comment,
doctypeDecl,
elementDecl,
endDocument,
endElement,
endEntityReference,
endExternalSubset,
endInternalSubset,
externalEntityDecl,
getDocument,
getExpandEntityReferences,
ignorableWhitespace,
ignorableWhitespace,
init,
internalEntityDecl,
notationDecl,
parameterEntityDecl,
processingInstruction,
setDocumentClass,
setNormalizeTextNodes,
startDocument,
startElement,
startEntityReference,
startExternalSubset,
startInternalSubset,
unparsedEntityDecl |
Methods inherited from class com.ibm.xml.framework.XMLParser |
error,
error1,
error2,
error3,
error4,
errorHandlingEnabled,
getAllowJavaEncodingName,
getCheckNamespace,
getContinueAfterFatalError,
getDocumentHandler,
getDocumentTypeHandler,
getEntityHandler,
getErrorHandler,
getErrorMsgString,
getLocator,
getParserState,
getScanner,
getValidationHandler,
getWarningOnDuplicateAttDef,
isFatal,
isWarning,
loadCatalog,
parse,
parse,
sendCharDataAsCharArray,
setCheckNamespace,
setContinueAfterFatalError,
setDocumentHandler,
setDocumentHandler,
setDocumentTypeHandler,
setDTDHandler,
setEntityHandler,
setEntityResolver,
setErrorHandler,
setLocale,
setValidationHandler,
setWarningOnDuplicateAttDef,
useDefaultValidationHandler |
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)
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)
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 setElementFactory(TXDocument factory)
By default, an instance of TXDocument is used.
factory
- 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
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)
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 handler)
By default, no tag handler is registered to this parser.
handler
- Handler to be registered.TagHandler
public void setReferenceHandler(ReferenceHandler handler)
By default, no reference handler is registered to this parser.
handler
- Handler to be registered.ReferenceHandler
public void addPreRootHandler(PreRootHandler handler)
By default, no preroot handlers are registered to this parser.
handler
- Handler to be registered.PreRootHandler
public void addPIHandler(PIHandler handler)
By default, no PI handlers are registered to this parser.
handler
- Handler to be registered.PIHandler
public void addElementHandler(ElementHandler handler)
By default, no element handlers are registered to this parser.
handler
- Handler to be registered.ElementHandler
public void addElementHandler(ElementHandler handler, java.lang.String elementName)
By default, no element handlers are registered to this parser.
handler
- Handler to be registered for the specified
elementName.elementName
- 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 int getNumberOfErrors()
ErrorListener
public int getNumberOfWarnings()
ErrorListener
public void setKeepComment(boolean keep)
TXComment
Nodes are created by this
parser when XML comments are encountered.
By default, TXComment Nodes are created by this parser.
keep
- =true
means maintain parsed comments;
=false
means drop comments when creating
object tree.TXComment
public void setExpandEntityReferences(boolean expand)
By default, EntityReference Nodes are kept.
keep
- =true
means expanding entity references;
=false
means maintain entity references.EntityReference
,
GeneralReference
public void setProcessExternalDTD(boolean process)
Sets whether this parser reads an external subset of DTD, pointed in an ExternalID in DOCTYPE declaration.
By default, this parser reads an external subset of DTD.
process
- =true
means process an external DTD;
=false
means ignore an external DTD.DTD
public void setProcessNamespace(boolean process)
By default, namespaces are NOT respected by this parser.
process
- =true
means parse for namespaces;
=false
means ignore namespaces when
parsing.Namespace
,
TXElement
,
TXAttribute
public void setAllowJavaEncodingName(boolean allow)
By default, Java encoding names are NOT allowed on xmlEncoding parameters by this parser.
allow
- =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 setPreserveSpace(boolean preserve)
Sets, at the document level, whether space is to be preserved
in the parsed document. Regardless of the value of
isPreserveSpace, this parser will preserve whitespace.
This value is used, for example, to determine if space is to be
preserved in Text Nodes during printWithFormat() operations. Note
that the document-level value will be overridden at the Node level
if this parser recognizes a xml:space
attribute.
By default, space is not to be preserved in the parsed document.
preserve
- =true
space is to be preserved;
=false
space is to be ignored.public void setEndBy1stError(boolean end)
By default, this parser stops parsing after an error occurs, as required by the XML specification.
end
- =true
means initial error or exception ends
processing;
=false
means processing continues until the
document is fully parsed.public TXDocument readStream(java.io.InputStream inputStream)
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)
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)
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 final void parseDTD(org.xml.sax.InputSource source) throws org.xml.sax.SAXException, java.io.IOException
source
- The input source.public void addNoRequiredAttributeHandler(NoRequiredAttributeHandler handler)
Register a handler for receiving control when a "no required attribute" event is recognized by this parser. A "no required attribute" event occurs when an Element is parsed and a required Attribute for this Element is not seen; Attributes are declared as required as part of the internal and/or external DTD declaration of the XML document.
By default, no required attribute handlers are registered to this parser.
handler
- Handler to be registered.NoRequiredAttributeHandler
public void setErrorNoByteMark(boolean error)
Sets whether this parser treats missing byte marks in the input stream as an error, and reports this condition through the defined ErrorListener.
By default, this condition is reported by this parser as an error.
error
- =true
means report condition as an error;
=false
means ignore this condition.public int getReaderBufferSize()
Returns the size of this parser's character-stream-oriented input source buffer. Characters are buffered during I/O in order to provide efficient reading. This method has no meaning for byte-stream-oriented input sources.
setReaderBufferSize(int)
public void setReaderBufferSize(int size)
Sets the size of this parser's character-stream-oriented input source buffer. Characters are buffered during I/O in order to provide efficient reading. This method has no meaning for byte-stream-oriented input sources.
The default buffer size is large enough for most purposes.
size
- Size of this parser's character-stream-oriented input
buffer.getReaderBufferSize()
public void setWarningRedefinedEntity(boolean warning)
Sets whether this parser treats redefined entities as a warning, and reports this condition through the defined ErrorListener.
By default, this condition is reported by this parser as a warning.
warning
- =true
means report condition as a
warning.
=false
means ignore this condition.EntityDecl
public void setWarningNoXMLDecl(boolean warning)
Sets whether this parser treats a missing XML prolog PIs as a warning, and reports this condition through the defined ErrorListener.
By default, this condition is reported by this parser as a warning.
warning
- =true
means report condition as a
warning;
=false
means ignore this condition.TXPI
public void setWarningNoDoctypeDecl(boolean warning)
Sets whether this parser treats a missing DTD declaration as a warning, and reports this condition through the defined ErrorListener.
By default, this condition is NOT reported by this parser as a warning.
warning
- =true
means report condition as a
warning;
=false
means ignore this condition.DTD
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.
protected void handleError(java.lang.String errorKey, java.lang.String errorMsg) throws java.lang.Exception
public void reset()
Resets the parser between calls to parse.
|
XML for Java Compatibility API 2.0.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |