|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.icu.util.ULocale.Builder
public static final class ULocale.Builder
Builder is used to build instances of Locale from values configured by the setter.
Builder supports the 'langtag' production of RFC 4646. Language tags consist of the ASCII digits, upper and lower case letters, and hyphen (which appears only as a field separator). As a convenience, underscores are accepted and normalized to hyphen. Values with any other character are ill-formed. Since language tags are case-insensitive, they are normalized to lower case, case distinctions are not preserved by the builder.
Note that since this implements 'langtag' and not 'Language-Tag',
grandfathered language tags are not supported by the builder.
Clients should use ULocale.forLanguageTag(java.lang.String)
instead.
Builders can be reused; clear()
resets all fields
to their default values.
create()
,
clear()
Constructor Summary | |
---|---|
ULocale.Builder()
Constructs an empty Builder. |
Method Summary | |
---|---|
ULocale.Builder |
clear()
Resets the builder to its initial, default state. |
ULocale.Builder |
clearExtensions()
Resets the extensions to their initial, default state. |
ULocale |
create()
Returns an instance of locale created from the fields set on this builder. |
ULocale.Builder |
setExtension(char key,
java.lang.String value)
Sets the extension for the given key. |
ULocale.Builder |
setLanguage(java.lang.String language)
Sets the language. |
ULocale.Builder |
setLanguageTag(java.lang.String langtag)
Resets the builder to match the provided language tag. |
ULocale.Builder |
setLDMLExtensionValue(java.lang.String key,
java.lang.String value)
Sets the LDML keyword value ('type') for the given key. |
ULocale.Builder |
setLocale(ULocale loc)
Resets the builder to match the provided locale. |
ULocale.Builder |
setRegion(java.lang.String region)
Sets the region. |
ULocale.Builder |
setScript(java.lang.String script)
Sets the script. |
ULocale.Builder |
setVariant(java.lang.String variant)
Sets the variant. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ULocale.Builder()
Method Detail |
---|
public ULocale.Builder setLocale(ULocale loc)
loc
- the locale
IllformedLocaleException
- if loc
has any ill-formed
fields.public ULocale.Builder setLanguageTag(java.lang.String langtag)
langtag
- the language tag
IllformedLocaleException
- if langtag
is ill-formed.ULocale.forLanguageTag(String)
public ULocale.Builder setLanguage(java.lang.String language)
language
- the language
IllformedLocaleException
- if language
is ill-formedpublic ULocale.Builder setScript(java.lang.String script)
script
- the script
IllformedLocaleException
- if script
is ill-formedpublic ULocale.Builder setRegion(java.lang.String region)
region
- the region
IllformedLocaleException
- if region
is ill-formedpublic ULocale.Builder setVariant(java.lang.String variant)
variant
- the variant
IllformedLocaleException
- if variant
is ill-formedpublic ULocale.Builder setExtension(char key, java.lang.String value)
[0-9A-WY-Za-wy-z]
. Well-formed
values are any series of fields of two to eight
alphanumeric characters, separated by hyphen or underscore.
note:The extension 'u' is used for LDML Keywords. Setting the 'u' extension replaces any existing LDML keywords with those defined in the extension. To be well-formed, a value for the 'u' extension must meet the additional constraint that the number of fields be even (fields represent key value pairs, where the value is mandatory), and that the keys and values be legal locale extension keys and values.
key
- the extension keyvalue
- the extension value
IllformedLocaleException
- if key
is illegal
or value
is ill-formedsetLDMLExtensionValue(java.lang.String, java.lang.String)
public ULocale.Builder setLDMLExtensionValue(java.lang.String key, java.lang.String value)
Note:Setting the 'u' extension replaces all LDML keywords with those defined in the extension.
key
- the LDML extension keyvalue
- the LDML extension value
IllformedLocaleException
- if key
or value
is ill-formedsetExtension(char, String)
public ULocale.Builder clear()
public ULocale.Builder clearExtensions()
setExtension(char, String)
public ULocale create()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |