/** Finds the child with the specified index and returns it as an int. * @throws IllegalArgumentException if the child was not found. */ public int getInt (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asInt(); }
/** Finds the child with the specified index and returns it as an int. * @throws IllegalArgumentException if the child was not found. */ public int getInt (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asInt(); }
/** Finds the child with the specified name and returns it as an int. * @throws IllegalArgumentException if the child was not found. */ public int getInt (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asInt(); }
/** Finds the child with the specified name and returns it as an int. * @throws IllegalArgumentException if the child was not found. */ public int getInt (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asInt(); }
/** Finds the child with the specified name and returns it as an int. Returns defaultValue if not found. */ public int getInt (String name, int defaultValue) { JsonValue child = get(name); return (child == null || !child.isValue() || child.isNull()) ? defaultValue : child.asInt(); }
/** Finds the child with the specified name and returns it as an int. Returns defaultValue if not found. */ public int getInt (String name, int defaultValue) { JsonValue child = get(name); return (child == null || !child.isValue() || child.isNull()) ? defaultValue : child.asInt(); }
try { if (type == null || type == float.class || type == Float.class) return (T)(Float)jsonData.asFloat(); if (type == int.class || type == Integer.class) return (T)(Integer)jsonData.asInt(); if (type == long.class || type == Long.class) return (T)(Long)jsonData.asLong(); if (type == double.class || type == Double.class) return (T)(Double)jsonData.asDouble();
try { if (type == null || type == float.class || type == Float.class) return (T)(Float)jsonData.asFloat(); if (type == int.class || type == Integer.class) return (T)(Integer)jsonData.asInt(); if (type == long.class || type == Long.class) return (T)(Long)jsonData.asLong(); if (type == double.class || type == Double.class) return (T)(Double)jsonData.asDouble();
private JsonValue readArchetype(JsonValue jsonData, Entity e) { // archetypes is optional, to avoid breaking compatibility if ("archetype".equals(jsonData.name)) { archetype = jsonData.asInt(); jsonData = jsonData.next; } else { archetype = -1; } return jsonData; }
/** Finds the child with the specified index and returns it as an int. * @throws IllegalArgumentException if the child was not found. */ public int getInt (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asInt(); }
public GrowableTarget(JsonValue props, JsonValue grow) { super(props); for(JsonValue value : grow) this.grow.put(PropKey.valueOf(value.name), value.asInt()); }
/** Finds the child with the specified name and returns it as an int. * @throws IllegalArgumentException if the child was not found. */ public int getInt (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asInt(); }
public Target(JsonValue props) { for(JsonValue value : props) this.props.put(PropKey.valueOf(value.name), value.asInt()); }
/** Finds the child with the specified name and returns it as an int. Returns defaultValue if not found. */ public int getInt (String name, int defaultValue) { JsonValue child = get(name); return (child == null || !child.isValue() || child.isNull()) ? defaultValue : child.asInt(); }
return (T) ((Float) objectRoot.asFloat()); } else if (fieldClass.equals(Integer.TYPE) || fieldClass.equals(Integer.class)) { return (T) ((Integer) objectRoot.asInt()); } else if (fieldClass.equals(Long.TYPE) || fieldClass.equals(Long.class)) { return (T) ((Long) objectRoot.asLong());
@Override public VersionData read(Json json, JsonValue jsonData, Class type) { VersionData data = new VersionData(); data.plainJson = jsonData.prettyPrint(JsonWriter.OutputType.json, 0); for (JsonValue entry = jsonData.child; entry != null; entry = entry.next) { switch (entry.name) { case "id": data.id = entry.asInt(); break; case "html_url": data.url = entry.asString(); break; case "tag_name": String tagName = entry.asString(); data.tag = tagName; data.version = new Version(tagName); break; case "name": data.name = entry.asString(); break; case "body": data.description = entry.asString(); break; } } return data; }
try { if (type == null || type == float.class || type == Float.class) return (T)(Float)jsonData.asFloat(); if (type == int.class || type == Integer.class) return (T)(Integer)jsonData.asInt(); if (type == long.class || type == Long.class) return (T)(Long)jsonData.asLong(); if (type == double.class || type == Double.class) return (T)(Double)jsonData.asDouble();
public Hero(int id, JsonValue json) { this.id = id; name = json.getString("name"); jname = json.getString("jname"); fg = json.getString("fg"); color = json.getString("color"); tag = json.getString("tag"); sprite = new MapSprite(0, 0, 0, 4, Path.WALK_HERO + json.getString("spriteImage")); target = new GrowableTarget(json.get("prop"), json.get("grow")); //初始化装备 for(JsonValue equip : json.get("equip")) target.setEquipment(Equipment.Parts.valueOf(equip.name), equip.isNull() ? null : Game.item.get(equip.asInt(), Equipment.class)); }