Class StandardErrorListener
- All Implemented Interfaces:
Serializable
,ErrorListener
- Author:
- Michael H. Kay
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
abbreviatePath
(String uri) Abbreviate a URI (if requested)void
error
(TransformerException exception) Receive notification of a recoverable error.void
fatalError
(TransformerException exception) Receive notification of a non-recoverable error.Get the error output streamstatic String
Get a string containing the message for this exception and all contained exceptionsGet a string identifying the location of an error.int
Get the recovery policymakeAnother
(int hostLanguage) Make a clean copy of this ErrorListener.static void
printStackTrace
(PrintStream out, XPathContext context) Print a stack trace to a specified output destinationvoid
setErrorOutput
(PrintStream writer) Set output destination for error messages (default is System.err)void
setRecoveryPolicy
(int policy) Set the recovery policyvoid
warning
(TransformerException exception) Receive notification of a warning.
-
Field Details
-
errorOutput
-
-
Constructor Details
-
StandardErrorListener
public StandardErrorListener()Create a Standard Error Listener
-
-
Method Details
-
makeAnother
Make a clean copy of this ErrorListener. This is necessary because the standard error listener is stateful (it remembers how many errors there have been)- Parameters:
hostLanguage
- the host language (not used by this implementation)- Returns:
- a copy of this error listener
-
setErrorOutput
Set output destination for error messages (default is System.err)- Parameters:
writer
- The PrintStream to use for error messages
-
getErrorOutput
Get the error output stream- Returns:
- the error output stream
-
setRecoveryPolicy
public void setRecoveryPolicy(int policy) Set the recovery policy- Parameters:
policy
- the recovery policy for XSLT recoverable errors. One ofConfiguration.RECOVER_SILENTLY
,Configuration.RECOVER_WITH_WARNINGS
,Configuration.DO_NOT_RECOVER
.
-
getRecoveryPolicy
public int getRecoveryPolicy()Get the recovery policy- Returns:
- the recovery policy for XSLT recoverable errors. One of
Configuration.RECOVER_SILENTLY
,Configuration.RECOVER_WITH_WARNINGS
,Configuration.DO_NOT_RECOVER
.
-
warning
Receive notification of a warning.Transformers can use this method to report conditions that are not errors or fatal errors. The default behaviour is to take no action.
After invoking this method, the Transformer must continue with the transformation. It should still be possible for the application to process the document through to the end.
- Specified by:
warning
in interfaceErrorListener
- Parameters:
exception
- The warning information encapsulated in a transformer exception.- Throws:
TransformerException
- if the application chooses to discontinue the transformation.- See Also:
-
error
Receive notification of a recoverable error.The transformer must continue to provide normal parsing events after invoking this method. It should still be possible for the application to process the document through to the end.
The action of the standard error listener depends on the recovery policy that has been set, which may be one of RECOVER_SILENTLY, RECOVER_WITH_WARNING, or DO_NOT_RECOVER
- Specified by:
error
in interfaceErrorListener
- Parameters:
exception
- The error information encapsulated in a transformer exception.- Throws:
TransformerException
- if the application chooses to discontinue the transformation.- See Also:
-
fatalError
Receive notification of a non-recoverable error.The application must assume that the transformation cannot continue after the Transformer has invoked this method, and should continue (if at all) only to collect addition error messages. In fact, Transformers are free to stop reporting events once this method has been invoked.
- Specified by:
fatalError
in interfaceErrorListener
- Parameters:
exception
- The error information encapsulated in a transformer exception.- Throws:
TransformerException
- if the application chooses to discontinue the transformation.- See Also:
-
getLocationMessage
Get a string identifying the location of an error.- Parameters:
err
- the exception containing the location information- Returns:
- a message string describing the location
-
abbreviatePath
Abbreviate a URI (if requested)- Parameters:
uri
- the URI to be abbreviated- Returns:
- the abbreviated URI, unless full path names were requested, in which case the URI as supplied
-
getExpandedMessage
Get a string containing the message for this exception and all contained exceptions- Parameters:
err
- the exception containing the required information- Returns:
- a message that concatenates the message of this exception with its contained exceptions, also including information about the error code and location.
-
printStackTrace
Print a stack trace to a specified output destination- Parameters:
out
- the print stream to which the stack trace will be outputcontext
- the XPath dynamic execution context (which holds the head of a linked list of context objects, representing the execution stack)
-