本文整理汇总了Java中com.google.gwt.json.client.JSONObject.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.containsKey方法的具体用法?Java JSONObject.containsKey怎么用?Java JSONObject.containsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.json.client.JSONObject
的用法示例。
在下文中一共展示了JSONObject.containsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStyle
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static ProjectLayerStyle getStyle(String geoJSONCSS) {
ProjectLayerStyle style = null;
final JSONValue jsonValue = JSONParser.parseLenient(geoJSONCSS);
final JSONObject geoJSONCssObject = jsonValue.isObject();
if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) {
JSONObject styleObject = geoJSONCssObject
.get(GeoJSONCSS.STYLE_NAME).isObject();
String fillColor = getStringValue(styleObject, FILL_COLOR_NAME);
Double fillOpacity = getDoubleValue(styleObject, FILL_OPACITY_NAME);
if(fillOpacity == null) {
fillOpacity = getDoubleValue(styleObject, FILL_OPACITY2_NAME);
}
String strokeColor = getStringValue(styleObject, STROKE_COLOR_NAME);
Double strokeWidth = getDoubleValue(styleObject, STROKE_WIDTH_NAME);
style = new ProjectLayerStyle(fillColor, fillOpacity, strokeColor,
strokeWidth);
}
return style;
}
示例2: depToHumanReadableString
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private String depToHumanReadableString(JSONObject json) {
if (json.containsKey("type") && json.get("type").isString().stringValue().contains("ActionDependency")) {
return actionDepToHumanReadableString(json);
}
if (json.containsKey("type") && json.get("type").isString().stringValue().contains("TimeDependency")) {
return timeDepToHumanReadableString(json);
}
if (json.containsKey("type") && json.get("type").isString().stringValue().contains("AndDependency")) {
return andDepToHumanReadableString(json);
}
if (json.containsKey("type") && json.get("type").isString().stringValue().contains("OrDependency")) {
return orDepToHumanReadableString(json);
}
if (json.containsKey("type") && json.get("type").isString().stringValue().contains("ProximityDependency")) {
return proximityDepToHumanReadableString(json);
}
return "not supported in viewing mode";
}
示例3: getJsonErrorMessage
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
/**
* @param str String representation of a serialized JSON Exception
* @return the value of the 'errorMessage' key
*/
public static String getJsonErrorMessage(String str) {
try {
JSONObject exc = JSONParser.parseStrict(str).isObject();
if (exc != null && exc.containsKey("errorMessage")) {
return retrieveErrorMessage(exc);
} else if (exc != null && exc.containsKey("exception")) {
JSONObject nestedExc = exc.get("exception").isObject();
return retrieveErrorMessage(nestedExc);
}
} catch (Exception e) {
if (str != null) {
return str;
} else {
return "<no reason>";
}
}
return null;
}
示例4: UrlBuilder
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
/**
* Parse url and set initial parameters(protocol, host, port, path)<br>
*
* @param url
*/
public UrlBuilder(String url) {
JavaScriptObject jso = parseUrl(url);
o = new JSONObject(jso);
setHost(o.get("host").isString().stringValue());
setProtocol(o.get("protocol").isString().stringValue());
if (o.containsKey("port")) {
final String port = o.get("port").isString().stringValue();
if (!port.isEmpty()) {
setPort(Integer.valueOf(port));
}
}
setPath(o.get("path").isString().stringValue());
// fill query parameters
JSONObject query = o.get("queryKey").isObject();
for (String key : query.keySet()) {
setParameter(key, query.get(key).isString().stringValue());
}
}
示例5: loadJson
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public void loadJson(JSONObject object) {
hasDependency = true;
showHasDependencyCheckBox = true;
hasDependencyCheckboxItem.setValue(true);
if (object.containsKey("generalItemId")) {
loadGeneralItemOptions((long) object.get("generalItemId").isNumber().doubleValue());
}
if (object.containsKey("action")){
setValue(ACTION_DEP, object.get("action").isString().stringValue());
setValue(ACTION_DEP_STRING, object.get("action").isString().stringValue());
}
if (object.containsKey("generalItemId")){
setValue(GENITEM_DEP, (long) object.get("generalItemId").isNumber().doubleValue());
}
if (object.containsKey("scope")) {
setValue(SCOPE_DEP, ""+(int)object.get("scope").isNumber().doubleValue());
}
}
示例6: getJson
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static JSONObject getJson(JSONObject[] childObjects, TreeNode[] childNodes) {
JSONObject dep = new JSONObject();
dep.put("type", new JSONString("org.celstec.arlearn2.beans.dependencies.TimeDependency"));
JSONObject offset = null;
int j = 0;
for (TreeNode tn: childNodes) {
if (tn.getAttribute("type")!= null &&tn.getAttribute("type").equals(TIMEDELTA)) {
long value = Long.parseLong(tn.getAttribute("Value"))*1000;
if (tn.getAttribute("Value")!=null) dep.put(TIMEDELTA, new JSONNumber(value));
}
}
for (int i =0; i<childObjects.length && j== 0; i++) {
JSONObject child = childObjects[i];
if (child != null && child.containsKey("type")) {
offset = child;
j++;
}
}
if (offset == null) return null;
dep.put("offset", offset);
return dep;
}
示例7: createRecord
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
protected AbstractRecord createRecord(JSONObject object) {
AbstractRecord record = dataSourceAdapter.createRecord();
record.setCorrespondingJsonObject(object);
for (int i = 0; i < attributeList.size(); i++) {
String attribute = attributeList.get(i);
if (object.containsKey(attribute)) {
processAttributeValue(record, attribute, object.get(attribute), typeList.get(i));
}
}
for (int i = 0; i < derivedTaskList.size(); i++) {
DerivedFieldTask task = derivedTaskList.get(i);
task.setJsonSource(object);
Object o = task.process();
if (o instanceof String[]) {
record.setAttribute(task.getTargetFieldName(), (String[]) o);
} else {
record.setAttribute(task.getTargetFieldName(), task.process());
}
}
return record;
}
示例8: getAttributeString
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public String getAttributeString(int i, String attributeName) {
if (jsonValue == null) return null;
// Window.alert("jsonValue string"+jsonValue);
// Window.alert("jsonValue string"+i+ " "+jsonValue.get(i));
JSONObject game = jsonValue.get(i).isObject();
if (game == null) return null;
if (!game.containsKey(attributeName)) return null;
if (game.get(attributeName).isArray()!=null) {
JSONArray ar = game.get(attributeName).isArray();
String returnString = "";
if (ar.size()>=1) returnString = ar.get(0).isString().stringValue();
for (int j = 1; j< ar.size(); j++) {
returnString += ", "+ar.get(j).isString().stringValue();
}
return returnString;
}
return game.get(attributeName).isString().stringValue();
}
示例9: getState
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private JavaScriptObject getState(JSONValue jsonValue) {
JSONObject state = jsonValue.isObject();
if (state.containsKey(STATE)) {
return state.get(STATE).isArray().get(0).isObject().getJavaScriptObject();
}
return state.getJavaScriptObject();
}
示例10: getSavedLessonIdentifier
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private String getSavedLessonIdentifier(JSONObject jsonObject) {
boolean hasIdentifier = jsonObject.containsKey(EmpiriaState.LESSON_IDENTIFIER);
if(hasIdentifier) {
return jsonObject.get(EmpiriaState.LESSON_IDENTIFIER).isString().stringValue();
}
return StringUtils.EMPTY;
}
示例11: getStringValue
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private static String getStringValue(JSONObject styleObject, String key) {
String newValue = "";
if (styleObject.containsKey(key)) {
try {
newValue = styleObject.get(key).isString().stringValue();
} catch (Exception e) {
// si el valor del atributo no está bien definido es ignorado
}
}
return newValue;
}
示例12: getDoubleValue
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private static Double getDoubleValue(JSONObject styleObject, String key) {
Double newValue = null;
if (styleObject.containsKey(key)) {
try {
newValue = styleObject.get(key).isNumber().doubleValue();
} catch (Exception e) {
// si el valor del atributo no está bien definido es ignorado
}
}
return newValue;
}
示例13: getLayerStyle
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public VectorStyleDef getLayerStyle(String vectorFormatString) {
VectorFeatureStyleDef def = null;
final JSONValue jsonValue = JSONParser.parseLenient(vectorFormatString);
final JSONObject geoJSONCssObject = jsonValue.isObject();
if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) {
JSONObject styleObject = geoJSONCssObject.get(GeoJSONCSS.STYLE_NAME).isObject();
JSObject styleJSObject = styleObject.getJavaScriptObject().cast();
def = getStyleDef(styleJSObject);
}
return def;
}
示例14: actionDepToHumanReadableString
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
protected String actionDepToHumanReadableString(JSONObject json){
String returnString = "";
returnString += "<table border=0 cellspacing=0 class=\"detailBlock\">";
if (json.containsKey("action")) returnString += "<tr><td width=\"10%\" class=\"detailLabel\" align=\"RIGHT\">action</td><td class=\"detail\" style=\"text-align:left;\">"+json.get("action").isString().stringValue()+"</td><tr>";
if (json.containsKey("generalItemId")) returnString += "<tr><td width=\"10%\" class=\"detailLabel\" align=\"RIGHT\">generalItemId</td><td class=\"detail\" style=\"text-align:left;\">"+(long)json.get("generalItemId").isNumber().doubleValue()+"</td><tr>";
if (json.containsKey("scope")) returnString += "<tr><td width=\"10%\" class=\"detailLabel\" align=\"RIGHT\">scope</td><td class=\"detail\" style=\"text-align:left;\">"+(long)json.get("scope").isNumber().doubleValue()+"</td><tr>";
returnString += "</table>";
return returnString;
}
示例15: getJsonErrorCode
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
/**
* @param str String representation of a serialized JSON Exception
* @return the value of the 'httpErrorCode' key, or -1
*/
public static int getJsonErrorCode(String str) {
try {
JSONObject exc = JSONParser.parseStrict(str).isObject();
if (exc != null && exc.containsKey("httpErrorCode")) {
return retrieveErrorCode(exc);
} else if (exc != null && exc.containsKey("exception")) {
JSONObject nestedExc = exc.get("exception").isObject();
return retrieveErrorCode(nestedExc);
}
} catch (Exception e) {
return -1;
}
return -1;
}