public class XMLErrorReporter extends Object implements XMLComponent
http://apache.org/xml/properties/internal/error-reporter
Errors are separated into domains that categorize a class of errors.
In a parser configuration, the parser would register a
MessageFormatter
for each domain that is capable of
localizing error messages and formatting them based on information
about the error. Any parser component can invent new error domains
and register additional message formatters to localize messages in
those domains.
This component requires the following features and properties from the component manager that uses it:
This component can use the following features and properties but they are not required:
MessageFormatter
Modifier and Type | Field and Description |
---|---|
protected static String |
CONTINUE_AFTER_FATAL_ERROR
Feature identifier: continue after fatal error.
|
protected static String |
ERROR_HANDLER
Property identifier: error handler.
|
protected boolean |
fContinueAfterFatalError
Continue after fatal error feature.
|
protected XMLErrorHandler |
fDefaultErrorHandler
Default error handler.
|
protected XMLErrorHandler |
fErrorHandler
Error handler.
|
protected Locale |
fLocale
The locale to be used to format error messages.
|
protected XMLLocator |
fLocator
Document locator.
|
protected Hashtable |
fMessageFormatters
Mapping of Message formatters for domains.
|
static short |
SEVERITY_ERROR
Severity: error.
|
static short |
SEVERITY_FATAL_ERROR
Severity: fatal error.
|
static short |
SEVERITY_WARNING
Severity: warning.
|
Constructor and Description |
---|
XMLErrorReporter()
Constructs an error reporter with a locator.
|
Modifier and Type | Method and Description |
---|---|
XMLErrorHandler |
getErrorHandler()
Get the internal XMLErrrorHandler.
|
boolean |
getFeature(String featureId) |
Boolean |
getFeatureDefault(String featureId)
Returns the default state for a feature, or null if this
component does not want to report a default value for this
feature.
|
Locale |
getLocale()
Gets the current locale.
|
MessageFormatter |
getMessageFormatter(String domain)
Returns the message formatter associated with the specified domain,
or null if no message formatter is registered for that domain.
|
Object |
getPropertyDefault(String propertyId)
Returns the default state for a property, or null if this
component does not want to report a default value for this
property.
|
String[] |
getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by
this component.
|
String[] |
getRecognizedProperties()
Returns a list of property identifiers that are recognized by
this component.
|
ErrorHandler |
getSAXErrorHandler()
Gets the internal XMLErrorHandler
as SAX ErrorHandler.
|
void |
putMessageFormatter(String domain,
MessageFormatter messageFormatter)
Registers a message formatter for the specified domain.
|
MessageFormatter |
removeMessageFormatter(String domain)
Removes the message formatter for the specified domain and
returns the removed message formatter.
|
String |
reportError(String domain,
String key,
Object[] arguments,
short severity)
Reports an error.
|
String |
reportError(String domain,
String key,
Object[] arguments,
short severity,
Exception exception)
Reports an error.
|
String |
reportError(XMLLocator location,
String domain,
String key,
Object[] arguments,
short severity)
Reports an error at a specific location.
|
String |
reportError(XMLLocator location,
String domain,
String key,
Object[] arguments,
short severity,
Exception exception)
Reports an error at a specific location.
|
void |
reset(XMLComponentManager componentManager)
Resets the component.
|
void |
setDocumentLocator(XMLLocator locator)
Sets the document locator.
|
void |
setFeature(String featureId,
boolean state)
Sets the state of a feature.
|
void |
setLocale(Locale locale)
Sets the current locale.
|
void |
setProperty(String propertyId,
Object value)
Sets the value of a property.
|
public static final short SEVERITY_WARNING
public static final short SEVERITY_ERROR
public static final short SEVERITY_FATAL_ERROR
Note: The parser does have a "continue after fatal error" feature but it should be used with extreme caution and care.
protected static final String CONTINUE_AFTER_FATAL_ERROR
protected static final String ERROR_HANDLER
protected Locale fLocale
protected Hashtable fMessageFormatters
protected XMLErrorHandler fErrorHandler
protected XMLLocator fLocator
protected boolean fContinueAfterFatalError
protected XMLErrorHandler fDefaultErrorHandler
public XMLErrorReporter()
public void setLocale(Locale locale)
locale
- The new locale.public Locale getLocale()
public void setDocumentLocator(XMLLocator locator)
locator
- The locator.public void putMessageFormatter(String domain, MessageFormatter messageFormatter)
Note: Registering a message formatter for a domain when there is already a formatter registered will cause the previous formatter to be lost. This method replaces any previously registered message formatter for the specified domain.
domain
- messageFormatter
- public MessageFormatter getMessageFormatter(String domain)
domain
- The domain of the message formatter.public MessageFormatter removeMessageFormatter(String domain)
domain
- The domain of the message formatter.public String reportError(String domain, String key, Object[] arguments, short severity) throws XNIException
domain
- The error domain.key
- The key of the error message.arguments
- The replacement arguments for the error message,
if needed.severity
- The severity of the error.XNIException
SEVERITY_WARNING
,
SEVERITY_ERROR
,
SEVERITY_FATAL_ERROR
public String reportError(String domain, String key, Object[] arguments, short severity, Exception exception) throws XNIException
domain
- The error domain.key
- The key of the error message.arguments
- The replacement arguments for the error message,
if needed.severity
- The severity of the error.exception
- The exception to wrap.XNIException
SEVERITY_WARNING
,
SEVERITY_ERROR
,
SEVERITY_FATAL_ERROR
public String reportError(XMLLocator location, String domain, String key, Object[] arguments, short severity) throws XNIException
location
- The error location.domain
- The error domain.key
- The key of the error message.arguments
- The replacement arguments for the error message,
if needed.severity
- The severity of the error.XNIException
SEVERITY_WARNING
,
SEVERITY_ERROR
,
SEVERITY_FATAL_ERROR
public String reportError(XMLLocator location, String domain, String key, Object[] arguments, short severity, Exception exception) throws XNIException
location
- The error location.domain
- The error domain.key
- The key of the error message.arguments
- The replacement arguments for the error message,
if needed.severity
- The severity of the error.exception
- The exception to wrap.XNIException
SEVERITY_WARNING
,
SEVERITY_ERROR
,
SEVERITY_FATAL_ERROR
public void reset(XMLComponentManager componentManager) throws XNIException
reset
in interface XMLComponent
componentManager
- The component manager.SAXException
- Thrown by component on initialization error.
For example, if a feature or property is
required for the operation of the component, the
component manager may throw a
SAXNotRecognizedException or a
SAXNotSupportedException.XNIException
- Thrown by component on initialization error.public String[] getRecognizedFeatures()
getRecognizedFeatures
in interface XMLComponent
public void setFeature(String featureId, boolean state) throws XMLConfigurationException
Note: Components should silently ignore features that do not affect the operation of the component.
setFeature
in interface XMLComponent
featureId
- The feature identifier.state
- The state of the feature.SAXNotRecognizedException
- The component should not throw
this exception.SAXNotSupportedException
- The component should not throw
this exception.XMLConfigurationException
- Thrown for configuration error.
In general, components should
only throw this exception if
it is really
a critical error.public boolean getFeature(String featureId) throws XMLConfigurationException
XMLConfigurationException
public String[] getRecognizedProperties()
getRecognizedProperties
in interface XMLComponent
public void setProperty(String propertyId, Object value) throws XMLConfigurationException
Note: Components should silently ignore properties that do not affect the operation of the component.
setProperty
in interface XMLComponent
propertyId
- The property identifier.value
- The value of the property.SAXNotRecognizedException
- The component should not throw
this exception.SAXNotSupportedException
- The component should not throw
this exception.XMLConfigurationException
- Thrown for configuration error.
In general, components should
only throw this exception if
it is really
a critical error.public Boolean getFeatureDefault(String featureId)
getFeatureDefault
in interface XMLComponent
featureId
- The feature identifier.public Object getPropertyDefault(String propertyId)
getPropertyDefault
in interface XMLComponent
propertyId
- The property identifier.public XMLErrorHandler getErrorHandler()
public ErrorHandler getSAXErrorHandler()
Copyright © 2021 JBoss by Red Hat. All rights reserved.