- java.lang.Object
-
- org.arakhne.afc.vmutil.locale.Locale
-
public final class Locale extends Object
This utility class permits a easier use of localized strings.Localeprovides a means to retreive messages in the default language. Use this to construct messages displayed for end users.Localetakes a string from a properties resource, then inserts the parameter strings into the extracted strings at the appropriate places. The pattern matching is proceeded withLocaleMessageFormatformatter. Note that''may represent a single quote in strings (seeLocaleMessageFormatfor details).- Since:
- 6.4
- Version:
- 17.0 2020-01-04 14:41:35
- Author:
- Stéphane GALLAND, $Author: lamotte$
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- vmutils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdecodeString(byte[] bytes)Decode the specified array of bytes according to a charset selection.static StringdecodeString(InputStream stream)Decode the bytes from the specified input stream according to a charset selection.static booleandecodeString(InputStream stream, List<String> lineArray)Decode the bytes from the specified input stream according to a charset selection.static Charset[]getPriorizedDecodingCharsets()Replies the charsets for decoding that must be used prior to the installed charsets.static StringgetString(Class<?> resource, String key, Object... params)Replies the text that corresponds to the specified resource.static StringgetString(ClassLoader classLoader, Class<?> resource, String key, Object... params)Replies the text that corresponds to the specified resource.static StringgetString(ClassLoader classLoader, String key, Object... params)Replies the text that corresponds to the specified resource.static StringgetString(String key, Object... params)Replies the text that corresponds to the specified resource.static StringgetStringFrom(ClassLoader classLoader, String resourcePath, String key, Object... params)Replies the text that corresponds to the specified resource.static StringgetStringFrom(String resourcePath, String key, Object... params)Replies the text that corresponds to the specified resource.static StringgetStringWithDefault(Class<?> resource, String key, String defaultValue, Object... params)Replies the text that corresponds to the specified resource.static StringgetStringWithDefault(ClassLoader classLoader, Class<?> resource, String key, String defaultValue, Object... params)Replies the text that corresponds to the specified resource.static StringgetStringWithDefault(ClassLoader classLoader, String key, String defaultValue, Object... params)Replies the text that corresponds to the specified resource.static StringgetStringWithDefault(String key, String defaultValue, Object... params)Replies the text that corresponds to the specified resource.static StringgetStringWithDefaultFrom(ClassLoader classLoader, String resourcePath, String key, String defaultValue, Object... params)Replies the text that corresponds to the specified resource.static StringgetStringWithDefaultFrom(String resourcePath, String key, String defaultValue, Object... params)Replies the text that corresponds to the specified resource.static voidsetPriorizedDecodingCharsets(Charset[] charsets)Change the charsets for decoding that must be used prior to the installed charsets.
-
-
-
Method Detail
-
getPriorizedDecodingCharsets
public static Charset[] getPriorizedDecodingCharsets()
Replies the charsets for decoding that must be used prior to the installed charsets.- Returns:
- the priorized decoding charsets.
-
setPriorizedDecodingCharsets
public static void setPriorizedDecodingCharsets(Charset[] charsets)
Change the charsets for decoding that must be used prior to the installed charsets.- Parameters:
charsets- the priorized decoding charsets.
-
getStringWithDefaultFrom
@Pure public static String getStringWithDefaultFrom(String resourcePath, String key, String defaultValue, Object... params)
Replies the text that corresponds to the specified resource.The
resourcePathargument should be a fully qualified class name. However, for compatibility with earlier versions, Sun's Java SE Runtime Environments do not verify this, and so it is possible to accessPropertyResourceBundles by specifying a path name (using "/") instead of a fully qualified class name (using ".").- Parameters:
resourcePath- is the name (path) of the resource file, a fully qualified class namekey- is the name of the resource into the specified filedefaultValue- is the default value to replies if the resource does not contain the specified key.params- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getStringWithDefaultFrom
@Pure public static String getStringWithDefaultFrom(ClassLoader classLoader, String resourcePath, String key, String defaultValue, Object... params)
Replies the text that corresponds to the specified resource.The
resourcePathargument should be a fully qualified class name. However, for compatibility with earlier versions, Sun's Java SE Runtime Environments do not verify this, and so it is possible to accessPropertyResourceBundles by specifying a path name (using "/") instead of a fully qualified class name (using ".").- Parameters:
classLoader- is the class loader to use, a fully qualified class nameresourcePath- is the name (path) of the resource filekey- is the name of the resource into the specified filedefaultValue- is the default value to replies if the resource does not contain the specified key.params- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getStringFrom
@Pure public static String getStringFrom(String resourcePath, String key, Object... params)
Replies the text that corresponds to the specified resource.The
resourcePathargument should be a fully qualified class name. However, for compatibility with earlier versions, Sun's Java SE Runtime Environments do not verify this, and so it is possible to accessPropertyResourceBundles by specifying a path name (using "/") instead of a fully qualified class name (using ".").- Parameters:
resourcePath- is the name (path) of the resource file, a fully qualified class namekey- is the name of the resource into the specified fileparams- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getStringFrom
@Pure public static String getStringFrom(ClassLoader classLoader, String resourcePath, String key, Object... params)
Replies the text that corresponds to the specified resource.The
resourcePathargument should be a fully qualified class name. However, for compatibility with earlier versions, Sun's Java SE Runtime Environments do not verify this, and so it is possible to accessPropertyResourceBundles by specifying a path name (using "/") instead of a fully qualified class name (using ".").- Parameters:
classLoader- is the classLoader to use.resourcePath- is the name (path) of the resource file, a fully qualified class namekey- is the name of the resource into the specified fileparams- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getString
@Pure public static String getString(Class<?> resource, String key, Object... params)
Replies the text that corresponds to the specified resource.- Parameters:
resource- is the name of the resource filekey- is the name of the resource into the specified fileparams- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getString
@Pure public static String getString(ClassLoader classLoader, Class<?> resource, String key, Object... params)
Replies the text that corresponds to the specified resource.- Parameters:
classLoader- is the class loader to use.resource- is the name of the resource filekey- is the name of the resource into the specified fileparams- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getString
public static String getString(String key, Object... params)
Replies the text that corresponds to the specified resource.This function assumes the classname of the caller as the resource provider.
- Parameters:
key- is the name of the resource into the specified fileparams- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getString
@Pure public static String getString(ClassLoader classLoader, String key, Object... params)
Replies the text that corresponds to the specified resource.This function assumes the classname of the caller as the resource provider.
- Parameters:
classLoader- is the classLoader to use.key- is the name of the resource into the specified fileparams- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getStringWithDefault
@Pure public static String getStringWithDefault(Class<?> resource, String key, String defaultValue, Object... params)
Replies the text that corresponds to the specified resource.- Parameters:
resource- is the name of the resource filekey- is the name of the resource into the specified filedefaultValue- is the default value to replies if the resource does not contain the specified key.params- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getStringWithDefault
@Pure public static String getStringWithDefault(ClassLoader classLoader, Class<?> resource, String key, String defaultValue, Object... params)
Replies the text that corresponds to the specified resource.- Parameters:
classLoader- is the class loader to use.resource- is the name of the resource filekey- is the name of the resource into the specified filedefaultValue- is the default value to replies if the resource does not contain the specified key.params- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getStringWithDefault
@Pure public static String getStringWithDefault(String key, String defaultValue, Object... params)
Replies the text that corresponds to the specified resource.- Parameters:
key- is the name of the resource into the specified filedefaultValue- is the default value to replies if the resource does not contain the specified key.params- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
getStringWithDefault
@Pure public static String getStringWithDefault(ClassLoader classLoader, String key, String defaultValue, Object... params)
Replies the text that corresponds to the specified resource.- Parameters:
classLoader- is the class loader to use.key- is the name of the resource into the specified filedefaultValue- is the default value to replies if the resource does not contain the specified key.params- is the the list of parameters which will replaces the#1,#2... into the string.- Returns:
- the text that corresponds to the specified resource
-
decodeString
@Pure public static String decodeString(byte[] bytes)
Decode the specified array of bytes according to a charset selection. This function tries to decode a string from the given byte array with the following charsets (in preferred order):- the current charset returned by
Charset.defaultCharset(), - OEM United States: IBM437,
- West European: ISO-8859-1,
- one of the chars returned by
Charset.availableCharsets().
The IBM437 charset was added to support several specific files (Dbase files) generated from a GIS.
- Parameters:
bytes- is the array of bytes to decode.- Returns:
- the decoded string with the appropriate charset set.
- the current charset returned by
-
decodeString
public static String decodeString(InputStream stream) throws IOException
Decode the bytes from the specified input stream according to a charset selection. This function tries to decode a string from the given byte array with the following charsets (in preferred order):- the current charset returned by
Charset.defaultCharset(), - OEM United States: IBM437,
- West European: ISO-8859-1,
- one of the charst returned by
Charset.availableCharsets().
The IBM437 charset was added to support several specific files (Dbase files) generated from a GIS.
- Parameters:
stream- is the stream to decode.- Returns:
- the decoded string with the appropriate charset set.
- Throws:
IOException- when the stream cannot be read.
- the current charset returned by
-
decodeString
public static boolean decodeString(InputStream stream, List<String> lineArray) throws IOException
Decode the bytes from the specified input stream according to a charset selection. This function tries to decode a string from the given byte array with the following charsets (in preferred order):- the current charset returned by
Charset.defaultCharset(), - OEM United States: IBM437,
- West European: ISO-8859-1,
- one of the charst returned by
Charset.availableCharsets().
The IBM437 charset was added to support several specific files (Dbase files) generated from a GIS.
This function read the input stream line by line.
- Parameters:
stream- is the stream to decode.lineArray- is the array of lines to fill- Returns:
trueis the decoding was successful, otherwhisefalse- Throws:
IOException- when the stream cannot be read.
- the current charset returned by
-
-