public final class I18nizableText extends Object
Modifier and Type | Field and Description |
---|---|
private String |
_catalogue |
private String |
_catalogueBundleName |
private String |
_catalogueLocation |
private String |
_directLabel |
private boolean |
_i18n |
private String |
_key |
private Map<String,I18nizableText> |
_parameterMap |
private List<String> |
_parameters |
Constructor and Description |
---|
I18nizableText(String label)
Create a simple international text
|
I18nizableText(String catalogue,
String key)
Create an i18nized text
|
I18nizableText(String catalogue,
String key,
List<String> parameters)
Create an i18nized text with ordered parameters.
|
I18nizableText(String catalogue,
String key,
Map<String,I18nizableText> parameters)
Create an i18nized text with named parameters.
|
I18nizableText(String catalogueLocation,
String catalogueFilename,
String key)
Create an i18nized text.
|
I18nizableText(String catalogueLocation,
String catalogueFilename,
String key,
List<String> parameters)
Create an i18nized text with ordered parameters.
|
I18nizableText(String catalogueLocation,
String catalogueFilename,
String key,
Map<String,I18nizableText> parameters)
Create an i18nized text with named parameters.
|
Modifier and Type | Method and Description |
---|---|
private void |
_toSAXAsParam(ContentHandler handler) |
boolean |
equals(Object obj) |
String |
getBundleName()
Get the files name of catalog
|
String |
getCatalogue()
Get the catalogue of the i18nized text.
|
static I18nizableText |
getI18nizableTextValue(Configuration config,
String defaultCatalogue,
String value)
Get an i18n text configuration (can be a key or a "direct" string).
|
private static I18nizableText |
getI18nizableTextValue(Configuration config,
String catalogueLocation,
String catalogueFilename,
String value)
Get an i18n text configuration (can be a key or a "direct" string).
|
String |
getKey()
Get the key of the i18nized text.
|
String |
getLabel()
Get the label if a text is not i18nized.
|
String |
getLocation()
Get the file location URI of the i18nized text.
|
Map<String,I18nizableText> |
getParameterMap()
Get the parameters of the key of the i18nized text.
|
List<String> |
getParameters()
Get the parameters of the key of the i18nized text.
|
int |
hashCode() |
static String |
i18nizableTextToString(I18nizableText i18nizableText)
Gets a string representation of a i18n text
|
boolean |
isI18n()
Determine whether the text is i18nized or a simple cross languages text.
|
private static boolean |
isI18n(Configuration config) |
static I18nizableText |
parseI18nizableText(Configuration config,
String defaultCatalogue)
Parse a mandatory i18n text configuration, throwing an exception if empty.
|
static I18nizableText |
parseI18nizableText(Configuration config,
String defaultCatalogue,
String defaultValue)
Parse an optional i18n text configuration, with a default value.
|
static I18nizableText |
parseI18nizableText(Configuration config,
String catalogueLocation,
String catalogueFilename,
String defaultValue)
Parse a i18n text configuration.
|
static I18nizableText |
stringToI18nizableText(String str)
Returns the i18n text from its string representation
|
void |
toSAX(ContentHandler handler)
SAX a text
|
void |
toSAX(ContentHandler handler,
String tagName)
SAX a text
|
String |
toString() |
private final boolean _i18n
private String _directLabel
private String _catalogue
private List<String> _parameters
private Map<String,I18nizableText> _parameterMap
private String _catalogueLocation
private String _catalogueBundleName
public I18nizableText(String label)
label
- The text. Cannot be null.public I18nizableText(String catalogue, String key)
catalogue
- the catalogue where the key is defined. Can be null. Can be overloaded by the catalogue in the key.key
- the key of the text. Cannot be null. May include the catalogue using the character ':' as separator. CATALOG:KEY.public I18nizableText(String catalogue, String key, List<String> parameters)
catalogue
- the catalogue where the key is defined. Can be null. Can be overloaded by the catalogue in the key.key
- the key of the text. Cannot be null. May include the catalogue using the character ':' as separator. CATALOG:KEY.parameters
- the parameters of the key if any. Can be null.public I18nizableText(String catalogue, String key, Map<String,I18nizableText> parameters)
catalogue
- the catalogue where the key is defined. Can be null. Can be overloaded by the catalogue in the key.key
- the key of the text. Cannot be null. May include the catalogue using the character ':' as separator. CATALOG:KEY.parameters
- the named parameters of the message, as a Map of name -> value. Value can itself be an i18n key but must not have parameters.public I18nizableText(String catalogueLocation, String catalogueFilename, String key)
catalogueLocation
- the file location URI of the catalogue where the key is defined.catalogueFilename
- the catalogue bundle name such as 'messages'key
- the key of the text. Cannot be null.public I18nizableText(String catalogueLocation, String catalogueFilename, String key, List<String> parameters)
catalogueLocation
- the file location URI of the catalogue where the key is defined.catalogueFilename
- the catalogue bundle name such as 'messages'key
- the key of the text. Cannot be null.parameters
- the parameters of the key if any. Can be null.public I18nizableText(String catalogueLocation, String catalogueFilename, String key, Map<String,I18nizableText> parameters)
catalogueLocation
- the file location URI of the catalogue where the key is defined.catalogueFilename
- the catalogue bundle name such as 'messages'key
- the key of the text. Cannot be null.parameters
- the named parameters of the message, as a Map of name -> value. Value can itself be an i18n key but must not have parameters.public boolean isI18n()
public String getCatalogue()
public String getLocation()
public String getBundleName()
public List<String> getParameters()
public Map<String,I18nizableText> getParameterMap()
public void toSAX(ContentHandler handler) throws SAXException
handler
- The sax content handlerSAXException
- if an error occurspublic void toSAX(ContentHandler handler, String tagName) throws SAXException
handler
- The sax content handlertagName
- The tag nameSAXException
- if an error occursprivate void _toSAXAsParam(ContentHandler handler) throws SAXException
SAXException
private static boolean isI18n(Configuration config)
private static I18nizableText getI18nizableTextValue(Configuration config, String catalogueLocation, String catalogueFilename, String value)
config
- The configuration to parse.catalogueLocation
- The i18n catalogue location URIcatalogueFilename
- The i18n catalogue bundle namevalue
- The i18n text, can be a key or a "direct" string.public static I18nizableText getI18nizableTextValue(Configuration config, String defaultCatalogue, String value)
config
- The configuration to parse.defaultCatalogue
- The i18n catalogue to use when not specified.value
- The i18n text, can be a key or a "direct" string.public static I18nizableText parseI18nizableText(Configuration config, String catalogueLocation, String catalogueFilename, String defaultValue) throws ConfigurationException
config
- the configuration to use.catalogueLocation
- The i18n catalogue location URIcatalogueFilename
- The i18n catalogue bundle namedefaultValue
- The default value key in configurationConfigurationException
- if the configuration is not valid.public static I18nizableText parseI18nizableText(Configuration config, String defaultCatalogue, String defaultValue)
config
- the configuration to use.defaultCatalogue
- the i18n catalogue to use when not specified.defaultValue
- the default value key in configuration.public static I18nizableText parseI18nizableText(Configuration config, String defaultCatalogue) throws ConfigurationException
config
- the configuration to use.defaultCatalogue
- the i18n catalogue to use when not specified.ConfigurationException
- if the configuration is not valid.public static String i18nizableTextToString(I18nizableText i18nizableText)
i18nizableText
- The i18 textpublic static I18nizableText stringToI18nizableText(String str)
str
- The string representation of the i18n text