@MinDoc(copyright="Copyright 2004, 2009 A. Weinert", author="Albrecht Weinert", version="V.56", lastModified="28.06.2021", usage="use ApplangMap as a (zoo of) PropMap(s) for language specific properties or\n\n java de.frame4j.util.ApplangMap [options] langCode", purpose="properties for (inter) nationalisation") public class AppLangMap extends PropMap
AppLangMap
object encompasses for one language the basic set
of catch words and commonplace phrases including output patterns. All
values can be got by a language independent set of keys and partly
indices. Switching the language is done by changing the AppLangMap
object in use.AppLangMap
object is a PropMap
(and
hence a Map
) featuring all possibilities of the parent
classes, like adding more key-value-pairs as
PropMapHelper.Entry
s). Compared to the parent
classes' possibilities the standard entries mentioned can't be
removed.Map
an AppLangMap
object by a given key,
like e.g. "jan" provides a language specific value, like here
"gennaio" for it etc. To get the January in the object's
language one can use the method month(1)
also.AppLangMap
object, making it a singleton with regard to the
language supported. Each one provides at least the the following basic
set of entriesTextHelper.messageFormat(..)
, AppLangMap
keys are lower case only. For the
standard values' keys this is irrelevant insofar as they are recognised in
any case combination. Providing the keys in lower case is recommended and
faster: sat_s or Sat_S e.g. would get both Sáb for the Portuguese (pt)
AppLangMap (Saturday abbreviated).AppLangMap
's language. If nothing is found there it will
be searched for in MAP_en
and MAP_de
as substitutes.
Those both must always be comprehensive. Feedback on gaps or faults
are welcome.App
extension. Execute it
byLocale
, DateFormatSymbols
etc. this class brings higher comfort and better performance. This is
restricted to languages of Western European origin (in the widest sense)
or those that could live with ISO8859-1 / Latin1, -15 or similar.App
gets by
AppLangMap
.getUMap()
quite simply the
AppLangMap
fitting the platforms language or that set by standard
start parameters. That's all.TimeHelper
e.g.) use essentially the same
proceeding.de.frame4j
,
TimeHelper
,
App
,
de.frame4j.util
,
TextHelper
,
Serialized FormPropMap.EntrySet, PropMap.KeySet<S>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
static int |
anzDatLangKeys
Number of date keys.
|
static int |
anzStdKeys
Number of standard keys.
|
static int |
anzSuplKeys
Number of special entries.
|
static int |
anzTimeZoneKeysKeys
Number of keys for time zones.
|
String |
langCode
The (two letter) language code.
|
protected static SoftReference<PropMap> |
langPropMapRef
PropMap from resource files.
|
protected Locale |
locale
The Locale used for otherwise not supported languages.
|
static AppLangMap |
MAP_de
Language specifics for applications, German, Deutsch, de.
|
static AppLangMap |
MAP_en
Language specifics for applications, English, en.
|
protected static ReentrantReadWriteLock.ReadLock |
rLock
The common lock for reads.
|
static int |
S_B
Begin of the language index range.
|
static int |
S_E
End of the language index range.
|
protected PropMapHelper.Entry[] |
stdEntries
Standard entries.
|
static int |
VL_CL
Cache size for valueUL() look up.
|
protected static ReentrantReadWriteLock.WriteLock |
wLock
The common lock for writes.
|
static int |
Z_B
Begin of time zone's range.
|
entries, FILE_LIST_LEN, hashMissMax, hashMissSum, internalEntrySet, internalKeySet, keyStringMld, language, region, reHashes, valStringMld
Modifier and Type | Method and Description |
---|---|
void |
clear(int startCap)
Clear / delete.
|
StringBuilder |
completeList(StringBuilder bastel)
List of the entries as multi-line sequence.
|
static int |
contNo(CharSequence key)
Internal number for standard keys.
|
PropMapHelper.Entry |
entry(CharSequence key)
Fetching the entry for a key.
|
static StringBuilder |
formMessageUL(CharSequence key,
String patternDefault,
Object param)
Make a (inter) nationalised massage.
|
Locale |
getLocale()
Get the Locale best fitting this application language map.
|
static AppLangMap |
getMap(CharSequence langCode)
Fetch language specifics for applications.
|
static AppLangMap |
getUMap()
Language specifics for applications, user setting.
|
static boolean |
isJarSigned()
jar file for resource is signed.
|
protected static PropMap |
langSubSet(CharSequence langCode)
PropMap object with language subset.
|
String |
languageName(CharSequence lang,
boolean abbrev)
Fetching a language descriptor.
|
static void |
main(String[] args)
Start as application.
|
String |
month(int m)
Fetching the full month.
|
PropMapHelper.Entry |
put(PropMapHelper.Entry newEntry)
Enter a key value pair.
|
protected boolean |
remove(int i)
Remove an entry by index.
|
String |
shortMonth(int m)
Fetching the abbreviated month.
|
String |
shortWeekDay(int wd)
Fetching the abbreviated day of week.
|
String |
summerTime(boolean summer,
boolean abbrev)
Fetching summer / winter time.
|
String |
timeZone(CharSequence zone,
boolean summer,
boolean abbrev)
Fetching time zone descriptors.
|
static String |
valueUL(CharSequence key)
Fetch value in user language for a key.
|
static String |
valueUL(CharSequence key,
String def)
Fetch value in user language for a key.
|
String |
weekDay(int wd)
Fetching the full day of week.
|
add, asProperties, clear, clone, containsKey, containsValue, deepIt, entrySet, equals, get, getBoolean, getBoolean, getBoolean, getInt, getInt, getLanguage, getLong, getProperty, getProperty, getProperty, getProperty, getRegion, getString, getString, hashCode, hashQuality, indexOfKey, isEmpty, keySet, load, load1, load1, put, putAll, putIfAbsent, putImpl, putNewImpl, putNewImut, rehash, rehash, remove, remove, replace, replace, setLanguage, setNewProperty, setNewProperty, setProperty, setProperty, setProperty, setRegion, size, sortedKeys, sortedList, store, subSet, substLang, toString, value, valueLang
values
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
protected static final ReentrantReadWriteLock.ReadLock rLock
wLock
.protected static final ReentrantReadWriteLock.WriteLock wLock
rLock
).public static final int VL_CL
17
public static final int S_B
39
public static final int anzDatLangKeys
public static final int S_E
public static final int anzSuplKeys
public static final int Z_B
public static final int anzTimeZoneKeysKeys
public static final int anzStdKeys
public static final AppLangMap MAP_de
public static final AppLangMap MAP_en
public final String langCode
AppLangMap
object (langCode singleton).protected static SoftReference<PropMap> langPropMapRef
protected final PropMapHelper.Entry[] stdEntries
protected volatile Locale locale
public static boolean isJarSigned()
public static AppLangMap getUMap()
AppLangMap
to the
last set user's language (like reported e,g, via App
and
Prop
).ComVar.UL
.AppLangMap
object prepared before. So if in doubt about the user's
language settings use this method instead of using a stored language.public StringBuilder completeList(StringBuilder bastel)
StringBuilder
bastel will be a list of all entries
using at least one line per entry (PropMapHelper.Entry
). The list
starts with all standard entries in their natural order. All other entries
follow in alphabetical order.bastel
- StringBuilder to append to. If null it will be made with
~ PropMap.size()
* 43 characters starting capacity.PropMap.toString()
,
PropMap.hashQuality(StringBuilder)
,
PropMap.sortedList(StringBuilder)
,
completeList(StringBuilder)
protected static PropMap langSubSet(CharSequence langCode)
langCode
will be determined. If langCode
's length is not
2 or if the subset is empty null will be returned.public static AppLangMap getMap(CharSequence langCode)
AppLangMap
object fitting the langCode
will be
determined respectively made on first request end returned.App
inheritors or Prop
) is taken. To get this, it's
recommended to use getUMap()
instead of this method with a null
parameter.public void clear(int startCap)
AppLangMap
empty, except for the
special entries (also available indexed).startCap
will be raised to a minimum of 267.public final String summerTime(boolean summer, boolean abbrev)
MAP_de
would return
according to the parameter values:summer
- true : Summer or day light saving timeabbrev
- true: abbreviate instead of full wordspublic final String timeZone(CharSequence zone, boolean summer, boolean abbrev)
MAP_de
and the CET zone
this method would return according to the boolean parameter
values:zone
- the time zone like CET (MEZ), EET, WET, GMT, UTC
(three letter code)summer
- true : Summer or day light saving time if applicable
(irrelevant for UTC, GMT)abbrev
- true: abbreviate instead of full wordspublic final String languageName(CharSequence lang, boolean abbrev)
AppLangMap
object for nd (= Dutch) "hollandaise"
respectively abbreviated "holl." would be returned.AppLangMap
's own
language langCode
is taken.lang
- language to denote as ISO 2 character code (de,
en, fr, it, es, pt, nl, da ...); case or surrounding white space
are ignored; null is own languageabbrev
- true: abbreviate (angl.) instead of full name (anglais)public final String month(int m)
m
- Month (1=January .. 12=December)ComVar.EMPTY_STRING
)shortMonth(int)
,
weekDay(int)
public final String shortMonth(int m)
m
- Month (1=January .. 12=December)ComVar.EMPTY_STRING
)month(int)
public final String weekDay(int wd)
wd
- day of week (0=Sunday .. 6=Saturday, 7=Sunday)ComVar.EMPTY_STRING
)shortWeekDay(int)
,
month(int)
public final String shortWeekDay(int wd)
wd
- day of week (0=Sunday .. 6=Saturday, 7=Sunday)ComVar.EMPTY_STRING
)weekDay(int)
public static int contNo(CharSequence key)
key
non regarding case or surrounding
white space its assigned index is returned; or -1 otherwise.PropMap.containsKey(java.lang.Object)
public static final String valueUL(CharSequence key)
getUMap()
,
Prop.valueLang(CharSequence)
public static final String valueUL(CharSequence key, String def)
key
will be stripped from surrounding whitespace. If key
is (then) empty, def
will be returned.key
is
searched for. If found and not null it is returned or otherwise
def
.entry(CharSequence)
(bringing the comfort to internationalised applications in the end) the
last VL_CL
findings will be cached for quick retrieval. So,
applications may just use this method without concerns or caching
exertions.public static StringBuilder formMessageUL(CharSequence key, String patternDefault, Object param)
key
and the user's set language a pattern
will be determined by
valueUL(key, patternDefault)
.param
is null the pattern just determined is returned as
is.param
to form a message as by
messageFormat(null, pattern, param)
. This message is returned.key
- a language independent key for the user language dependent
patternpatternDefault
- substitute pattern if indeterminable (as not null)
by keyparam
- the parameters to be parts of the messagepublic PropMapHelper.Entry put(PropMapHelper.Entry newEntry) throws UnsupportedOperationException
put
in class PropMap
newEntry
- an Entry object (according to the contract) or nullUnsupportedOperationException
- if an immutable entry would
have to be replaced / modifiedPropMap.put(de.frame4j.util.PropMapHelper.Entry)
public final PropMapHelper.Entry entry(CharSequence key)
entry
in class PropMap
Map.get(java.lang.Object)
,
PropMap.get(Object)
protected boolean remove(int i)
public Locale getLocale()
public static void main(String[] args)
Prop
's default options (see
Prop.Prop()
).Prop
's
option parameter is used.AppLangMap
object and lists
its key-value-pairs. If not available for the language, a substitute
according to AppLangMap
's rules is taken.App
.