/** Finds the child with the specified name and returns its first child. * @return May be null. */ public JsonValue getChild (String name) { JsonValue child = get(name); return child == null ? null : child.child; }
/** @param type May be null if the type is unknown. * @param elementType May be null if the type is unknown. * @return May be null. */ public <T> T readValue (String name, Class<T> type, Class elementType, T defaultValue, JsonValue jsonMap) { JsonValue jsonValue = jsonMap.get(name); return (T)readValue(type, elementType, defaultValue, jsonValue); }
/** Finds the child with the specified name and returns it as a string. * @throws IllegalArgumentException if the child was not found. */ public String getString (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asString(); }
/** Finds the child with the specified name and returns it as a char. * @throws IllegalArgumentException if the child was not found. */ public char getChar (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asChar(); }
/** Finds the child with the specified index and returns it as a char. * @throws IllegalArgumentException if the child was not found. */ public char getChar (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asChar(); }
/** @param type May be null if the type is unknown. * @return May be null. */ public <T> T readValue (String name, Class<T> type, T defaultValue, JsonValue jsonMap) { JsonValue jsonValue = jsonMap.get(name); if (jsonValue == null) return defaultValue; return (T)readValue(type, null, jsonValue); }
/** @param type May be null if the type is unknown. * @param elementType May be null if the type is unknown. * @return May be null. */ public <T> T readValue (String name, Class<T> type, Class elementType, JsonValue jsonMap) { return (T)readValue(type, elementType, jsonMap.get(name)); }
/** @param type May be null if the type is unknown. * @param elementType May be null if the type is unknown. * @return May be null. */ public <T> T readValue (String name, Class<T> type, Class elementType, T defaultValue, JsonValue jsonMap) { JsonValue jsonValue = jsonMap.get(name); return (T)readValue(type, elementType, defaultValue, jsonValue); }
/** Finds the child with the specified name and returns it as a long. * @throws IllegalArgumentException if the child was not found. */ public long getLong (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asLong(); }
/** Finds the child with the specified name and returns it as a short. * @throws IllegalArgumentException if the child was not found. */ public short getShort (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asShort(); }
/** Finds the child with the specified index and returns it as a double. * @throws IllegalArgumentException if the child was not found. */ public double getDouble (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asDouble(); }
/** Finds the child with the specified index and returns it as a boolean. * @throws IllegalArgumentException if the child was not found. */ public boolean getBoolean (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asBoolean(); }
/** @param type May be null if the type is unknown. * @return May be null. */ public <T> T readValue (String name, Class<T> type, JsonValue jsonMap) { return (T)readValue(type, null, jsonMap.get(name)); }
/** Finds the child with the specified name and returns it as a boolean. * @throws IllegalArgumentException if the child was not found. */ public boolean getBoolean (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asBoolean(); }
/** Finds the child with the specified name and returns it as a char. * @throws IllegalArgumentException if the child was not found. */ public char getChar (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asChar(); }
/** Finds the child with the specified index and returns it as a string. * @throws IllegalArgumentException if the child was not found. */ public String getString (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asString(); }
/** Finds the child with the specified index and returns it as a char. * @throws IllegalArgumentException if the child was not found. */ public char getChar (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asChar(); }
private Array<ModelNode> parseNodes (ModelData model, JsonValue json) { JsonValue nodes = json.get("nodes"); if (nodes != null) { model.nodes.ensureCapacity(nodes.size); for (JsonValue node = nodes.child; node != null; node = node.next) { model.nodes.add(parseNodesRecursively(node)); } } return model.nodes; }
/** 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 a double. Returns defaultValue if not found. */ public double getDouble (String name, double defaultValue) { JsonValue child = get(name); return (child == null || !child.isValue() || child.isNull()) ? defaultValue : child.asDouble(); }