org.eclipse.osgi.util
Class NLS

java.lang.Object
  extended by org.eclipse.osgi.util.NLS
Direct Known Subclasses:
UIMessages

public abstract class NLS
extends java.lang.Object

Common superclass for all message bundle classes. Provides convenience methods for manipulating messages.

The #bind methods perform string substitution and should be considered a convenience and not a full substitute replacement for MessageFormat#format method calls.

Text appearing within curly braces in the given message, will be interpreted as a numeric index to the corresponding substitution object in the given array. Calling the #bind methods with text that does not map to an integer will result in an IllegalArgumentException.

Text appearing within single quotes is treated as a literal. A single quote is escaped by a preceeding single quote.

Clients who wish to use the full substitution power of the MessageFormat class should call that class directly and not use these #bind methods.

Clients may subclass this type.

Since:
3.1

Constructor Summary
protected NLS()
          Creates a new NLS instance.
 
Method Summary
static java.lang.String bind(java.lang.String message, java.lang.Object binding)
          Bind the given message's substitution locations with the given string value.
static java.lang.String bind(java.lang.String message, java.lang.Object[] bindings)
          Bind the given message's substitution locations with the given string values.
static java.lang.String bind(java.lang.String message, java.lang.Object binding1, java.lang.Object binding2)
          Bind the given message's substitution locations with the given string values.
static void initializeMessages(java.lang.String bundleName, java.lang.Class clazz)
          Initialize the given class with the values from the specified message bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NLS

protected NLS()
Creates a new NLS instance.

Method Detail

bind

public static java.lang.String bind(java.lang.String message,
                                    java.lang.Object binding)
Bind the given message's substitution locations with the given string value.

Parameters:
message - the message to be manipulated
binding - the object to be inserted into the message
Returns:
the manipulated String
Throws:
java.lang.IllegalArgumentException - if the text appearing within curly braces in the given message does not map to an integer

bind

public static java.lang.String bind(java.lang.String message,
                                    java.lang.Object binding1,
                                    java.lang.Object binding2)
Bind the given message's substitution locations with the given string values.

Parameters:
message - the message to be manipulated
binding1 - An object to be inserted into the message
binding2 - A second object to be inserted into the message
Returns:
the manipulated String
Throws:
java.lang.IllegalArgumentException - if the text appearing within curly braces in the given message does not map to an integer

bind

public static java.lang.String bind(java.lang.String message,
                                    java.lang.Object[] bindings)
Bind the given message's substitution locations with the given string values.

Parameters:
message - the message to be manipulated
bindings - An array of objects to be inserted into the message
Returns:
the manipulated String
Throws:
java.lang.IllegalArgumentException - if the text appearing within curly braces in the given message does not map to an integer

initializeMessages

public static void initializeMessages(java.lang.String bundleName,
                                      java.lang.Class clazz)
Initialize the given class with the values from the specified message bundle.

Parameters:
bundleName - fully qualified path of the class name
clazz - the class where the constants will exist