public class iContext
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
iContext encapsulates international context sensitivity for the webMethods platform. This includes locale, language preference, collation (sorting), currency, region, time zone, and calendar preferences.
This class relies heavily on utility classes that encapsulate the related standards. When you construct and set a field in this class, it will always contain the nearest match to the related standard for that particular field. You can set a field to any value (similar to a Java locale object), but webMethods does not guarantee interoperability or any functionality related to these non-standard values.
The standards encapsulated by this class are:
For specific information, see the following sites:
The non-standard items in the iContext are based on the IBM International Classes for Unicode for Java (ICU4J) library and the related internationalization and Unicode standards. For specific information, see the following sites:
iContext supports the Microsoft .NET CultureInfo identifier, which Microsoft calls an 'rfc1766 ID'. RFC1766 was the precursor to RFC3066. In addition, Microsoft has a few proprietary add-on codes that extend these standards. iContext parses these additional values and populates the correct field for the given value (for example, the "Region" code "CB" for Caribbean is mapped correctly and not to a variant). Note that other platforms may not fully support these values.
iContext is constructed from an RFC3066bis identifier. RFC3066bis is an Internet-draft. This draft is a replacement for RFC3066 and provides a number of extensions to the older form. Although iContext uses RFC3066bis extension mechanism to store some proprietary values (such as, collation parameters), it should be regarded as the source for valid behavior of an iContext.
Serialization of an iContext has changed in this version to be an RFC3066bis string. The older URN string syntax remains and is extended to be compatible with v1.0 of this class (used in the webMethods 6.1 product). The URN format provides support for all of the fields in an iContext, and thus is lossless. An RFC3066 string stores only the four most important values (language, region, script, and variant). RFC3066bis stores everything, so it should be regarded as the "native" serialization format.
The URN is the format used by the toUrnString() method of the class and for serialization within the webMethods platform.
Validation and matching methods look only at a subset of fields in an iContext. webMethods looks only at RFC3066bis identifying fields plus some extensions. The expected pattern is:
The fallback pattern is similar to Java. webMethods remove elements from right-to-left. Empty fields are allowed. Script is mostly unpopulated except for a few minor languages (Uzbek, Serbian, Azeri) and one major one(Chinese).
The wmResourceBundleLoader understands iContext in ResourceBundle lookups, which enables you to create non-Java resources. Regular ResourceBundle can also be used to access these resources, but you must use the JavaLocale class in a non-strict mode.
The iContext class also supports four specialized or 'abstract' iContext values. The abstract values are used to set execution policy in the Integration Server.
The four values are:
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KEY_CONCRETE
(Convenience) Constant used to specify the iContext is not abstract.
|
static java.lang.String |
KEY_DEFAULT
(Convenience) Constant used to specify the server-default iContext.
|
static java.lang.String |
KEY_NEUTRAL_DEFAULT
(Convenience) Constant used to specify the neutral iContext.
|
static java.lang.String |
KEY_USER_DEFAULT
(Convenience) Constant used to specify the user-default iContext.
|
Constructor and Description |
---|
iContext()
Creates a new, empty instance of iContext.
|
iContext(iContext p_iContext)
Creates a new instance of iContext from another iContext.
|
iContext(java.util.Locale p_Locale)
Creates a new instance of iContext using the language, country and
variant of the provided Java locale object.
|
iContext(java.lang.String p_LocaleString)
Creates a new iContext based on the RFC3066 string provided.
|
iContext(java.lang.String p_lang,
java.lang.String p_script,
java.lang.String p_variant,
java.lang.String p_region)
Creates a new instance of iContext with the provided language, script, region and variant values.
|
Modifier and Type | Method and Description |
---|---|
void |
addExtension(java.lang.String key,
java.lang.String value)
Inserts the given extension value with the given key.
|
void |
addSubLang(java.lang.String extlang)
Adds the specific sublanguage to the end of the list of sublanguages.
|
void |
addVariant(java.lang.String p_sVariant)
Adds a variant to the list of variants.
|
void |
clearExtensions()
Removes all the extensions.
|
void |
clearSubLangs()
Removes all of the sublanguages from the list and
deletes the references to sublanguages from the internal store.
|
void |
clearVariants()
Clears all the variants associated with this iContext.
|
java.lang.Object |
clone()
Duplicates this iContext object.
|
boolean |
equals(iContext p_IContext)
Determines whether the iContexts are equal.
|
boolean |
equals(java.lang.String p_sLocale)
Determines whether the locale in this iContext matches the provided locale.
|
java.lang.String |
getAbstractKey()
Returns the key string for the iContext(
KEY_DEFAULT , KEY_NEUTRAL_DEFAULT ,
or KEY_USER_DEFAULT ), if this is an abstract iContext (it is being used as a policy). |
java.lang.String |
getCultureInfo()
Converts to a Microsoft .NET String format.
|
java.lang.String |
getCurrency()
Returns the currency in the form of an ISO 4217 code.
|
java.lang.String |
getCurrency(boolean p_bAllowGuessing)
Returns the currency in the form of an ISO 4217 code.
|
static iContext |
getDefault()
Returns the iContext described by the JVM default Locale object.
|
java.lang.String |
getEncoding()
Returns the encoding
|
java.lang.String |
getExtension(java.lang.String key)
Returns the specified extension.
|
java.util.Iterator |
getExtensions()
Returns an iterator over the set of extension values.
|
java.lang.String |
getISOCountry()
Returns the country code as an ISO 3166 2-letter code.
|
java.lang.String |
getISOCountry3()
Returns the country code as an ISO 3166 3-letter code.
|
java.lang.String |
getISOCurrency()
Returns the currency in the form of an ISO 4217 code.
|
java.lang.String |
getISOLanguage()
Returns the language for this iContext as an ISO 639 Code 2-letter code.
|
java.lang.String |
getISOLanguage3()
Returns the language for this iContext as an ISO 639 Code 3-letter code.
|
java.lang.String |
getISOScript()
Returns the script as an ISO 15924 Code.
|
java.util.Locale |
getJavaLocale(boolean p_bBestMatch)
Returns the Java locale that most closely matches this iContext or a Java
locale that holds the iContext information.
|
java.lang.String |
getLanguage()
Returns the language for this iContext.
|
static iContext |
getNeutral()
Returns the neutral (abstract) iContext described by KEY_NEUTRAL_DEFAULT.
|
java.lang.String |
getPosix()
Converts the iContext into a POSIX locale using UTF8 encoding.
|
java.lang.String |
getPosix(java.lang.String encoding)
Converts to a POSIX locale string using the provided encoding.
|
java.lang.String |
getRegion()
Returns the region of this iContext, if any.
|
java.lang.String |
getRfc3066()
Converts the IContext into a RFC3066 language tag.
|
java.lang.String |
getScript()
Returns the script.
|
java.util.Iterator |
getSubLangs()
Returns an iterator over the list of sublanguages.
|
java.util.TimeZone |
getTimeZone()
Returns the timezone as a Java TimeZone.
|
java.lang.String |
getTimeZoneID()
Returns the current timeZone ID.
|
java.util.Iterator |
getVariants()
Returns the list of variants
|
boolean |
hasExtensions()
Determines if this iContext has any extension values.
|
boolean |
hasSubLangs()
Determines if this iContext has a sublanguage (also referred to as extended language code).
|
boolean |
hasVariants()
Determines if the iContext has any variants.
|
boolean |
isAbstract()
Determines if this iContext is abstract.
|
boolean |
isCountryNeutral()
Determines if the country or region is not set.
|
boolean |
isCurrencyEuro()
Determines if the currency corresponds to the EURO.
|
boolean |
isCurrencySet()
Determines if the currency is set.
|
boolean |
isEncodingSet()
Determines if the encoding is set.
|
boolean |
isLanguageSet()
Determines if the language parameter is set.
|
boolean |
isNeutral()
Determines if this iContext corresponds to the "neutral" locale.
|
boolean |
isRegionSet()
Determines if the country or region is set.
|
boolean |
isRoot()
(Convenience) Determines if this iContext is the root iContext.
|
boolean |
isScriptSet()
Determines if the script value is not empty.
|
boolean |
isServerDefault()
Determines if this iContext corresponds to the "server default" locale.
|
boolean |
isTimeZoneSet()
Determines if the timezone is set.
|
boolean |
isUserDefault()
Determines if this iContext corresponds to the "user default" locale.
|
boolean |
matches(iContext p_IContext)
Determines whether the fields in this iContext are compatible with those in the other iContext.
|
boolean |
matches(java.lang.String p_sLocale)
Matches the locale of this iContext against a provided locale.
|
iContext |
parent()
Returns the most logical parent iContext.
|
boolean |
removeSubLang(java.lang.String extlang)
Removes the specific sublanguage from the list of sublanguages, if it exists.
|
void |
setCalendarID(java.lang.String p_sCalendarID)
Sets the current calendar to one identified by p_sCalendarID.
|
void |
setCurrency(java.lang.String p_sCurrency)
webMethods strongly encourages you to use ISO 4217 currency codes for this
property.
|
void |
setEncoding(java.lang.String p_sEncoding)
Sets the encoding associated with this locale.
|
void |
setLanguage(java.lang.String p_sLanguage)
Sets the language field in the iContext to the specified value.
|
void |
setRegion(java.lang.String p_sRegion)
For this property, webMethods strongly encourages that you use only ISO 3166 country codes.
|
void |
setScript(java.lang.String p_sScript)
webMethods strongly encourages you to use ISO-15924 script codes for this
property.
|
void |
setTimeZone(java.lang.String p_sTimeZone)
Sets the timezone ID to p_sTimeZone, which must be a valid
Olsen ID, empty string, or null.
|
java.lang.String |
toString()
Converts this iContext to a string.
|
public static final java.lang.String KEY_USER_DEFAULT
public static final java.lang.String KEY_DEFAULT
public static final java.lang.String KEY_NEUTRAL_DEFAULT
public static final java.lang.String KEY_CONCRETE
public iContext()
public iContext(java.util.Locale p_Locale)
p_Locale
- If null, a neutral iContext is constructed.public iContext(iContext p_iContext)
p_iContext
- If null, a neutral iContext is constructed.public iContext(java.lang.String p_lang, java.lang.String p_script, java.lang.String p_variant, java.lang.String p_region)
p_lang
- the language (usually an ISO 639 code)p_script
- the script (usually an ISO 15924 code)p_variant
- the variant (usually an IANA registered variant value)p_region
- the region (usually an ISO 3166 code)public iContext(java.lang.String p_LocaleString)
All other fields are left null and determined at run time from the language and country (if supplied).
If the RFC3066 string cannot be parsed or contains illegal values, this constructor ignores all of the unrecognized fields, sets what it can, and returns with no error. This may lead to an empty iContext.
p_LocaleString
- The string to parse. If null, the "neutral" locale is created.public java.lang.Object clone()
clone
in class java.lang.Object
public static iContext getDefault()
public static iContext getNeutral()
Note that this is not the same as an iContext with all empty fields.
To construct this iContext, use the String constructor
with the empty string or the Locale constructor with the locale
new Locale("","");
.
public void setRegion(java.lang.String p_sRegion)
p_sRegion
- An ISO 3166 2- or 3-letter code or if no other option, an alphanumerical string.
This parameter is not case sensitive.public java.lang.String getRegion()
public java.lang.String getISOCountry()
public java.lang.String getISOCountry3()
public boolean isCountryNeutral()
true
if region is null or has an empty string;
false
otherwise.public boolean isRegionSet()
true
if region is set;
false
otherwise.public void setLanguage(java.lang.String p_sLanguage)
You can set the iContext to an abstract value by passing one of the abstract keys (KEY_DEFAULT, KEY_NEUTRAL_DEFAULT or KEY_USER_DEFAULT). Setting an abstract key loses any existing information stored in this iContext. This is a convenient way to set up an abstract iContext other than via the constructor.
Note that there is a difference between the policy (abstract) iContext "$null" and the empty (neutral) iContext.
p_sLanguage
- an ISO 639 2- or 3-letter code, or if no other option,
an alphanumerical stringpublic java.lang.String getLanguage()
public java.lang.String getISOLanguage()
public java.lang.String getISOLanguage3()
public boolean isLanguageSet()
true
if the language is set;
false
otherwise.public boolean hasSubLangs()
true
if there is at least one sublanguage set;
false
otherwise.public java.util.Iterator getSubLangs()
public void addSubLang(java.lang.String extlang)
extlang
- a 3-letter codepublic boolean removeSubLang(java.lang.String extlang)
extlang
- the sublanguage you want to removetrue
if the sublanguage was removed;
false
otherwise.public void clearSubLangs()
public void setScript(java.lang.String p_sScript)
p_sScript
- an ISO 15924 4-letter code or if no other option, an
alphanumerical stringpublic java.lang.String getScript()
public boolean isScriptSet()
true
if the script is set;
false
otherwise.public java.lang.String getISOScript()
public void clearVariants()
public void addVariant(java.lang.String p_sVariant)
p_sVariant
- the variant string (usually a IANA register variant value)public java.util.Iterator getVariants()
public boolean hasVariants()
true
if the iContext has variants;
false
otherwise.public void setEncoding(java.lang.String p_sEncoding)
p_sEncoding
- encoding name to associate with the localepublic java.lang.String getEncoding()
public boolean isEncodingSet()
true
if the encoding setting for this iContext is not empty;
false
otherwise.public void setCurrency(java.lang.String p_sCurrency)
p_sCurrency
- an ISO 4217 3-letter code or if no other option, an
alphanumerical stringpublic boolean isCurrencySet()
true
if the currency has a non-empty value;
false
otherwise.public java.lang.String getCurrency()
public java.lang.String getISOCurrency()
public boolean isCurrencyEuro()
true
if the currency corresponds to the EURO;
false
otherwise.public java.lang.String getCurrency(boolean p_bAllowGuessing)
p_bAllowGuessing
- true
To allow guessing;
false
otherwise.public void clearExtensions()
public void addExtension(java.lang.String key, java.lang.String value)
key
- the extension key you want to insert (usually a single letter)value
- the key value for the provided extension key. This is usually
an alphanumerical string of 2 or more characters.public java.lang.String getExtension(java.lang.String key)
key
- the key for the extension you want to returnpublic java.util.Iterator getExtensions()
public boolean hasExtensions()
true
if this iContext has extensions;
false
otherwise.public boolean isTimeZoneSet()
true
if the timezone is set;
false
otherwise.public void setTimeZone(java.lang.String p_sTimeZone)
p_sTimeZone
- The timezone you want to use to form a valid Olsen ID.
Specify an empty string or null to unset the timezone.public java.lang.String getTimeZoneID()
public java.util.TimeZone getTimeZone()
public void setCalendarID(java.lang.String p_sCalendarID)
p_sCalendarID
- string for the calendar ID.public iContext parent()
public java.lang.String getAbstractKey()
KEY_DEFAULT
, KEY_NEUTRAL_DEFAULT
,
or KEY_USER_DEFAULT
), if this is an abstract iContext (it is being used as a policy).
If the iContext is concrete (not abstract), returns KEY_CONCRETE
.KEY_DEFAULT
, KEY_NEUTRAL_DEFAULT
,
or KEY_USER_DEFAULT
)public boolean equals(iContext p_IContext)
p_IContext
- iContext to use for comparisontrue
if all fields are equal;
false
otherwise.public boolean equals(java.lang.String p_sLocale)
p_sLocale
- locale to use for the comparisontrue
if all the information carried by the locale is identical to the one in the iContext;
false
otherwise.public boolean matches(iContext p_IContext)
This method only compares the language, region, variant and script fields. Note: The matches test is not the same as the equals test. It determines if this iContext is a logical parent or equal to the provided iContext with regard to resource default.
The following matching order is used:
Matching rules are not case sensitive. For example:
p_IContext
- the iContext with which to compare to the current iContexttrue
if the rules set above are satisfied;
false
otherwise.public boolean matches(java.lang.String p_sLocale)
p_sLocale
- locale to use for the matching testtrue
if various fields match;
false
otherwise.matches(iContext)
public boolean isNeutral()
true
if this iContext corresponds to "neutral";
false
otherwise.public boolean isUserDefault()
true
if this iContext corresponds to "user default";
false
otherwise.public boolean isServerDefault()
true
if this iContext corresponds to "server default";
false
otherwise.public boolean isAbstract()
true
if this iContext is abstract;
false
otherwise.public boolean isRoot()
true
if this iContext is not abstract and
the language, region, script, and variant fields are empty;
false
otherwise.public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Locale getJavaLocale(boolean p_bBestMatch)
p_bBestMatch
- true
To return the closest matching Java Locale;
false
otherwise.public java.lang.String getRfc3066()
public java.lang.String getCultureInfo()
public java.lang.String getPosix()
public java.lang.String getPosix(java.lang.String encoding)
encoding
- encoding string to use for the resulting POSIX localevalue | matches | doesn't match |
en | en-GB, en-GB-Latn | fr |
zh-hant | zh-hant-TW, zh-CHT | zh-TW |