本文整理匯總了Java中org.mozilla.javascript.Context.toNumber方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.toNumber方法的具體用法?Java Context.toNumber怎麽用?Java Context.toNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mozilla.javascript.Context
的用法示例。
在下文中一共展示了Context.toNumber方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseResult
import org.mozilla.javascript.Context; //導入方法依賴的package包/類
private KeyboardEntry parseResult(NativeObject nativeObject) {
List<List<KeyEntry>> keyboard = new ArrayList<>(5);
int index = 0;
String presetNumber = null;
KeyboardType keyboardType = null;
NumberType presetNumberType = NumberType.AUTO_DETECT;
int numberLength = 0;
int numberLimitLength = 0;
NumberType detectedNumberType = NumberType.AUTO_DETECT;
Set<Map.Entry<Object, Object>> entrySet = nativeObject.entrySet();
for (Map.Entry<Object, Object> entry : entrySet) {
final String key = entry.getKey().toString();
final Object value = entry.getValue();
if ("index".equals(key)) {
index = (int) Context.toNumber(value);
} else if ("presetNumber".equals(key)) {
presetNumber = Context.toString(value);
} else if ("keyboardType".equals(key)) {
keyboardType = KeyboardType.values()[(int) Context.toNumber(value)];
} else if ("numberType".equals(key)) {
presetNumberType = NumberType.values()[(int) Context.toNumber(value)];
} else if ("numberLength".equals(key)) {
numberLength = (int) Context.toNumber(value);
} else if ("numberLimitLength".equals(key)) {
numberLimitLength = (int) Context.toNumber(value);
} else if (key.startsWith("row")) {
List<KeyEntry> keyList = getKeyEntries(entry);
if (keyList == null) {
continue;
}
keyboard.add(keyList);
} else if ("detectedNumberType".equals(key)) {
detectedNumberType = NumberType.values()[(int) Context.toNumber(value)];
}
}
return new KeyboardEntry(index, presetNumber, keyboardType, presetNumberType, numberLength,
numberLimitLength, keyboard, detectedNumberType);
}