com.ibm.xml.framework
Class XMLParser
java.lang.Object
|
+--com.ibm.xml.framework.XMLParser
- Direct Known Subclasses:
- NonValidatingDOMParser, NonValidatingParser, NonValidatingTXDOMParser, SAXParser
- public abstract class XMLParser
- extends java.lang.Object
- implements Parser, XMLDocumentTypeHandler, XMLDocumentHandler, XMLErrorHandler
This is the base class of all parsers.
This class implements the Parser
interface. The application can use
the ParserFactory
class to construct a parser from a class name.
This class implements the XMLDocumentTypeHandler
, XMLDocumentHandler
,
and XMLErrorHandler
interfaces. This is provided as a convenience to parser
subclasses so that they can implement these interfaces directly in the subclass instead of
needing a separate class.
- Version:
- Revision: 51 1.15 src/com/ibm/xml/framework/XMLParser.java, parser, xml4j2, xml4j2_0_15
- See Also:
XMLParser
,
InputSource
,
Locator
Constructor Summary |
protected |
XMLParser()
Constructor |
Method Summary |
protected void |
checkHandlers()
|
void |
error(int errorCode)
|
void |
error1(int errorCode,
int stringIndex1)
|
void |
error2(int errorCode,
int stringIndex1,
int stringIndex2)
|
void |
error3(int errorCode,
int stringIndex1,
int stringIndex2,
int stringIndex3)
|
void |
error4(int errorCode,
int stringIndex1,
int stringIndex2,
int stringIndex3,
int stringIndex4)
|
protected boolean |
errorHandlingEnabled()
|
boolean |
getAllowJavaEncodingName()
|
boolean |
getCheckNamespace()
|
boolean |
getContinueAfterFatalError()
|
XMLDocumentHandler |
getDocumentHandler()
|
XMLDocumentTypeHandler |
getDocumentTypeHandler()
|
XMLEntityHandler |
getEntityHandler()
|
XMLErrorHandler |
getErrorHandler()
|
protected java.lang.String |
getErrorMsgString(java.lang.String errorKey,
java.lang.Object[] errorArgs)
|
protected Locator |
getLocator()
Return the Locator object. |
ParserState |
getParserState()
|
XMLScanner |
getScanner()
|
XMLValidationHandler |
getValidationHandler()
|
boolean |
getWarningOnDuplicateAttDef()
|
protected void |
handleError(java.lang.String errorKey,
java.lang.String errorMsg)
|
protected boolean |
isFatal(java.lang.String errorKey)
|
protected boolean |
isWarning(java.lang.String errorKey)
|
void |
loadCatalog(InputSource source)
Loads the catalog stream specified by the given input source and
appends the contents to the catalog. |
void |
parse(InputSource source)
Parses the specified input source. |
void |
parse(java.lang.String systemId)
Parses the input source specified by the given system identifier. |
void |
reset()
|
protected void |
resetOrCopy()
|
boolean |
sendCharDataAsCharArray()
The default for XMLDocumentHandler is to use the StringPool to pass CharData, not char arrays. |
void |
setAllowJavaEncodingName(boolean flag)
|
void |
setCheckNamespace(boolean flag)
|
void |
setContinueAfterFatalError(boolean flag)
|
void |
setDocumentHandler(DocumentHandler handler)
|
protected void |
setDocumentHandler(XMLDocumentHandler handler)
|
protected void |
setDocumentTypeHandler(XMLDocumentTypeHandler handler)
|
void |
setDTDHandler(DTDHandler handler)
|
protected void |
setEntityHandler(XMLEntityHandler handler)
|
void |
setEntityResolver(EntityResolver resolver)
|
void |
setErrorHandler(ErrorHandler handler)
|
void |
setLocale(java.util.Locale locale)
Set the locale to use for messages. |
protected void |
setValidationHandler(XMLValidationHandler handler)
|
void |
setWarningOnDuplicateAttDef(boolean flag)
|
protected void |
useDefaultValidationHandler()
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
fScanner
protected XMLScanner fScanner
fLocale
protected java.util.Locale fLocale
fResourceBundle
protected java.util.ResourceBundle fResourceBundle
fParseInProgress
protected boolean fParseInProgress
fNeedReset
protected boolean fNeedReset
XMLParser
protected XMLParser()
- Constructor
reset
public void reset()
resetOrCopy
protected void resetOrCopy()
checkHandlers
protected void checkHandlers()
throws java.lang.Exception
getParserState
public ParserState getParserState()
getScanner
public XMLScanner getScanner()
getLocator
protected Locator getLocator()
- Return the
Locator
object.
- Returns:
- The locator.
setAllowJavaEncodingName
public void setAllowJavaEncodingName(boolean flag)
getAllowJavaEncodingName
public boolean getAllowJavaEncodingName()
setWarningOnDuplicateAttDef
public void setWarningOnDuplicateAttDef(boolean flag)
getWarningOnDuplicateAttDef
public boolean getWarningOnDuplicateAttDef()
setCheckNamespace
public void setCheckNamespace(boolean flag)
getCheckNamespace
public boolean getCheckNamespace()
setContinueAfterFatalError
public void setContinueAfterFatalError(boolean flag)
getContinueAfterFatalError
public boolean getContinueAfterFatalError()
setDocumentHandler
protected void setDocumentHandler(XMLDocumentHandler handler)
getDocumentHandler
public XMLDocumentHandler getDocumentHandler()
setDocumentTypeHandler
protected void setDocumentTypeHandler(XMLDocumentTypeHandler handler)
getDocumentTypeHandler
public XMLDocumentTypeHandler getDocumentTypeHandler()
setEntityHandler
protected void setEntityHandler(XMLEntityHandler handler)
getEntityHandler
public XMLEntityHandler getEntityHandler()
getErrorHandler
public XMLErrorHandler getErrorHandler()
setValidationHandler
protected void setValidationHandler(XMLValidationHandler handler)
getValidationHandler
public XMLValidationHandler getValidationHandler()
useDefaultValidationHandler
protected void useDefaultValidationHandler()
loadCatalog
public void loadCatalog(InputSource source)
throws java.lang.Exception
- Loads the catalog stream specified by the given input source and
appends the contents to the catalog.
- Parameters:
source
- The catalog source.- Throws:
- java.lang.Exception - Throws an exception if an error
occurs while loading the catalog source.
setLocale
public final void setLocale(java.util.Locale locale)
throws SAXException
- Set the locale to use for messages.
This method is part of the
Parser
interface.
- Specified by:
- setLocale in interface Parser
- Parameters:
locale
- The locale object to use for localization of messages.- Throws:
- SAXException - An exception thrown if the parser
does not support the specified locale.
- See Also:
Parser
setEntityResolver
public void setEntityResolver(EntityResolver resolver)
- Specified by:
- setEntityResolver in interface Parser
setDTDHandler
public void setDTDHandler(DTDHandler handler)
- Specified by:
- setDTDHandler in interface Parser
setDocumentHandler
public void setDocumentHandler(DocumentHandler handler)
- Specified by:
- setDocumentHandler in interface Parser
setErrorHandler
public void setErrorHandler(ErrorHandler handler)
- Specified by:
- setErrorHandler in interface Parser
parse
public void parse(InputSource source)
throws SAXException,
java.io.IOException
- Parses the specified input source.
- Specified by:
- parse in interface Parser
- Parameters:
source
- The input source.- Throws:
- SAXException - Throws exception on SAX error.
- java.io.IOException - Throws exception on i/o error.
parse
public void parse(java.lang.String systemId)
throws SAXException,
java.io.IOException
- Parses the input source specified by the given system identifier.
This method is equivalent to the following:
parse(new InputSource(systemId));
- Specified by:
- parse in interface Parser
- Parameters:
source
- The input source.- Throws:
- SAXException - Throws exception on SAX error.
- java.io.IOException - Throws exception on i/o error.
sendCharDataAsCharArray
public boolean sendCharDataAsCharArray()
- The default for XMLDocumentHandler is to use the StringPool to pass CharData, not char arrays.
- Specified by:
- sendCharDataAsCharArray in interface XMLDocumentHandler
errorHandlingEnabled
protected boolean errorHandlingEnabled()
handleError
protected void handleError(java.lang.String errorKey,
java.lang.String errorMsg)
throws java.lang.Exception
getErrorMsgString
protected final java.lang.String getErrorMsgString(java.lang.String errorKey,
java.lang.Object[] errorArgs)
isWarning
protected final boolean isWarning(java.lang.String errorKey)
isFatal
protected final boolean isFatal(java.lang.String errorKey)
error
public final void error(int errorCode)
throws java.lang.Exception
- Specified by:
- error in interface XMLErrorHandler
error1
public final void error1(int errorCode,
int stringIndex1)
throws java.lang.Exception
- Specified by:
- error1 in interface XMLErrorHandler
error2
public final void error2(int errorCode,
int stringIndex1,
int stringIndex2)
throws java.lang.Exception
- Specified by:
- error2 in interface XMLErrorHandler
error3
public final void error3(int errorCode,
int stringIndex1,
int stringIndex2,
int stringIndex3)
throws java.lang.Exception
- Specified by:
- error3 in interface XMLErrorHandler
error4
public final void error4(int errorCode,
int stringIndex1,
int stringIndex2,
int stringIndex3,
int stringIndex4)
throws java.lang.Exception
- Specified by:
- error4 in interface XMLErrorHandler