Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.impl

public Class XMLErrorReporter

extends Object
implements XMLComponent
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xerces.internal.xni.parser.XMLComponent
Known Direct Subclasses
com.sun.xml.internal.stream.StaxErrorReporter
Imports
com.sun.org.apache.xerces.internal.util.DefaultErrorHandler, .ErrorHandlerProxy, .MessageFormatter, com.sun.org.apache.xerces.internal.xni.XMLLocator, .XNIException, com.sun.org.apache.xerces.internal.xni.parser.XMLComponent, .XMLComponentManager, .XMLConfigurationException, .XMLErrorHandler, .XMLParseException, java.util.HashMap, .Locale, .Map, org.xml.sax.ErrorHandler

This class is a common element of all parser configurations and is used to report errors that occur. This component can be queried by parser components from the component manager using the following property ID:
  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:

Authors
Eric Ye, IBM, Andy Clark, IBM
See Also
MessageFormatter

Field Summary

Modifier and TypeField and Description
protected static final String
CONTINUE_AFTER_FATAL_ERROR

Feature identifier: continue after fatal error.

protected static final String
ERROR_HANDLER

Property identifier: error handler.

protected boolean
fContinueAfterFatalError

Continue after fatal error feature.

protected XMLErrorHandler
fDefaultErrorHandler

Default error handler.

private static final Boolean[]
FEATURE_DEFAULTS

Feature defaults.

protected XMLErrorHandler
fErrorHandler

Error handler.

protected Locale
fLocale

The locale to be used to format error messages.

protected XMLLocator
fLocator

Document locator.

protected Map<String, MessageFormatter>
fMessageFormatters

Mapping of Message formatters for domains.

private ErrorHandler
fSaxProxy

A SAX proxy to the error handler contained in this error reporter.

private static final Object[]
PROPERTY_DEFAULTS

Property defaults.

private static final String[]
RECOGNIZED_FEATURES

Recognized features.

private static final String[]
RECOGNIZED_PROPERTIES

Recognized properties.

public static final short
SEVERITY_ERROR

Severity: error.

public static final short
SEVERITY_FATAL_ERROR

Severity: fatal error.

public static final short
SEVERITY_WARNING

Severity: warning.

Constructor Summary

AccessConstructor and Description
public
XMLErrorReporter()

Constructs an error reporter with a locator.

Method Summary

Modifier and TypeMethod and Description
public XMLErrorHandler
getErrorHandler()

Get the internal XMLErrrorHandler.

public boolean
getFeature(String featureId)

public Boolean
getFeatureDefault(String
The feature identifier.
featureId
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getFeatureDefault.

Returns the default state for a feature, or null if this component does not want to report a default value for this feature.

public Locale

Returns:

the current Locale
getLocale
()

Gets the current locale.

public MessageFormatter
getMessageFormatter(String
The domain of the message formatter.
domain
)

Returns the message formatter associated with the specified domain, or null if no message formatter is registered for that domain.

public Object
getPropertyDefault(String
The property identifier.
propertyId
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getPropertyDefault.

Returns the default state for a property, or null if this component does not want to report a default value for this property.

public String[]
getRecognizedFeatures()

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getRecognizedFeatures.

Returns a list of feature identifiers that are recognized by this component.

public String[]
getRecognizedProperties()

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getRecognizedProperties.

Returns a list of property identifiers that are recognized by this component.

public ErrorHandler
getSAXErrorHandler()

Gets the internal XMLErrorHandler as SAX ErrorHandler.

public void
putMessageFormatter(String domain, MessageFormatter messageFormatter)

Registers a message formatter for the specified domain.

public MessageFormatter
removeMessageFormatter(String
The domain of the message formatter.
domain
)

Removes the message formatter for the specified domain and returns the removed message formatter.

public String

Returns:

The formatted error message.
reportError
(String
The error domain.
domain
,
String
The key of the error message.
key
,
Object[]
The replacement arguments for the error message, if needed.
arguments
,
short
The severity of the error.
severity
)

Reports an error.

public String

Returns:

The formatted error message.
reportError
(String
The error domain.
domain
,
String
The key of the error message.
key
,
Object[]
The replacement arguments for the error message, if needed.
arguments
,
short
The severity of the error.
severity
,
Exception
The exception to wrap.
exception
)

Reports an error.

public String

Returns:

The formatted error message.
reportError
(XMLLocator
The error location.
location
,
String
The error domain.
domain
,
String
The key of the error message.
key
,
Object[]
The replacement arguments for the error message, if needed.
arguments
,
short
The severity of the error.
severity
)

Reports an error at a specific location.

public String

Returns:

The formatted error message.
reportError
(XMLLocator
The error location.
location
,
String
The error domain.
domain
,
String
The key of the error message.
key
,
Object[]
The replacement arguments for the error message, if needed.
arguments
,
short
The severity of the error.
severity
,
Exception
The exception to wrap.
exception
)

Reports an error at a specific location.

public void
reset(XMLComponentManager
The component manager.
componentManager
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.reset.

Resets the component.

public void
setDocumentLocator(XMLLocator
The locator.
locator
)

Sets the document locator.

public void
setFeature(String
The feature identifier.
featureId
,
boolean
The state of the feature.
state
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setFeature.

Sets the state of a feature.

public void
setLocale(Locale
The new locale.
locale
)

Sets the current locale.

public void
setProperty(String
The property identifier.
propertyId
,
Object
The value of the property.
value
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setProperty.

Sets the value of a property.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONTINUE_AFTER_FATAL_ERRORback to summary
protected static final String CONTINUE_AFTER_FATAL_ERROR

Feature identifier: continue after fatal error.

ERROR_HANDLERback to summary
protected static final String ERROR_HANDLER

Property identifier: error handler.

fContinueAfterFatalErrorback to summary
protected boolean fContinueAfterFatalError

Continue after fatal error feature.

fDefaultErrorHandlerback to summary
protected XMLErrorHandler fDefaultErrorHandler

Default error handler. This error handler is only used in the absence of a registered error handler so that errors are not "swallowed" silently. This is one of the most common "problems" reported by users of the parser.

FEATURE_DEFAULTSback to summary
private static final Boolean[] FEATURE_DEFAULTS

Feature defaults.

fErrorHandlerback to summary
protected XMLErrorHandler fErrorHandler

Error handler.

fLocaleback to summary
protected Locale fLocale

The locale to be used to format error messages.

fLocatorback to summary
protected XMLLocator fLocator

Document locator.

fMessageFormattersback to summary
protected Map<String, MessageFormatter> fMessageFormatters

Mapping of Message formatters for domains.

fSaxProxyback to summary
private ErrorHandler fSaxProxy

A SAX proxy to the error handler contained in this error reporter.

PROPERTY_DEFAULTSback to summary
private static final Object[] PROPERTY_DEFAULTS

Property defaults.

RECOGNIZED_FEATURESback to summary
private static final String[] RECOGNIZED_FEATURES

Recognized features.

RECOGNIZED_PROPERTIESback to summary
private static final String[] RECOGNIZED_PROPERTIES

Recognized properties.

SEVERITY_ERRORback to summary
public static final short SEVERITY_ERROR

Severity: error. Common causes of errors are document structure and/or content that that does not conform to the grammar rules specified for the document. These are typically validation errors.

SEVERITY_FATAL_ERRORback to summary
public static final short SEVERITY_FATAL_ERROR

Severity: fatal error. Fatal errors are errors in the syntax of the XML document or invalid byte sequences for a given encoding. The XML 1.0 Specification mandates that errors of this type are not recoverable.

Note

The parser does have a "continue after fatal error" feature but it should be used with extreme caution and care.

SEVERITY_WARNINGback to summary
public static final short SEVERITY_WARNING

Severity: warning. Warnings represent informational messages only that should not be considered serious enough to stop parsing or indicate an error in the document's validity.

Constructor Detail

XMLErrorReporterback to summary
public XMLErrorReporter()

Constructs an error reporter with a locator.

Method Detail

getErrorHandlerback to summary
public XMLErrorHandler getErrorHandler()

Get the internal XMLErrrorHandler.

getFeatureback to summary
public boolean getFeature(String featureId) throws XMLConfigurationException
getFeatureDefaultback to summary
public Boolean getFeatureDefault(String featureId)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getFeatureDefault.

Returns the default state for a feature, or null if this component does not want to report a default value for this feature.

Parameters
featureId:String

The feature identifier.

Since
Xerces 2.2.0
getLocaleback to summary
public Locale getLocale()

Gets the current locale.

Returns:Locale

the current Locale

getMessageFormatterback to summary
public MessageFormatter getMessageFormatter(String domain)

Returns the message formatter associated with the specified domain, or null if no message formatter is registered for that domain.

Parameters
domain:String

The domain of the message formatter.

getPropertyDefaultback to summary
public Object getPropertyDefault(String propertyId)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getPropertyDefault.

Returns the default state for a property, or null if this component does not want to report a default value for this property.

Parameters
propertyId:String

The property identifier.

Since
Xerces 2.2.0
getRecognizedFeaturesback to summary
public String[] getRecognizedFeatures()

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getRecognizedFeatures.

Returns a list of feature identifiers that are recognized by this component. This method may return null if no features are recognized by this component.

getRecognizedPropertiesback to summary
public String[] getRecognizedProperties()

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getRecognizedProperties.

Returns a list of property identifiers that are recognized by this component. This method may return null if no properties are recognized by this component.

getSAXErrorHandlerback to summary
public ErrorHandler getSAXErrorHandler()

Gets the internal XMLErrorHandler as SAX ErrorHandler.

putMessageFormatterback to summary
public void putMessageFormatter(String domain, MessageFormatter messageFormatter)

Registers a message formatter for the specified domain.

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.

removeMessageFormatterback to summary
public MessageFormatter removeMessageFormatter(String domain)

Removes the message formatter for the specified domain and returns the removed message formatter.

Parameters
domain:String

The domain of the message formatter.

reportErrorback to summary
public String reportError(String domain, String key, Object[] arguments, short severity) throws XNIException

Reports an error. The error message passed to the error handler is formatted for the locale by the message formatter installed for the specified error domain.

Parameters
domain:String

The error domain.

key:String

The key of the error message.

arguments:Object[]

The replacement arguments for the error message, if needed.

severity:short

The severity of the error.

Returns:String

The formatted error message.

See Also
SEVERITY_WARNING, SEVERITY_ERROR, SEVERITY_FATAL_ERROR
reportErrorback to summary
public String reportError(String domain, String key, Object[] arguments, short severity, Exception exception) throws XNIException

Reports an error. The error message passed to the error handler is formatted for the locale by the message formatter installed for the specified error domain.

Parameters
domain:String

The error domain.

key:String

The key of the error message.

arguments:Object[]

The replacement arguments for the error message, if needed.

severity:short

The severity of the error.

exception:Exception

The exception to wrap.

Returns:String

The formatted error message.

See Also
SEVERITY_WARNING, SEVERITY_ERROR, SEVERITY_FATAL_ERROR
reportErrorback to summary
public String reportError(XMLLocator location, String domain, String key, Object[] arguments, short severity) throws XNIException

Reports an error at a specific location.

Parameters
location:XMLLocator

The error location.

domain:String

The error domain.

key:String

The key of the error message.

arguments:Object[]

The replacement arguments for the error message, if needed.

severity:short

The severity of the error.

Returns:String

The formatted error message.

See Also
SEVERITY_WARNING, SEVERITY_ERROR, SEVERITY_FATAL_ERROR
reportErrorback to summary
public String reportError(XMLLocator location, String domain, String key, Object[] arguments, short severity, Exception exception) throws XNIException

Reports an error at a specific location.

Parameters
location:XMLLocator

The error location.

domain:String

The error domain.

key:String

The key of the error message.

arguments:Object[]

The replacement arguments for the error message, if needed.

severity:short

The severity of the error.

exception:Exception

The exception to wrap.

Returns:String

The formatted error message.

See Also
SEVERITY_WARNING, SEVERITY_ERROR, SEVERITY_FATAL_ERROR
resetback to summary
public void reset(XMLComponentManager componentManager) throws XNIException

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.reset.

Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.

Parameters
componentManager:XMLComponentManager

The component manager.

Exceptions
XNIException:

Doc from com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.reset.

Thrown by component on initialization error.

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.
setDocumentLocatorback to summary
public void setDocumentLocator(XMLLocator locator)

Sets the document locator.

Parameters
locator:XMLLocator

The locator.

setFeatureback to summary
public void setFeature(String featureId, boolean state) throws XMLConfigurationException

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setFeature.

Sets the state of a feature. This method is called by the component manager any time after reset when a feature changes state.

Note

Components should silently ignore features that do not affect the operation of the component.

Parameters
featureId:String

The feature identifier.

state:boolean

The state of the feature.

Exceptions
XMLConfigurationException:

Doc from com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setFeature.

Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

SAXNotRecognizedException:
The component should not throw this exception.
SAXNotSupportedException:
The component should not throw this exception.
setLocaleback to summary
public void setLocale(Locale locale)

Sets the current locale.

Parameters
locale:Locale

The new locale.

setPropertyback to summary
public void setProperty(String propertyId, Object value) throws XMLConfigurationException

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setProperty.

Sets the value of a property. This method is called by the component manager any time after reset when a property changes value.

Note

Components should silently ignore properties that do not affect the operation of the component.

Parameters
propertyId:String

The property identifier.

value:Object

The value of the property.

Exceptions
XMLConfigurationException:

Doc from com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setProperty.

Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

SAXNotRecognizedException:
The component should not throw this exception.
SAXNotSupportedException:
The component should not throw this exception.