本文整理汇总了Java中com.google.gwt.json.client.JSONBoolean类的典型用法代码示例。如果您正苦于以下问题:Java JSONBoolean类的具体用法?Java JSONBoolean怎么用?Java JSONBoolean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JSONBoolean类属于com.google.gwt.json.client包,在下文中一共展示了JSONBoolean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addOption
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
/**
* Add an option dynamically into the set of options that will be used by the init function
* for TinyMCE.
*
* @param key a string value denoting the configuration parameter (see TinyMCE documentation)
* @param value a value of Boolean, Integer, or String types.
*/
public void addOption(String key, Object value)
{
// do not allow overriding fixed options
if (fixedOptions.contains(key)) {
return;
}
if (value instanceof Boolean) {
options.put(key, JSONBoolean.getInstance((Boolean) value));
} else if (value instanceof Integer) {
options.put(key, new JSONNumber((Integer) value));
} else if (value instanceof String) {
options.put(key, new JSONString((String) value));
} else {
// Shouldn't ever really get to this, but just in case.
options.put(key, new JSONString(value.toString()));
}
}
示例2: helloWorld
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
private void helloWorld() throws Exception {
JSONObject sampleData = new JSONObject();
sampleData.put("Field1", new JSONNumber(1.0));
sampleData.put("Field2", new JSONString("Hello world"));
sampleData.put("Field3", JSONBoolean.getInstance(true));
// Sample 1 - basic usage
final FormLayout formLayout = new FormLayout(sampleData.toString());
RootPanel.get().add(formLayout);
Button button = new Button("Apply");
button.addStyleName(style.apply());
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert(formLayout.getDataJson());
}
});
formLayout.appendWidgetToBottom(button);
}
示例3: convertToJson
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
public static JSONValue convertToJson(Object value) {
if (value instanceof Enum) {
return new JSONString(((Enum<?>) value).name());
} else if (value instanceof String) {
return new JSONString((String) value);
} else if (value instanceof Number) {
return new JSONNumber(((Number) value).doubleValue());
} else if (value instanceof Boolean) {
return JSONBoolean.getInstance((boolean) value);
} else if (value instanceof JsonSerializable) {
return ((JsonSerializable) value).toJsonElement();
} else if (value instanceof JSONValue) {
return (JSONValue) value;
}
throw new RuntimeException("Unexpected runtime value: " + value);
}
示例4: uploadFile
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
private void uploadFile() {
JSONObject post = new JSONObject();
String mime = form.getValueAsString(FIELD_MIMETYPE);
if (mime != null && !mime.trim().isEmpty()) {
post.put(FIELD_MIMETYPE, new JSONString(mime));
}
post.put(FIELD_PID, new JSONString(dobj.getPid()));
String batchId = dobj.getBatchId();
if (batchId != null) {
post.put(FIELD_BATCHID, new JSONString(batchId));
}
post.put(DigitalObjectResourceApi.DISSEMINATION_ERROR, JSONBoolean.getInstance(true));
uploader.setPostParams(post);
uploader.startUpload();
showUploading(true);
}
示例5: deserialize
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
@Override
public CallResponse deserialize(String payload) throws InvalidPayload {
JSONArray array = JSONParser.parseStrict(payload).isArray();
if (array.size() != CallResponse.Message.SIZE) {
throw new InvalidPayload();
}
JSONString token = array.get(
CallResponse.Message.POSITION_TOKEN).isString();
JSONBoolean success = array.get(
CallResponse.Message.POSITION_SUCCESS).isBoolean();
JSONString returnValue = array.get(
CallResponse.Message.POSITION_RETURN_VALUE).isString();
return new CallResponse(
token.stringValue(),
success.booleanValue(),
returnValue.stringValue());
}
示例6: toJSONObject
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
public static JSONObject toJSONObject(Hero hero) {
JSONObject obj = new JSONObject();
obj.put("name", new JSONString(hero.name));
obj.put("id", new JSONNumber(hero.id));
obj.put("level", new JSONNumber(hero.level));
obj.put("paragonLevel", new JSONNumber(hero.paragonLevel));
obj.put("lastUpdated", new JSONNumber(hero.lastUpdated));
obj.put("hardcore", JSONBoolean.getInstance(hero.hardcore));
obj.put("seasonal", JSONBoolean.getInstance(hero.seasonal));
obj.put("dead", JSONBoolean.getInstance(hero.dead));
obj.put("clazz", new JSONString(hero.clazz));
return obj;
}
示例7: saveToBean
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
@Override
public void saveToBean(GeneralItem gi) {
if (form.getValue("isOpenQuestion") != null && (Boolean) form.getValue("isOpenQuestion")) {
JSONObject openQuestion = new JSONObject();
openQuestion.put("withPicture", JSONBoolean.getInstance( form.getValue("openQuestionWithImage")==null?false:(Boolean) form.getValue("openQuestionWithImage")) );
openQuestion.put("withText", JSONBoolean.getInstance( form.getValue(OPENQUESTIONWITHTEXT)==null?false:(Boolean) form.getValue(OPENQUESTIONWITHTEXT)) );
openQuestion.put("withValue", JSONBoolean.getInstance( form.getValue(OPENQUESTIONWITHVALUE)==null?false:(Boolean) form.getValue(OPENQUESTIONWITHVALUE)) );
openQuestion.put("withAudio", JSONBoolean.getInstance( form.getValue(OPENQUESTIONWITHAUTDIO)==null?false:(Boolean) form.getValue(OPENQUESTIONWITHAUTDIO)) );
openQuestion.put("withVideo", JSONBoolean.getInstance( form.getValue("openQuestionWithVideo")==null?false:(Boolean) form.getValue("openQuestionWithVideo")) );
openQuestion.put(OPENQUESTIONVALUEDESC, new JSONString(form.getValueAsString(OPENQUESTIONVALUEDESC)==null?"":form.getValueAsString(OPENQUESTIONVALUEDESC)));
openQuestion.put(OPENQUESTIONTEXTDESC, new JSONString(form.getValueAsString(OPENQUESTIONTEXTDESC)==null?"":form.getValueAsString(OPENQUESTIONTEXTDESC)));
gi.getJsonRep().put("openQuestion", openQuestion);
} else {
if (gi.getJsonRep().containsKey("openQuestion")) {
gi.getJsonRep().put("openQuestion", null);
}
}
}
示例8: getJsonArray
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static JSONArray getJsonArray(List<Object> messageList) {
JSONArray jsonArr = new JSONArray();
int index = 0;
for (Object object : messageList) {
if (object == null) {
jsonArr.set(index++, JSONNull.getInstance());
} else if (object instanceof Boolean) {
jsonArr.set(index++, JSONBoolean.getInstance((Boolean) object));
} else if (object instanceof Integer) {
jsonArr.set(index++, new JSONNumber((Integer) object));
} else if (object instanceof String) {
jsonArr.set(index++, new JSONString((String) object));
} else if (object instanceof List) {
jsonArr.set(index++, getJsonArray((List<Object>) object));
} else if (object instanceof Map) {
jsonArr.set(index++, getJsonObject((Map<String, Object>) object));
} else {
throw new IllegalStateException("Invalid object encountered");
}
}
return jsonArr;
}
示例9: getMapFromJsonObject
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
public static Map<String, Object> getMapFromJsonObject(JSONObject jsonObj) {
Map<String, Object> map = new HashMap<String, Object>();
for (String key : jsonObj.keySet()) {
JSONValue jsonVal = jsonObj.get(key);
if (jsonVal instanceof JSONNull) {
map.put(key, null);
} else if (jsonVal instanceof JSONBoolean) {
map.put(key, ((JSONBoolean) jsonVal).booleanValue());
} else if (jsonVal instanceof JSONNumber) {
map.put(key, new Integer((int) ((JSONNumber) jsonVal).doubleValue()));
} else if (jsonVal instanceof JSONString) {
map.put(key, ((JSONString) jsonVal).stringValue());
} else if (jsonVal instanceof JSONArray) {
map.put(key, getListFromJsonArray((JSONArray) jsonVal));
} else if (jsonVal instanceof JSONObject) {
map.put(key, getMapFromJsonObject((JSONObject) jsonVal));
} else {
throw new IllegalStateException("Invalid JSONValue encountered");
}
}
return map;
}
示例10: getListFromJsonArray
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
private static Object getListFromJsonArray(JSONArray jsonArr) {
List<Object> list = new ArrayList<Object>();
for (int i = 0; i < jsonArr.size(); i++) {
JSONValue jsonVal = jsonArr.get(i);
if (jsonVal instanceof JSONNull) {
list.add(null);
} else if (jsonVal instanceof JSONBoolean) {
list.add(((JSONBoolean) jsonVal).booleanValue());
} else if (jsonVal instanceof JSONNumber) {
list.add(new Integer((int) ((JSONNumber) jsonVal).doubleValue()));
} else if (jsonVal instanceof JSONString) {
list.add(((JSONString) jsonVal).stringValue());
} else if (jsonVal instanceof JSONArray) {
list.add(getListFromJsonArray((JSONArray) jsonVal));
} else if (jsonVal instanceof JSONObject) {
list.add(getMapFromJsonObject((JSONObject) jsonVal));
} else {
throw new IllegalStateException("Invalid JSONValue encountered");
}
}
return list;
}
示例11: display
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
private void display(final int n, final FlowPanel container, final JSONValue tree) {
JSONObject jsonObject;
JSONString jsonString;
JSONNumber jsonNumber;
JSONArray jsonArray;
final JSONBoolean jsonBoolean;
// Just wanna point out the internal workings of JSONValue are weird as fuck
if ((jsonObject = tree.isObject()) != null) {
drawObject(container, n, jsonObject);
} else if ((jsonString = tree.isString()) != null) {
drawString(container, jsonString.stringValue());
} else if ((jsonNumber = tree.isNumber()) != null) {
drawNumber(container, jsonNumber.doubleValue());
} else if (tree.isNull() != null) {
drawNull(container);
} else if ((jsonArray = tree.isArray()) != null) {
drawArray(n, container, jsonArray);
} else if ((jsonBoolean = tree.isBoolean()) != null) {
drawBoolean(container, jsonBoolean.booleanValue());
}
}
示例12: setProp
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
@Override
public void setProp(HasProp o, String group, String key, Object value) {
JSONObject groupJSON = getOrCreateJsonGroup(o, group);
if (value == null) {
groupJSON.put(key, JSONNull.getInstance());
} else if (value instanceof Long) {
groupJSON.put(key, new JSONNumber((Long) value));
} else if (value instanceof Double) {
groupJSON.put(key, new JSONNumber((Double) value));
} else if (value instanceof Integer) {
groupJSON.put(key, new JSONNumber((Integer) value));
} else if (value instanceof Float) {
groupJSON.put(key, new JSONNumber((Float) value));
} else if (value instanceof String) {
groupJSON.put(key, new JSONString((String) value));
} else if (value instanceof Boolean) {
groupJSON.put(key, JSONBoolean.getInstance((Boolean) value));
}
o.setPropsJson(group, groupJSON.toString());
}
示例13: getPropMap
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
@Override
public Map<String, Object> getPropMap(HasProp hasProp, String id) {
Map<String, Object> map = new HashMap<>();
if (hasProp.getPropsJson(id) == null)
return map;
JSONObject groupJSON = getOrCreateJsonGroup(hasProp, id);
for (String key : groupJSON.keySet()) {
JSONNumber numObj = groupJSON.get(key).isNumber();
if (numObj != null) {
map.put(key, numObj.doubleValue());
continue;
}
JSONString stringObj = groupJSON.get(key).isString();
if (stringObj != null) {
map.put(key, stringObj.stringValue());
continue;
}
JSONBoolean boolObj = groupJSON.get(key).isBoolean();
if (boolObj != null) {
map.put(key, boolObj.booleanValue());
continue;
}
}
return map;
}
示例14: toGoogle
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
private static JSONValue toGoogle(JsonNode node) {
if (node.isObject()) {
TestJSONObject object = new TestJSONObject();
for (Iterator<String> it = node.fieldNames(); it.hasNext();) {
String key = it.next();
object.put(key, toGoogle(node.get(key)));
}
return object;
} else if (node.isArray()) {
JSONArray array = new TestJSONArray();
for (int i = 0; i < node.size(); i++) {
array.set(i, toGoogle(node.get(i)));
}
return array;
} else if (node.isBoolean()) {
JSONBoolean b = JSONBoolean.getInstance(node.booleanValue());
return b;
} else if (node.isNumber()) {
JSONNumber n = new JSONNumber(node.doubleValue());
return n;
} else if (node.isTextual()) {
JSONString s = new JSONString(node.textValue());
return s;
}
return null;
}
示例15: getState
import com.google.gwt.json.client.JSONBoolean; //导入依赖的package包/类
public JSONArray getState() {
JSONArray array = new JSONArray();
for (int i = 0; i < choices.size(); i++) {
boolean selected = choices.get(i).isSelected();
array.set(i, JSONBoolean.getInstance(selected));
}
return array;
}