public class GrowableInternationalString extends AbstractInternationalString implements Serializable
Constructor and Description |
---|
GrowableInternationalString()
Constructs an initially empty international string.
|
GrowableInternationalString(String string)
Constructs an international string initialized with the specified string.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Locale locale,
String string)
Adds a string for the given locale.
|
boolean |
add(String prefix,
String key,
String string)
Adds a string for the given property key.
|
boolean |
equals(Object object)
Compares this international string with the specified object for equality.
|
Set<Locale> |
getLocales()
Returns the set of locales defined in this international string.
|
int |
hashCode()
Returns a hash code value for this international text.
|
boolean |
isSubsetOf(Object candidate)
Returns
true if all localized texts stored in this international string are contained
in the specified object. |
String |
toString(Locale locale)
Returns a string in the specified locale.
|
charAt, compareTo, length, subSequence, toString
chars, codePoints
public GrowableInternationalString()
add(...)
methods.public GrowableInternationalString(String string)
add(...)
methods. The string
specified to this constructor is the one that will be returned if no localized string is
found for the Locale
argument in a call to toString(Locale)
.string
- The string in no specific locale.public void add(Locale locale, String string) throws IllegalArgumentException
locale
- The locale for the string
value, or null
.string
- The localized string.IllegalArgumentException
- if a different string value was already set for the given
locale.public boolean add(String prefix, String key, String string) throws IllegalArgumentException
AbstractInternationalString
during iteration through the entries in a Map
. It infers the Locale
from the property
key
, using the following steps:
key
do not starts with the specified prefix
, then this method do
nothing and returns false
.
prefix
are parsed as an ISO language and
country code, and the add(Locale,String)
method is invoked.
For example if the prefix is "remarks"
, then the "remarks_fr"
property key stands for remarks in French while the
"remarks_fr_CA"
property key stands for remarks in French Canadian.
prefix
- The prefix to skip at the begining of the key
.key
- The property key.string
- The localized string for the specified key
.true
if the key has been recognized, or false
otherwise.IllegalArgumentException
- if the locale after the prefix is an illegal code, or a
different string value was already set for the given locale.public Set<Locale> getLocales()
public String toString(Locale locale)
locale
, then this method search for a locale without the variant part. If no string are found, then this method search for a locale without the
country part. For example if the "fr_CA"
locale
was requested but not found, then this method looks for the "fr"
locale. The
null
locale (which stand for unlocalized message) is tried last.toString
in interface InternationalString
toString
in class AbstractInternationalString
locale
- The locale to look for, or null
.public boolean isSubsetOf(Object candidate)
true
if all localized texts stored in this international string are contained
in the specified object. More specifically:
If candidate
is an instance of InternationalString
, then this method
returns true
if, for all locale-string pairs contained in this
, candidate.toString(locale)
returns a string
equals to string
.
If candidate
is an instance of CharSequence
, then this method
returns true
if toString(Locale)
returns a string equals to candidate.toString()
for all locales.
If candidate
is an instance of Map
, then this methods returns true
if all locale-string pairs are contained into candidate
.
Otherwise, this method returns false
.
candidate
- The object which may contains this international string.true
if the given object contains all localized strings found in this
international string.public boolean equals(Object object)
Copyright © 1996–2019 Geotools. All rights reserved.