public class MuLi extends Object
MuLi
represents a multi-lingual identifier or text.
Its structure is
language ::= (String U _syntheticLanguage_)
MuLi ::= language -/-> String
#_syntheticLanguage_
is a special string value reserved for the cases
in which a language differetiation is not applicable (e.g. for pure numeric strings
or for personal names).
language
values should follow the ISO language codes.
as specified in
ISO 639-2. These are the codes also used by "xml:lang
",
cf. RFC 4646 / RFC 4647 / IETF BCP 47.
At least they should not have the value of the #_syntheticLanguage_
string.
The look-up function get(String)
is delegated to a map object and
has the usual java-like semantics, esp. returning null
if
s
not in the domain.
Further, there is a special look-up function get(String...)
of type
get : preference:(SEQ language)->MuLi.TextFoundwith
MuLi.TextFound ::= (index:(NAT U{-1}) * language:String * result:StringThe object of class
MuLi.TextFound
,
as returned by the function, reflects the most left language in
the original preference list for which an entry can be found in the
MuLi
object.
=-1
indicated the fact that the found language is chosen
by random and was not in the list of preferred languages.
Modifier and Type | Class and Description |
---|---|
static class |
MuLi.TextFound
A class representing the result of calls to
get(String...) and sim. |
Modifier and Type | Field and Description |
---|---|
protected Location |
location |
static String |
syntheticLanguage
Use this as key value for
put and get
in cases where no natural language is applicable. |
protected Map<String,String> |
texts |
Constructor and Description |
---|
MuLi() |
MuLi(Map<String,String> data)
Initialize translations, uses
put(Map) , see there for important remarks! |
Modifier and Type | Method and Description |
---|---|
MuLi |
cloneUnmodifiable() |
boolean |
containsLang(String lang) |
Location |
get_location() |
@Opt MuLi.TextFound |
get(List<String> preference) |
@Opt MuLi.TextFound |
get(String... preference) |
@Opt String |
get(String lang) |
Set<String> |
getLanguages() |
void |
put(List<String> pairs)
Deprecated.
use "put(
eu.bandm.tools.ops.Collections.literalMap() " instead! |
void |
put(Map<String,String> data)
Put a multitude of key/value pairs into the internal map.
|
void |
put(String... pairs)
Deprecated.
use "put(
eu.bandm.tools.ops.Collections.literalMap() " instead! |
void |
put(String lang,
String text)
Put a new key/value pair into the internal map.
|
void |
set_location(Location loc) |
String |
toString() |
public static final String syntheticLanguage
put
and get
in cases where no natural language is applicable.
E.g. for technical notions, personal names, formulae.protected Location location
public MuLi cloneUnmodifiable()
public String toString()
public Location get_location()
public void set_location(Location loc)
public Set<String> getLanguages()
@Opt public @Opt String get(String lang)
null
if key not
in domain.public boolean containsLang(String lang)
@Opt public @Opt MuLi.TextFound get(String... preference)
MuLi.TextFound
object representing the first string found when
trying the listed languages from left to right.
If not translation is found, return an arbitrary one.
If no translation exists, return null.@Opt public @Opt MuLi.TextFound get(List<String> preference)
get(String...)
public void put(String lang, String text)
lang
- the key, should be a language code.text
- the value, i.e. the translation into this language.public void put(Map<String,String> data)
put(String,String)
.
map
- map of language to name@Deprecated public void put(String... pairs)
eu.bandm.tools.ops.Collections.literalMap()
" instead!put(String,String)
.
pairs
- sequence of key/value pairsIllegalArgumentException
- in case the number of Strings in not even.@Deprecated public void put(List<String> pairs)
eu.bandm.tools.ops.Collections.literalMap()
" instead!put(String...)
see also the complete user documentation .