Oracle ADF Model and Business Components API Reference 10.1.2 B14022-01

oracle.jbo.common
Class JboExceptionHelper

java.lang.Object
  extended byoracle.jbo.common.JboExceptionHelper
Direct Known Subclasses:
JboExHelperLocalized

public class JboExceptionHelper
extends java.lang.Object

The top-level class for Business Component exceptions.

This class provides tools for localizing exception messages for various target languages, and for message formatting.

Message-text localization occurs when the client calls getLocalizedMessage(), rather than at time the exception occurs, because the client may need to present the message in a number of different languages.

The components of a message are:

Additional components may be introduced in future.

A counterpart subclass of ResourceBundle, JboExceptionBundle, is used to determine the overall formatting of the message. The default format is

productCode-errorCode: messageBody
For example, ORA-10234: I don't think so.

Most subclasses wll provide a value for the error code in a specialized constructor.

Applications may define subclasses of most JBO exceptions. To do this the application should override the following methods to provide the correct set of values for the messaging services:

Other methods may be overridden to modify the message format.

Since:
JDeveloper 3.0
See Also:
JboExHelperLocalized, JboException

Constructor Summary
JboExceptionHelper(JboMessage ex, java.lang.String msg, java.lang.String errorCode, java.lang.Object[] params)
          Creates a translatable exception.
 
Method Summary
 void addToDetails(java.lang.Object obj)
          Adds to the list of details.
 java.lang.String getBaseMessage()
          Gets the message without localizing it or inserting parameters.
 java.lang.String getDetailMessage()
          Constructs a message incorporating the list of details.
 java.lang.Object[] getDetails()
          Gets the list of objects and exceptions that spawned this message.
 com.sun.java.util.collections.ArrayList getDetailsList()
           
 java.lang.String getErrorCode()
          Gets the error code.
protected  java.lang.String getErrorMsg(java.util.Locale l, java.lang.Object[] params)
           
protected  java.lang.String getErrorMsgFormat(java.util.Locale l)
          Return the default format to print messages in.
 java.lang.Object[] getErrorParameters()
          Gets the error message parameters.
 java.lang.String getLocalizedBaseMessage(java.util.Locale l)
          Localizes an un-parameterized message text for a specific Locale.
 java.lang.String getLocalizedMessage(java.util.Locale l)
          Formats the message text for a specific Locale.
 java.lang.String getMessage()
          Formats the message text for the default locale.
 java.lang.String getProductCode()
          Gets the product code.
 java.lang.Class getResourceClass()
          Gets the resource bundle used to localize messages.
 java.lang.String getResourceName()
          Gets the name of the ResourceBundle used to localize messages.
 boolean isAppendCodes()
          Returns true if this exception has to prefix the error message with Product and Message Ids.
 void setAppendCodes(boolean flag)
          Set false if this exception should not prefix the error message with Product and Message Ids.
 void setDetails(java.lang.Object[] details)
          Sets the list of details.
 void setDetailsList(com.sun.java.util.collections.ArrayList details)
          Sets the list of details.
 void setErrorParameters(java.lang.Object[] params)
          Resets the error parameters.
 void setLocaleContext(LocaleContext locale)
          Set the default locale for this exception to the given locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JboExceptionHelper

public JboExceptionHelper(JboMessage ex,
                          java.lang.String msg,
                          java.lang.String errorCode,
                          java.lang.Object[] params)
Creates a translatable exception.

Parameters:
ex - a Business Component error or warning.
errorCode - error code; a key associated with a message in a resource bundle.
params - the error message's parameters.
See Also:
ResourceBundle
Method Detail

getMessage

public java.lang.String getMessage()
Formats the message text for the default locale.

Returns:
the localized message.

getLocalizedMessage

public java.lang.String getLocalizedMessage(java.util.Locale l)
Formats the message text for a specific Locale.

Parameters:
l - a locale.
Returns:
the localized message.

getBaseMessage

public java.lang.String getBaseMessage()
Gets the message without localizing it or inserting parameters.

Returns:
the un-formatted, non-localized message.

getLocalizedBaseMessage

public java.lang.String getLocalizedBaseMessage(java.util.Locale l)
Localizes an un-parameterized message text for a specific Locale.

Parameters:
l - a locale.
Returns:
the localalized but un-formatted message.

getResourceName

public java.lang.String getResourceName()
Gets the name of the ResourceBundle used to localize messages.

Returns:
null.

getResourceClass

public java.lang.Class getResourceClass()
Gets the resource bundle used to localize messages.

Returns:
null.

getErrorParameters

public java.lang.Object[] getErrorParameters()
Gets the error message parameters.

Returns:
an array of objects.

setErrorParameters

public void setErrorParameters(java.lang.Object[] params)
Resets the error parameters. This method is for use by derived classes who create their own set of parameters but do not want the "thrower" to know about it.


getErrorCode

public java.lang.String getErrorCode()
Gets the error code.

Returns:
a string containing an error code.

getProductCode

public java.lang.String getProductCode()
Gets the product code.

Returns:
the exception's product code.

getErrorMsg

protected java.lang.String getErrorMsg(java.util.Locale l,
                                       java.lang.Object[] params)

getErrorMsgFormat

protected java.lang.String getErrorMsgFormat(java.util.Locale l)
Return the default format to print messages in. When the exception system cannot load the Format information required to format messages for printing, it calls this method to obtain the required information.

In general, the Message format consists of 3 elements, these are:

  1. product code from getProductCode
  2. error code from getErrorCode
  3. error message text loaded from the resource bundle
This method returns a string of the form "{0}-{1}: {2}". An example message in this form might look like:
JBO-100: A Mandatory attribute is missing.

Parameters:
l - the locale for the formatted message.
Returns:
a format string to format the printed message.

getDetails

public java.lang.Object[] getDetails()
Gets the list of objects and exceptions that spawned this message.

Returns:
an array.

getDetailMessage

public java.lang.String getDetailMessage()
Constructs a message incorporating the list of details.

Returns:
a text string.

setDetails

public void setDetails(java.lang.Object[] details)
Sets the list of details.

Parameters:
details - an array which replaces the current list of details.

setDetailsList

public void setDetailsList(com.sun.java.util.collections.ArrayList details)
Sets the list of details.

Parameters:
details - an array which replaces the current list of details.

getDetailsList

public com.sun.java.util.collections.ArrayList getDetailsList()

addToDetails

public void addToDetails(java.lang.Object obj)
Adds to the list of details.

Parameters:
obj - an object to add to the details list.

isAppendCodes

public boolean isAppendCodes()
Returns true if this exception has to prefix the error message with Product and Message Ids.


setAppendCodes

public void setAppendCodes(boolean flag)
Set false if this exception should not prefix the error message with Product and Message Ids. By default this flag is set to true.


setLocaleContext

public void setLocaleContext(LocaleContext locale)
Set the default locale for this exception to the given locale. This locale will be used when returning message from getMessage.


Oracle ADF Model and Business Components API Reference 10.1.2 B14022-01

 

Copyright © 1997, 2004, Oracle. All rights reserved.