本文整理汇总了Java中com.google.gwt.core.client.JsonUtils.safeEval方法的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils.safeEval方法的具体用法?Java JsonUtils.safeEval怎么用?Java JsonUtils.safeEval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.core.client.JsonUtils
的用法示例。
在下文中一共展示了JsonUtils.safeEval方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyAlphaMapMaterial
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
public void applyAlphaMapMaterial(Primitive primitive) {
JSONObject uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
uniforms.put("channel", new JSONString("r"));
JSONObject alphaMaterial = new JSONObject();
alphaMaterial.put("type", new JSONString("AlphaMap"));
alphaMaterial.put("uniforms", uniforms);
JSONObject materials = new JSONObject();
materials.put("alphaMaterial", alphaMaterial);
JSONObject components = new JSONObject();
components.put("diffuse", new JSONString("vec3(1.0)"));
components.put("alpha", new JSONString("alphaMaterial.alpha"));
JSONObject fabric = new JSONObject();
fabric.put("materials", materials);
fabric.put("components", components);
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
示例2: applyWaterMaterial
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
public void applyWaterMaterial(Primitive primitive) {
JSONObject uniforms = new JSONObject();
uniforms.put("specularMap", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
uniforms.put("normalMap", new JSONString(GWT.getModuleBaseURL() + "images/waterNormals.jpg"));
uniforms.put("frequency", new JSONNumber(10000.0));
uniforms.put("animationSpeed", new JSONNumber(0.01));
uniforms.put("amplitude", new JSONNumber(1.0));
JSONObject fabric = new JSONObject();
fabric.put("type", new JSONString("Water"));
fabric.put("uniforms", uniforms);
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
示例3: getSavedItems
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private JsoArray<Entry> getSavedItems() {
Storage storage = getStorage();
if (storage != null) {
String data = storage.getItem(SAVED_ITEMS);
JsoArray<Entry> list = null;
if (data != null) {
list = JsonUtils.safeEval(data);
} else {
list = (JsoArray<Entry>) JavaScriptObject.createArray();
}
return list;
} else {
return (JsoArray<Entry>) JavaScriptObject.createArray();
}
}
示例4: testDynamicJsArray_length
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
/** Array of keys is accessible through the JSO. */
public void testDynamicJsArray_length() {
DynamicJsArray arr = JsonUtils.safeEval("[1, \"a\", false]");
assertEquals(3, arr.length());
// Length can be increased arbitrarily, but items default to null.
arr.setLength(6);
assertEquals(6, arr.length());
assertNull(arr.get(3));
// Getting a non-existent element returns null.
assertNull(arr.get(10));
assertNull(arr.typeofIndex(10));
// Array can be shortened, trimming items from the end.
arr.setLength(1);
assertEquals(1, arr.length());
assertEquals(1, arr.getInteger(0));
assertNull(arr.get(1));
}
示例5: testDynamicJsArray_shift
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
/** shift() pops a value off the beginning of the array. */
public void testDynamicJsArray_shift() {
DynamicJsArray arr = JsonUtils.safeEval("[false, 1.2, 12, \"a\", {\"a\":\"b\"}]");
assertEquals(5, arr.length());
assertFalse(arr.shiftBoolean());
assertEquals(4, arr.length());
assertEquals(1.2, arr.shiftDouble());
assertEquals(3, arr.length());
assertEquals(12, arr.shiftInteger());
assertEquals(2, arr.length());
assertEquals("a", arr.shiftString());
assertEquals(1, arr.length());
DynamicJso jso = arr.shift();
assertEquals(0, arr.length());
assertEquals(1, jso.keys().length());
assertEquals("b", jso.getString("a"));
// With nothing remaining, shift() returns null.
assertNull(arr.shift());
}
示例6: testDynamicJsArray_typeof
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
/** The type of data stored in the array is accessible as expected. */
public void testDynamicJsArray_typeof() {
DynamicJsArray arr = JsonUtils.safeEval("[1.2, 12, \"foo\", false, [\"a\"], {\"fa\":\"bar\"}]");
assertEquals(JsType.NUMBER, arr.typeofIndex(0));
assertEquals(JsType.INTEGER, arr.typeofIndex(1));
assertEquals(JsType.STRING, arr.typeofIndex(2));
assertEquals(JsType.BOOLEAN, arr.typeofIndex(3));
assertEquals(JsType.ARRAY, arr.typeofIndex(4));
assertEquals(JsType.OBJECT, arr.typeofIndex(5));
}
示例7: testDynamicJso_keys
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
/** Array of keys is accessible through the JSO. */
public void testDynamicJso_keys() {
DynamicJso jso = JsonUtils.safeEval("{\"a\":{\"foo\":\"bar\"}}");
assertEquals(1, jso.keys().length());
assertEquals("a", jso.keys().get(0));
jso = JavaScriptObject.createObject().cast();
jso.set("a", true);
jso.set("b", false);
jso.set("c", 123);
assertEquals(3, jso.keys().length());
assertEquals("a", jso.keys().get(0));
assertEquals("b", jso.keys().get(1));
assertEquals("c", jso.keys().get(2));
// Getting a non-existent key return null
assertNull(jso.get("zzz"));
assertNull(jso.typeofKey("zzz"));
}
示例8: deserializeAsCollection
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response,
DeserializationContext context) {
JsArray<T> jsArray = JsonUtils.safeEval(response);
if (collectionType.equals(List.class) || collectionType.equals(Collection.class)) {
return (C) new JsArrayList(jsArray);
} else {
C col = context.getContainerInstance(collectionType);
for (int i = 0; i < jsArray.length(); i++) {
T t = jsArray.get(i);
col.add(t);
}
return col;
}
}
示例9: getRestAreas
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
private void getRestAreas() {
String jsonString = AppBundle.INSTANCE.restAreaData().getText();
RestAreaFeed restAreas = JsonUtils.safeEval(jsonString);
RestAreaItem item;
for (int i = 0; i < restAreas.getRestAreas().length(); i++){
item = new RestAreaItem();
item.setId(i);
item.setRoute(restAreas.getRestAreas().get(i).getRoute());
item.setLocation(restAreas.getRestAreas().get(i).getLocation());
item.setDescription(restAreas.getRestAreas().get(i).getDescription());
item.setMilepost(restAreas.getRestAreas().get(i).getMilepost());
item.setDirection(restAreas.getRestAreas().get(i).getDirection());
item.setLatitude(restAreas.getRestAreas().get(i).getLatitude());
item.setLongitude(restAreas.getRestAreas().get(i).getLongitude());
item.setNotes(restAreas.getRestAreas().get(i).getNotes());
item.setHasDump(restAreas.getRestAreas().get(i).hasDump());
item.setOpen(restAreas.getRestAreas().get(i).isOpen());
item.setAmenities(restAreas.getRestAreas().get(i).getAmenities());
restAreaItems.add(item);
}
drawRestAreasLayer();
}
示例10: onSubmit
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
public void onSubmit(String results) {
initForm();
JavaScriptObject jsResponse = JsonUtils.safeEval(results);
if (jsResponse != null) {
JSONObject response = new JSONObject(jsResponse);
if (response.get("document") != null) {
JSONObject document = response.get("document").isObject();
DocumentData data = new DocumentData(document.get("fileName").isString().stringValue(),
new Double(document.get("size").isNumber().doubleValue()).longValue(),
null);
data.setContentId(document.get("contentId").isString().stringValue());
setValue(data,
true);
} else if (response.get("error").isNull() != null) {
setValue(null,
true);
}
}
}
示例11: getNumberArrayAttribute
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
private List<Double> getNumberArrayAttribute(SliderOption option, List<Double> defaultValue) {
// Get array attribute
JsArrayNumber array = null;
if (isAttached()) {
array = getNumberArrayAttribute(getElement(), option.getName());
} else {
String value = attributeMixin.getAttribute(option.getDataAttribute());
if (value != null && !value.isEmpty()) {
array = JsonUtils.safeEval(value);
}
}
// Attribute not set
if (array == null) {
return defaultValue;
}
// Put array to list
List<Double> list = new ArrayList<Double>(array.length());
for (int i = 0; i < array.length(); i++) {
list.add(array.get(i));
}
return list;
}
示例12: getStringArrayAttribute
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
private List<String> getStringArrayAttribute(SliderOption option, List<String> defaultValue) {
// Get array attribute
JsArrayString array = null;
if (isAttached()) {
array = getStringArrayAttribute(getElement(), option.getName());
} else {
String value = attributeMixin.getAttribute(option.getDataAttribute());
if (value != null && !value.isEmpty()) {
array = JsonUtils.safeEval(value);
}
}
// Attribute not set
if (array == null) {
return defaultValue;
}
// Put array to list
List<String> list = new ArrayList<String>(array.length());
for (int i = 0; i < array.length(); i++) {
list.add(array.get(i));
}
return list;
}
示例13: getSamplePoint
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
private PointRegisterJSO getSamplePoint(VehicleJSO vehicleJSO) {
String data = SampleDataProvider.INSTANCE.lastPointRegister()
.getText();
PointRegisterListResponseJSO pointRegisterResponse = JsonUtils
.safeEval(data);
PointRegisterJSO point = pointRegisterResponse
.getPointRegisterListEmbededJSO().getPointRegister()[0];
return point;
}
示例14: getSamplePoints
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
private void getSamplePoints(VehicleJSO vehicleJSO, String startDate, String endDate) {
String plate = "";
if ("29085257".equals(vehicleJSO.getPlate())) {
plate = SampleDataProvider.INSTANCE.list20RegisterPoint().getText();
} else if ("39213844".equals(vehicleJSO.getPlate())) {
plate = SampleDataProvider.INSTANCE.list500RegisterPoint()
.getText();
}
PointRegisterListResponseJSO pointRegisterResponse = JsonUtils
.safeEval(plate);
PointRegisterJSO[] pointRegisters = pointRegisterResponse
.getPointRegisterListEmbededJSO().getPointRegister();
List<PointRegisterJSO> points = Arrays.asList(pointRegisters);
if (points.size() == 0) {
messageDialogBuilder
.createInfo("Atención",
"No se encuentran datos registrados para la fecha especificada")
.show();
return;
}
createRouteLayer(vehicleJSO, startDate, points);
}
示例15: convert
import com.google.gwt.core.client.JsonUtils; //导入方法依赖的package包/类
public <V> V convert(Object object, Class<V> clazz) {
if (object == null) {
return null;
} else if (object.getClass().equals(clazz)) {
return (V) object;
} else if (object instanceof String) {
return read((String) object, clazz);
} else if (object instanceof Collection) {
Collection<?> objects = (Collection<?>) object;
if (JavaScriptObject.class.equals(clazz)) {
JsObjectArray<JavaScriptObject> jsArray = JsObjectArray.create();
for (Object o : objects) {
jsArray.add(convert(o, JavaScriptObject.class));
}
return (V) jsArray;
}
} else if (object instanceof JsonBuilder) {
JsonBuilder jsonBuilder = (JsonBuilder) object;
if (JavaScriptObject.class.equals(clazz)) {
return jsonBuilder.getDataImpl();
} else {
return convert(jsonBuilder.getDataImpl(), clazz);
}
} else if (object instanceof JavaScriptObject) {
JavaScriptObject jso = (JavaScriptObject) object;
if (JSONObject.class.equals(clazz)) {
return (V) new JSONObject(jso);
} else {
return read(JsonUtils.stringify(jso), clazz);
}
} else if (clazz.equals(JavaScriptObject.class) && mappers.containsKey(object.getClass())) {
return (V) JsonUtils.safeEval(write(object));
}
throw new UnsupportedOperationException("Conversion not supported: object=" + String.valueOf(object) + ",clazz=" + String.valueOf(clazz));
}