本文整理匯總了Java中com.google.gwt.json.client.JSONValue.isNumber方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONValue.isNumber方法的具體用法?Java JSONValue.isNumber怎麽用?Java JSONValue.isNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.json.client.JSONValue
的用法示例。
在下文中一共展示了JSONValue.isNumber方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
public IFlowRequest create(JSONArray state, Integer initialItemIndex) {
IFlowRequest flowRequest = null;
if (initialItemIndex != null) {
flowRequest = new FlowRequest.NavigateGotoItem(initialItemIndex);
} else if (state != null) {
JSONValue firstState = state.get(0);
if (firstState.isNumber() != null) {
flowRequest = getFlowRequestFromNumber(firstState);
} else if (firstState.isString() != null) {
flowRequest = getFlowRequestFromString(firstState);
}
}
return flowRequest;
}
示例2: setState
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
@Override
public void setState(JSONArray newState) {
JSONValue jsonValue = newState.get(0);
if (jsonValue.isNumber() != null) {
int idFromState = (int) jsonValue.isNumber().doubleValue();
assetId = Optional.of(idFromState);
}
}
示例3: getLongValue
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
private static long getLongValue(JSONObject obj, String fieldName) throws JSONException {
JSONValue jsonLongValue = obj.get(fieldName);
if (jsonLongValue == null) {
throw new JSONException("Expected JSON Object with attribute " + fieldName + ": " + obj.toString());
}
JSONNumber jsonLong = jsonLongValue.isNumber();
if (jsonLong == null) {
throw new JSONException("Expected JSON number: " + jsonLongValue.toString());
}
return (long) jsonLong.doubleValue();
}
示例4: retrieveErrorCode
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
private static int retrieveErrorCode(JSONObject exc) {
JSONValue val = exc.get("httpErrorCode");
if (val == null || val.isNumber() == null) {
return -1;
} else {
return (int) val.isNumber().doubleValue();
}
}
示例5: processResult
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
@Override
public void processResult(String result) {
JSONObject object = controller.parseJSON(result).isObject();
if (object != null) {
String timeStamp = DateTimeFormat.getFormat(PredefinedFormat.HOUR24_MINUTE)
.format(new Date(System.currentTimeMillis()));
addRow();
loadTable.setValue(loadTable.getNumberOfRows() - 1, 0, timeStamp);
boolean initColumns = super.initColumns();
int colIndex = 1;
for (String key : object.keySet()) {
if (initColumns) {
loadTable.addColumn(ColumnType.NUMBER, beautifyName(key));
}
double value = 0;
JSONValue jsonVal = object.get(key).isArray().get(0).isObject().get("value");
if (jsonVal != null && jsonVal.isNumber() != null) {
value = jsonVal.isNumber().doubleValue();
}
loadTable.setValue(loadTable.getNumberOfRows() - 1, colIndex++, value);
}
loadChart.draw(loadTable, loadOpts);
}
}
示例6: getNumberValueFor
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
public Integer getNumberValueFor(EditorProperties property) {
JSONValue jsonValue = getJsonValueFor(property);
if (jsonValue == null) {
return null;
}
JSONNumber jsonNumber = jsonValue.isNumber();
if (jsonNumber == null) {
return null;
}
Double result = jsonNumber.doubleValue();
return result.intValue();
}
示例7: create
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
/**
* Creates one of implementations of {@link EditorPropertyWidget}.
*
* @return an instance of {@link EditorPropertyWidget}
*/
public EditorPropertyWidget create(@NotNull String propertyName, @NotNull JSONValue value) {
if (value.isBoolean() != null) {
return new EditorBooleanPropertyWidget(propertyName, value.isBoolean().booleanValue());
}
if (value.isNumber() != null) {
Double doubleValue = value.isNumber().doubleValue();
return new EditorNumberPropertyWidget(propertyName, doubleValue.intValue());
}
return new EditorStringPropertyWidget(propertyName, value.toString());
}
示例8: matches
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
private static boolean matches(JSONValue element, JsonDecision decision) {
if (decision == JsonDecision.LIST) {
return element.isArray() != null;
}
if (decision == JsonDecision.BOOLEAN) {
return element.isBoolean() != null;
}
if (decision == JsonDecision.NUMBER) {
return element.isNumber() != null;
}
if (decision == JsonDecision.STRING) {
return element.isString() != null;
}
return element.isObject() != null;
}
示例9: setJSONValue
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
@Override
public void setJSONValue(JSONValue value) {
JSONNumber numberVal = value.isNumber();
JSONString stringVal = value.isString();
if (numberVal != null) {
textbox.setValue(String.valueOf(numberVal.doubleValue()));
} else if (stringVal != null){
textbox.setValue(stringVal.stringValue());
} else {
throw new JSONException("Not a valid JSON number: " + value.toString());
}
}
示例10: getPrimaryKey
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
public Object getPrimaryKey(AbstractRecord record) {
if (record.getCorrespondingJsonObject().containsKey(pkAttribute)) {
JSONValue value = record.getCorrespondingJsonObject().get(pkAttribute);
if (value.isNumber() != null) {
return new Long((long) value.isNumber().doubleValue());
}
if (value.isString() != null) {
return value.isString().stringValue();
}
}
return null;
}
示例11: getJsonLongValue
import com.google.gwt.json.client.JSONValue; //導入方法依賴的package包/類
/**
* Helper function to extract a long value from given JSON object.
*
* @param json JSON object to extract the value from.
* @param key key of the value to extract.
* @return the Long object extracted from JSON (can be null if the value does
* not exist or is invalid.
*/
private static Long getJsonLongValue(JSONObject json, String key) {
JSONValue value = json.get(key);
JSONNumber number = value == null ? null : value.isNumber();
return number != null ? Math.round(number.doubleValue()) : null;
}