本文整理汇总了Java中com.eclipsesource.json.JsonValue.isString方法的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.isString方法的具体用法?Java JsonValue.isString怎么用?Java JsonValue.isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.eclipsesource.json.JsonValue
的用法示例。
在下文中一共展示了JsonValue.isString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseStack
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
public static ItemStack parseStack(JsonValue js) {
if (js.isString()) {
return new ItemStack(getItem(js.asString()));
} else if (js.isObject()) {
JsonObject obj = js.asObject();
JsonValue id = obj.get("id");
if (id == null)
throw new JsonException("No id");
return new ItemStack(getItem(id.asString()), obj.getInt("count", 1), obj.getInt("meta", 0));
} else if (js.isNull()) {
return null;
}
throw new JsonException("Invalid type " + js.toString());
}
示例2: parse
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
@Override
public String[] parse(JsonValue p3) {
String[] textures = new String[6];
if (p3.isString()) {
Arrays.fill(textures, p3.asString());
} else {
JsonObject texture = p3.asObject();
for (JsonObject.Member member : texture) {
String value = member.getValue().asString();
parseSwitch(member, textures, value);
}
}
return textures;
}
示例3: load
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
/**
* Load from configuration.
*/
public void load() {
// Return if the config file does not exist.
if (!confFile.exists()) {
return;
}
try {
JsonObject json = Json.parse(Files.readFile(confFile.getAbsolutePath())).asObject();
for (Field field : this.getClass().getDeclaredFields()) {
String name = field.getName();
JsonValue value = json.get(name);
if (value == null) {
continue;
}
field.setAccessible(true);
if (value.isBoolean()) {
field.set(this, value.asBoolean());
} else if (value.isNumber()) {
field.set(this, value.asInt());
} else if (value.isString()) {
field.set(this, value.asString());
} else {
Object parsed = parse(field.getType(), value);
if (parsed != null) {
field.set(this, parsed);
}
}
}
} catch (Exception e) {
Recaf.INSTANCE.logging.error(e, false);
}
}
示例4: parseStack
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
public static ItemStack parseStack(JsonValue json) {
if (json.isString()) {
return new ItemStack(getItem(json.asString()));
} else if (json.isObject()) {
JsonObject obj = json.asObject();
JsonValue id = obj.get("id");
if (id == null) throw new JsonException("No id");
return new ItemStack(getItem(id.asString()), obj.getInt("count", 1), obj.getInt("meta", 0));
} else if (json.isNull()) {
return null;
}
throw new JsonException("Invalid type " + json.toString());
}
示例5: parse
import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
@Override
public String[] parse(JsonValue prop) {
String[] textures = new String[6];
if (prop.isString()) {
Arrays.fill(textures, prop.asString());
} else {
JsonObject texture = prop.asObject();
for (JsonObject.Member member : texture) {
String value = member.getValue().asString();
switch (member.getName()) {
case "posX":
textures[BlockFace.posX.index] = value;
break;
case "negX":
textures[BlockFace.negX.index] = value;
break;
case "posY":
case "top":
textures[BlockFace.posY.index] = value;
break;
case "negY":
case "bottom":
textures[BlockFace.negY.index] = value;
break;
case "posZ":
textures[BlockFace.posZ.index] = value;
break;
case "negZ":
textures[BlockFace.negZ.index] = value;
break;
case "side":
textures[BlockFace.posX.index] = value;
textures[BlockFace.negX.index] = value;
textures[BlockFace.posZ.index] = value;
textures[BlockFace.negZ.index] = value;
break;
case "other":
for (int i = 0; i < textures.length; i++) {
if (textures[i] == null) textures[i] = value;
}
break;
default:
throw new JsonException("Unexpected block texture member \"" + member.getName() + "\"");
}
}
}
return textures;
}