BEA Systems, Inc.

WebLogic Server 8.1 API Reference

weblogic.i18n
Class Localizer

java.lang.Object
  |
  +--weblogic.i18n.Localizer

public final class Localizer
extends java.lang.Object

Localizer is a class used to look up the various elements of a message definition. A Localizer accesses localization data through properties files generated from the message catalogs using the combination of message element names and message id as keys. For example,

String text = (String) getObject(Localizer.MESSAGE_BODY,"123456")

returns the text for message 123456. Convenience methods are also provided. For instance, the getBody("123456") call is equivalent to the above getObject() call. For log messages, two properties files are generated. One for basic catalog data and one for detailed text. Refer to L10nLookup for information on retrieving detailed vs. basic localization data.

Author:
Copyright © 2004 BEA Systems, Inc. All Rights Reserved.

Field Summary
static java.lang.String ACTION
          key to locate message action
static java.lang.String CAUSE
          key to locate message cause
static java.lang.String I18N_PACKAGE
          key to locate internationalizer package
static java.lang.String L10N_PACKAGE
          key to locate localizer package
static java.lang.String MESSAGE_BODY
          key to locate message message-id
static java.lang.String MESSAGE_DETAIL
          key to locate message detail
static java.lang.String[] NON_SERVER_SEVERITIES
           
static java.lang.String PREFIX
          key to locate catalog prefix
static java.lang.String PREFIX_DELIM
          Delimiter separating prefix from message id
static java.lang.String[] SERVER_SEVERITIES
           
static java.lang.String SEVERITY
          key to locate message severity
static java.lang.String STACKTRACE
          key to locate stack trace option
static java.lang.String SUBSYSTEM
          key to locate catalog subsystem
static java.lang.String VERSION
          key to locate catalog version
 
Constructor Summary
Localizer(java.util.ResourceBundle rb)
           
 
Method Summary
 java.lang.String get(java.lang.String id)
          locate text associated with the passed message id.
 java.lang.String getAction(java.lang.String id)
          Lookup up message action for message, "id".
 java.lang.String getBody(java.lang.String id)
          Lookup up message text for log message, "id".
 java.lang.String getCause(java.lang.String id)
          Lookup up message cause for message, "id".
 java.lang.String getDetail(java.lang.String id)
          Lookup up message detail for log message, "id".
 java.lang.String getI18nPackage()
          Returns the i18n package associated with this Localizer.
 java.lang.String getL10nPackage()
          Returns the l10n package associated with this Localizer.
 java.lang.Object getObject(java.lang.String key, int id)
          Returns an Object in a Localizer bundle matching the key and the specified message id.
 java.lang.Object getObject(java.lang.String key, java.lang.String id)
          Returns an Object in a Localizer bundle matching the key and the specified message id.
 java.lang.String getPrefix()
          Returns the prefix associated with this Localizer.
 int getSeverity(java.lang.String id)
          Lookup up severity for message, "id".
 boolean getStackTrace(java.lang.String id)
          Lookup stack trace option for message, "id".
 java.lang.String getString(java.lang.String key, int id)
          Returns an String in a Localizer bundle matching the key and the specified message id.
 java.lang.String getString(java.lang.String key, java.lang.String id)
          Returns a String-ified version of a value from a Localizer bundle matching the key and the specified message id.
 java.lang.String getSubSystem()
          Returns the subsystem associated with this Localizer.
 java.lang.String getVersion()
          Returns the catalog version supported by this Localizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
key to locate catalog version

L10N_PACKAGE

public static final java.lang.String L10N_PACKAGE
key to locate localizer package

I18N_PACKAGE

public static final java.lang.String I18N_PACKAGE
key to locate internationalizer package

SUBSYSTEM

public static final java.lang.String SUBSYSTEM
key to locate catalog subsystem

PREFIX

public static final java.lang.String PREFIX
key to locate catalog prefix

SEVERITY

public static final java.lang.String SEVERITY
key to locate message severity

MESSAGE_BODY

public static final java.lang.String MESSAGE_BODY
key to locate message message-id

MESSAGE_DETAIL

public static final java.lang.String MESSAGE_DETAIL
key to locate message detail

CAUSE

public static final java.lang.String CAUSE
key to locate message cause

ACTION

public static final java.lang.String ACTION
key to locate message action

STACKTRACE

public static final java.lang.String STACKTRACE
key to locate stack trace option

SERVER_SEVERITIES

public static final java.lang.String[] SERVER_SEVERITIES

NON_SERVER_SEVERITIES

public static final java.lang.String[] NON_SERVER_SEVERITIES

PREFIX_DELIM

public static final java.lang.String PREFIX_DELIM
Delimiter separating prefix from message id
Constructor Detail

Localizer

public Localizer(java.util.ResourceBundle rb)
Method Detail

getVersion

public java.lang.String getVersion()
                            throws java.util.MissingResourceException
Returns the catalog version supported by this Localizer.

Returns:
version number (x.y format)

getL10nPackage

public java.lang.String getL10nPackage()
                                throws java.util.MissingResourceException
Returns the l10n package associated with this Localizer.

Returns:
package name

getI18nPackage

public java.lang.String getI18nPackage()
                                throws java.util.MissingResourceException
Returns the i18n package associated with this Localizer.

Returns:
package name

getSubSystem

public java.lang.String getSubSystem()
                              throws java.util.MissingResourceException
Returns the subsystem associated with this Localizer.

Returns:
subsystem name

getPrefix

public java.lang.String getPrefix()
Returns the prefix associated with this Localizer.

Returns:
prefix name

getObject

public java.lang.Object getObject(java.lang.String key,
                                  java.lang.String id)
                           throws java.util.MissingResourceException
Returns an Object in a Localizer bundle matching the key and the specified message id.

Parameters:
key - Element of a message definition.
id - Message id.
Returns:
Object from the Localizer ResourceBundle.
Throws:
java.util.MissingResourceException - There is no entry in the Localizer for key/id.

getObject

public java.lang.Object getObject(java.lang.String key,
                                  int id)
                           throws java.util.MissingResourceException
Returns an Object in a Localizer bundle matching the key and the specified message id.

Parameters:
key - Element of a message definition.
id - Message id.
Returns:
Object from the Localizer ResourceBundle.
Throws:
java.util.MissingResourceException - There is no entry in the Localizer for key/id.

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String id)
                           throws java.util.MissingResourceException
Returns a String-ified version of a value from a Localizer bundle matching the key and the specified message id. getString is a convenience method to save casting from getObject().

Parameters:
key - Element of a message definition.
id - Message id.
Returns:
String from the Localizer ResourceBundle.
Throws:
java.util.MissingResourceException - There is no entry in the Localizer for key/id.

getString

public java.lang.String getString(java.lang.String key,
                                  int id)
                           throws java.util.MissingResourceException
Returns an String in a Localizer bundle matching the key and the specified message id. getString is a convenience method to save casting from getObject().

Parameters:
key - Element of a message definition.
id - Message id.
Returns:
String from the Localizer ResourceBundle.
Throws:
java.util.MissingResourceException - There is no entry in the Localizer for key/id.

get

public java.lang.String get(java.lang.String id)
locate text associated with the passed message id. This method is useful for users of simple text message catalogs.

Returns:
message text

getBody

public java.lang.String getBody(java.lang.String id)
Lookup up message text for log message, "id".

Returns:
message body text for message identified by id param. An empty String is returned if message not in catalog.

getDetail

public java.lang.String getDetail(java.lang.String id)
Lookup up message detail for log message, "id".

Returns:
message detail text for message identified by id param. An empty String is returned if message not in catalog.

getCause

public java.lang.String getCause(java.lang.String id)
Lookup up message cause for message, "id".

Returns:
message cause text for the log message identified by id param. An empty String is returned if message not in catalog.

getAction

public java.lang.String getAction(java.lang.String id)
Lookup up message action for message, "id".

Returns:
message action text for the log message identified by id param. An empty String is returned if message not in catalog.

getSeverity

public int getSeverity(java.lang.String id)
Lookup up severity for message, "id".

Returns:
severity value for the log message identified by id param. Zero is returned if message not in catalog.

getStackTrace

public boolean getStackTrace(java.lang.String id)
Lookup stack trace option for message, "id".

Returns:
true if option excists and value is "true". Otherwise false.

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs81