Java 类com.badlogic.gdx.utils.JsonValue.ValueType 实例源码

项目:TheConsole_POC    文件:JsonUtils.java   
public static JsonValue getOrCreateChild(JsonValue root, String key, ValueType type) {
    JsonValue tree = root.get(key);

    if (tree == null) {
        tree = new JsonValue(type);
        tree.setName(key);

        if (root.size == 0) {
            root.child = tree;
        }
        else {
            JsonValue prev = root.get(root.size - 1);
            prev.setNext(tree);
            tree.setPrev(prev);
        }

        ++root.size;
    }

    return tree;
}
项目:TheConsole_POC    文件:Database.java   
private SectionAccessor getSection(JsonValue root, String section, boolean createIfDoesntExist) {
    JsonValue tree = null;

    if (createIfDoesntExist) {
        tree = JsonUtils.getOrCreateChild(root, section, ValueType.object);
    }
    else {
        tree = root.get(section);
    }

    return new SectionAccessor(tree);
}
项目:TheConsole_POC    文件:Database.java   
public void set(String key, String value) {
    JsonValue tree = JsonUtils.getOrCreateChild(root, key, ValueType.stringValue);
    tree.set(value);
}
项目:libgdxcn    文件:JsonReader.java   
protected void startObject (String name) {
    JsonValue value = new JsonValue(ValueType.object);
    if (current != null) addChild(name, value);
    elements.add(value);
    current = value;
}
项目:libgdxcn    文件:JsonReader.java   
protected void startArray (String name) {
    JsonValue value = new JsonValue(ValueType.array);
    if (current != null) addChild(name, value);
    elements.add(value);
    current = value;
}
项目:libgdx_g3db_converter    文件:G3DBConverter.java   
private void writeObject (JsonValue root, UBJsonWriter writer) throws IOException {
    if (root.type() == ValueType.array) {
        if (root.name() != null) {
            writer.array(root.name());
        } else {
            writer.array();
        }
    } else {
        if (root.name() != null) {
            writer.object(root.name());
        } else {
            writer.object();
        }
    }

    JsonValue child = root.child();
    while (child != null) {
        switch (child.type()) {
        case booleanValue:
            if (child.name()!=null){
                writer.set(child.name(), child.asBoolean());
            }
            else{
                writer.value(child.asBoolean());
            }
            break;

        case doubleValue:
            if (child.name()!=null){
                writer.set(child.name(), child.asDouble());
            }
            else{
                writer.value(child.asDouble());
            }
            break;

        case longValue:
            if (child.name()!=null){
                writer.set(child.name(), child.asLong());
            }
            else{
                writer.value(child.asLong());
            }
            break;

        case stringValue:
            if (child.name()!=null){
                writer.set(child.name(), child.asString());
            }
            else{
                writer.value(child.asString());
            }
            break;

        case nullValue:
            if (child.name()!=null){
                writer.set(child.name());
            }
            break;

        case array:
        case object:
            writeObject(child, writer);
            break;
        }

        child = child.next();
    }

    writer.pop();
}