org.apache.woden.internal
Class ErrorReporterImpl

java.lang.Object
  extended by org.apache.woden.internal.ErrorReporterImpl
All Implemented Interfaces:
ErrorReporter

public class ErrorReporterImpl
extends java.lang.Object
implements ErrorReporter

This class reports errors that occur while parsing, validating or manipulating WSDL descriptions, such as XML parser errors or violations of the rules defined in the WSDL specification. That is, errors that relate specifically to the WSDL. It does not report system runtime or configuration errors, which are instead treated as exceptions.

There are four ways to report an error:

An error id and an array of message arguments are used to produce a formatted error message from some parameterized message text. The error may be reported with an target exception or without one.

An error id is specified with some ready-formatted message text. The error may be reported with an target exception or without one.

The error is handled according to the severity level (warning, error or fatal error) reported with the error.

The error reporter supports the 'en' (English) locale by default and has a default error handler (i.e. a default implementation of ErrorHandler). However, a different locale may be configured via setLocale and a custom error handler implementation may be configured as a system property.

Author:
jkaputin@apache.org

Field Summary
protected static java.lang.String CONTINUE_AFTER_FATAL_ERROR
           
protected static java.lang.String ERROR_HANDLER_NAME
           
protected static java.lang.String LOCALE_LANGUAGE
           
 
Fields inherited from interface org.apache.woden.ErrorReporter
SEVERITY_ERROR, SEVERITY_FATAL_ERROR, SEVERITY_WARNING
 
Constructor Summary
ErrorReporterImpl()
           
 
Method Summary
 ErrorHandler getErrorHandler()
          Return the custom error handler if one has been set, otherwise return the default error handler.
 java.lang.String getFormattedMessage(java.lang.String key, java.lang.Object[] arguments)
          Returns a formatted message string for the specified message key and arguments.
 java.util.Locale getLocale()
           
 void reportError(ErrorLocator errLoc, java.lang.String errorId, java.lang.Object[] arguments, short severity)
          Insert the message arguments into a parameterized message identified by errorId to produce a formatted error message, then report the message and the error location in the document according to the severity.
 void reportError(ErrorLocator errLoc, java.lang.String errorId, java.lang.Object[] arguments, short severity, java.lang.Exception exception)
          Insert the message arguments into a parameterized message identified by errorId to produce a formatted error message, then report the message and the error location in the document according to the severity.
 void reportError(ErrorLocator errLoc, java.lang.String errorId, java.lang.String message, short severity)
          Report the message and the error location in the document according to the severity.
 void reportError(ErrorLocator errLoc, java.lang.String errorId, java.lang.String message, short severity, java.lang.Exception exception)
          Report the message and the error location in the document according to the severity.
 void setErrorHandler(ErrorHandler errorHandler)
          Set a custom error handler on this error reporter to replace the default error handler.
 void setLocale(java.util.Locale locale)
          Set the Locale used for localization of error messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALE_LANGUAGE

protected static final java.lang.String LOCALE_LANGUAGE
See Also:
Constant Field Values

ERROR_HANDLER_NAME

protected static final java.lang.String ERROR_HANDLER_NAME
See Also:
Constant Field Values

CONTINUE_AFTER_FATAL_ERROR

protected static final java.lang.String CONTINUE_AFTER_FATAL_ERROR
See Also:
Constant Field Values
Constructor Detail

ErrorReporterImpl

public ErrorReporterImpl()
                  throws WSDLException
Throws:
WSDLException
Method Detail

reportError

public void reportError(ErrorLocator errLoc,
                        java.lang.String errorId,
                        java.lang.Object[] arguments,
                        short severity)
                 throws WSDLException
Description copied from interface: ErrorReporter
Insert the message arguments into a parameterized message identified by errorId to produce a formatted error message, then report the message and the error location in the document according to the severity.

Specified by:
reportError in interface ErrorReporter
Parameters:
errLoc - ErrorLocator showing the location of the error in the document.
errorId - String that identifies the message for this error.
arguments - Object[] with values to be inserted into the message text.
severity - a short indicating warning, error or fatal error.
Throws:
WSDLException - if the severity is fatal error

reportError

public void reportError(ErrorLocator errLoc,
                        java.lang.String errorId,
                        java.lang.Object[] arguments,
                        short severity,
                        java.lang.Exception exception)
                 throws WSDLException
Description copied from interface: ErrorReporter
Insert the message arguments into a parameterized message identified by errorId to produce a formatted error message, then report the message and the error location in the document according to the severity. Also report the exception that caused this error.

Specified by:
reportError in interface ErrorReporter
Parameters:
errLoc - ErrorLocator showing the location of the error in the document.
errorId - String that identifies the message for this error.
arguments - Object[] with values to be inserted into the message text.
severity - a short indicating warning, error or fatal error.
exception - the Exception that caused this error
Throws:
WSDLException - if the severity is fatal error

reportError

public void reportError(ErrorLocator errLoc,
                        java.lang.String errorId,
                        java.lang.String message,
                        short severity)
                 throws WSDLException
Description copied from interface: ErrorReporter
Report the message and the error location in the document according to the severity.

Specified by:
reportError in interface ErrorReporter
Parameters:
errLoc - ErrorLocator showing the location of the error in the document.
errorId - String that identifies the message for this error.
message - message text.
severity - a short indicating warning, error or fatal error.
Throws:
WSDLException - if the severity is fatal error

reportError

public void reportError(ErrorLocator errLoc,
                        java.lang.String errorId,
                        java.lang.String message,
                        short severity,
                        java.lang.Exception exception)
                 throws WSDLException
Description copied from interface: ErrorReporter
Report the message and the error location in the document according to the severity. Also report the exception that caused this error.

Specified by:
reportError in interface ErrorReporter
Parameters:
errLoc - ErrorLocator showing the location of the error in the document.
errorId - String that identifies the message for this error.
message - message text.
severity - a short indicating warning, error or fatal error.
exception - the Exception that caused this error
Throws:
WSDLException - if the severity is fatal error

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
Description copied from interface: ErrorReporter
Set a custom error handler on this error reporter to replace the default error handler. TODO: identify all use cases for setting the error handler and determine how best to expose this on the API. Currently, just via WSDLReader.setLocale which supports the 'read wsdl' use case, but others may include 'modify wsdl', 'create wsdl programmatically' and maybe 'write wsdl'.

Specified by:
setErrorHandler in interface ErrorReporter
Parameters:
errorHandler - the custom error handler

getErrorHandler

public ErrorHandler getErrorHandler()
Description copied from interface: ErrorReporter
Return the custom error handler if one has been set, otherwise return the default error handler.

Specified by:
getErrorHandler in interface ErrorReporter
Returns:
the ErrorHandler used by this error reporter

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: ErrorReporter
Set the Locale used for localization of error messages. TODO: identify all use cases for setting the locale and determine how best to expose this on the API. Currently, just via WSDLReader.setLocale which supports the 'read wsdl' use case, but others may include 'modify wsdl', 'create wsdl programmatically' and maybe 'write wsdl'.

Specified by:
setLocale in interface ErrorReporter
Parameters:
locale - the required locale

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface ErrorReporter
Returns:
the Locale used for localization of error messages.

getFormattedMessage

public java.lang.String getFormattedMessage(java.lang.String key,
                                            java.lang.Object[] arguments)
Description copied from interface: ErrorReporter
Returns a formatted message string for the specified message key and arguments. Used for formatting messages that will not be reported by the error reporter as parsing errors (via the reportError method). Typically these types of messages will be for configuration or runtime errors that will be thrown as exceptions by the caller.

Specified by:
getFormattedMessage in interface ErrorReporter
Parameters:
key - a String representing the message key
arguments - an Object array of message parameters
Returns:
the formatted message string


Copyright © 2007. All Rights Reserved.