本文整理汇总了Java中com.google.gwt.json.client.JSONString.stringValue方法的典型用法代码示例。如果您正苦于以下问题:Java JSONString.stringValue方法的具体用法?Java JSONString.stringValue怎么用?Java JSONString.stringValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.json.client.JSONString
的用法示例。
在下文中一共展示了JSONString.stringValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toList
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
public List<String> toList(String jsonStr) {
JSONValue parsed = JSONParser.parseStrict(jsonStr);
JSONArray jsonArray = parsed.isArray();
if (jsonArray == null) {
return Collections.emptyList();
}
List<String> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONValue jsonValue = jsonArray.get(i);
JSONString jsonString = jsonValue.isString();
String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
list.add(stringValue);
}
return list;
}
示例2: extractFormName
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
private static String extractFormName(RpcResult result) {
String extraString = result.getExtra();
if (extraString != null) {
JSONValue extraJSONValue = JSONParser.parseStrict(extraString);
JSONObject extraJSONObject = extraJSONValue.isObject();
if (extraJSONObject != null) {
JSONValue formNameJSONValue = extraJSONObject.get("formName");
if (formNameJSONValue != null) {
JSONString formNameJSONString = formNameJSONValue.isString();
if (formNameJSONString != null) {
return formNameJSONString.stringValue();
}
}
}
}
return "Screen1";
}
示例3: toMap
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
public static Map<String, String> toMap(String jsonStr) {
Map<String, String> map = new HashMap<String, String>();
JSONValue parsed = JSONParser.parseStrict(jsonStr);
JSONObject jsonObj = parsed.isObject();
if (jsonObj != null) {
for (String key : jsonObj.keySet()) {
JSONValue jsonValue = jsonObj.get(key);
JSONString jsonString = jsonValue.isString();
// if the json value is a string, set the unescaped value, else set the json representation
// of the value
String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
map.put(key, stringValue);
}
}
return map;
}
示例4: deserialize
import com.google.gwt.json.client.JSONString; //导入方法依赖的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());
}
示例5: parseVersion
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
public static Version parseVersion(JSONValue jsonValue) {
JSONObject obj = jsonValue.isObject();
Version version = new Version();
if (obj != null) {
JSONValue value = obj.get("version");
if (value != null) {
JSONString str = value.isString();
if (str != null) {
version.version = str.stringValue();
}
}
}
return version;
}
示例6: getTokenValue
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
public String getTokenValue( String name )
{
JSONValue value = values.get( name );
if( value == null )
return "";
JSONString string = value.isString();
if( string == null )
return "";
String res = string.stringValue();
if( res == null )
return "";
return res;
}
示例7: parseJson
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
/**
* @param jsonUser the JSON representation of an user
* @return a POJO equivalent
*/
public static SchedulerUser parseJson(JSONObject jsonUser) {
String host = "";
if (jsonUser.containsKey("hostName")) {
JSONString str = jsonUser.get("hostName").isString();
if (str != null)
host = str.stringValue();
}
String user = jsonUser.get("username").isString().stringValue();
long connTime = (long) jsonUser.get("connectionTime").isNumber().doubleValue();
long subTime = (long) jsonUser.get("lastSubmitTime").isNumber().doubleValue();
int subNum = (int) jsonUser.get("submitNumber").isNumber().doubleValue();
return new SchedulerUser(host, user, connTime, subTime, subNum);
}
示例8: getString
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
private static String getString(JSONValue value) throws JSONException {
if (value.isNull() != null) {
return null;
}
JSONString string = value.isString();
if (string == null) {
throw new JSONException("Expected JSON String: " + value.toString());
}
return string.stringValue();
}
示例9: getTitle
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
/**
* Get the title of an extra column from the JSON definition
* @param extraColumnProperties the JSON properties of the column
* @param columnIndex the index of the column
* @return the value of the title property
*/
public static String getTitle(JSONObject extraColumnProperties, int columnIndex) {
JSONString title = extraColumnProperties.get("title").isString();
if (title != null)
return title.stringValue();
else {
LOGGER.log(Level.SEVERE, "Could not read the field \"title\" of column number " + columnIndex);
return "";
}
}
示例10: getType
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
/**
* Get the type of an extra column from the JSON definition
* @param information the JSON \"information\" property of the column
* @param columnIndex the index of the column
* @return the value of the type property
*/
private static String getType(JSONObject information, int columnIndex) {
JSONString typeJson = information.get("type").isString();
if (typeJson != null)
return typeJson.stringValue();
else {
LOGGER.log(Level.SEVERE,
"Could not read the field \"information\"->\"type\" of column number " + columnIndex);
return "";
}
}
示例11: getKey
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
/**
* Get the key of an extra column from the JSON definition
* @param information the JSON \"information\" property of the column
* @param columnIndex the index of the column
* @return the value of the key property
*/
private static String getKey(JSONObject information, int columnIndex) {
JSONString keyJson = information.get("key").isString();
if (keyJson != null)
return keyJson.stringValue();
else {
LOGGER.log(Level.SEVERE,
"Could not read the field \"information\"->\"key\" of column number " + columnIndex);
return "";
}
}
示例12: getJsonStringNullable
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
private String getJsonStringNullable(JSONObject jsonObject, String attributeName, String defaultValue) {
JSONString result = jsonObject.get(attributeName).isString();
if (result == null) {
return defaultValue;
}
return result.stringValue();
}
示例13: readJSONDragComponent
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
public LayoutDragComponent readJSONDragComponent(String json) {
JSONObject jsonObject = JSONParser.parseStrict(json).isObject();
JSONString typeValue = jsonObject.get(COMPONENT_TYPE).isString();
if (typeValue != null) {
String type = typeValue.stringValue();
return getLayoutDragComponent(jsonObject,
type);
}
return null;
}
示例14: parseSet
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
public static <T extends Enum<T>> Set<T> parseSet(Class<T> clazz, String text) {
if ((text == null) || (text.trim().length() == 0))
return null;
Set<T> set = new TreeSet<T>();
JSONValue value = JSONParser.parseLenient(text);
JSONArray array = value.isArray();
if (array == null)
return null;
for (int i = 0; i < array.size(); i++) {
JSONValue e = array.get(i);
if (e != null) {
JSONString str = e.isString();
if (str != null) {
String name = str.stringValue();
if (name != null) {
T elem = Enum.valueOf(clazz, name);
if (elem != null) {
set.add(elem);
}
}
}
}
}
return set;
}
示例15: getString
import com.google.gwt.json.client.JSONString; //导入方法依赖的package包/类
@Override
public String getString(JSONObject o, String key) throws JsonizationException {
JSONString string = o.get(key).isString();
if (string != null)
return string.stringValue();
else {
String message = "JSON object '"+o.toString()+"' does not have an string valued property '"+key+"'.";
logger.severe(message);
throw new JsonizationException(message);
}
}