Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
* 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
* {@link 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
*/
public abstract class NLS {
private static Logger logger = LoggerFactory.getLogger(NLS.class.getName());
private static final Object[] EMPTY_ARGS = new Object[0];
private static final String EXTENSION = ".properties"; //$NON-NLS-1$
private static String[] nlSuffixes;
static final int SEVERITY_ERROR = 0x04;
static final int SEVERITY_WARNING = 0x02;
/*
* This object is assigned to the value of a field map to indicate that a translated message has
* already been assigned to that field.
*/
static final Object ASSIGNED = new Object();
/**
* Creates a new NLS instance.
*/
protected NLS() {
super();
}
/**
* Bind the given message's substitution locations with the given string value.
*
* @param message the message to be manipulated
* @param binding the object to be inserted into the message
* @return the manipulated String
* @throws IllegalArgumentException if the text appearing within curly braces in the given message
* does not map to an integer
*/
public static String bind(String message, Object binding) {
return internalBind(message, null, String.valueOf(binding), null);
}
/**
* Bind the given message's substitution locations with the given string values.
*
* @param message the message to be manipulated
* @param binding1 An object to be inserted into the message
* @param binding2 A second object to be inserted into the message
* @return the manipulated String
* @throws IllegalArgumentException if the text appearing within curly braces in the given message
* does not map to an integer
*/
public static String bind(String message, Object binding1, Object binding2) {
return internalBind(message, null, String.valueOf(binding1), String.valueOf(binding2));
}
/**
* Bind the given message's substitution locations with the given string values.
*
* @param message the message to be manipulated
* @param bindings An array of objects to be inserted into the message
* @return the manipulated String
* @throws IllegalArgumentException if the text appearing within curly braces in the given message
* does not map to an integer
*/
public static String bind(String message, Object[] bindings) {
return internalBind(message, bindings, null, null);
}
/**
* Initialize the given class with the values from the message properties specified by the base
* name. The base name specifies a fully qualified base name to a message properties file,
* including the package where the message properties file is located. The class loader of the
* specified class will be used to load the message properties resources.
*
* For example, if the locale is set to en_US and org.eclipse.example.nls.messages is
* used as the base name then the following resources will be searched using the class loader of
* the specified class:
*
*
*
*
* @param baseName the base name of a fully qualified message properties file.
* @param clazz the class where the constants will exist
*/
public static void initializeMessages(final String baseName, final Class> clazz) {
if (System.getSecurityManager() == null) {
load(baseName, clazz);
return;
}
AccessController.doPrivileged(new PrivilegedAction