本文整理汇总了Java中com.ibm.icu.util.ULocale.forLanguageTag方法的典型用法代码示例。如果您正苦于以下问题:Java ULocale.forLanguageTag方法的具体用法?Java ULocale.forLanguageTag怎么用?Java ULocale.forLanguageTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.util.ULocale
的用法示例。
在下文中一共展示了ULocale.forLanguageTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readExternal
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
in.readByte(); // version.
locale = ULocale.forLanguageTag(in.readUTF());
formatWidth = fromFormatWidthOrdinal(in.readByte() & 0xFF);
numberFormat = (NumberFormat) in.readObject();
if (numberFormat == null) {
throw new InvalidObjectException("Missing number format.");
}
subClass = in.readByte() & 0xFF;
// This cast is safe because the serialized form of hashtable can have
// any object as the key and any object as the value.
keyValues = (HashMap<Object, Object>) in.readObject();
if (keyValues == null) {
throw new InvalidObjectException("Missing optional values map.");
}
}
示例2: readObject
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
* Custom deserialization, new in ICU 4.8. See comments on writeObject().
* @throws InvalidObjectException if the objects read from the stream is invalid.
*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
// ICU 4.8 custom deserialization.
String languageTag = (String)in.readObject();
ulocale = ULocale.forLanguageTag(languageTag);
MessagePattern.ApostropheMode aposMode = (MessagePattern.ApostropheMode)in.readObject();
if (msgPattern == null || aposMode != msgPattern.getApostropheMode()) {
msgPattern = new MessagePattern(aposMode);
}
String msg = (String)in.readObject();
if (msg != null) {
applyPattern(msg);
}
// custom formatters
for (int numFormatters = in.readInt(); numFormatters > 0; --numFormatters) {
int formatIndex = in.readInt();
Format formatter = (Format)in.readObject();
setFormat(formatIndex, formatter);
}
// skip future (int, Object) pairs
for (int numPairs = in.readInt(); numPairs > 0; --numPairs) {
in.readInt();
in.readObject();
}
}