Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Business Components
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.jbo.common
Class JboExceptionHelper

    java.lang.Object
      |
      +--oracle.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:

- a non-translated product code string, such as `"FRM"` or `"ORA"`.
- a non-translated error code string, such as `"10234"`
- non-translated message text.
- message parameters, equal in number to the number of '%' symbols in the message text.
- a "details" list containing background information.

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:

- `getResourceName`
to return the name of the appropriate resource bundle.
- `getProductCode`
to return the name of the product.

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.
`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.
`void` | `setDetails(java.lang.Object[] details)` Sets the list of details.
`void` | `setErrorParameters(java.lang.Object[] params)` Resets the error parameters.

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.
    `message` - the default text of the message.
    `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.

### addToDetails

    public void addToDetails(java.lang.Object obj)

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Business Components
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD