Example usage for com.google.gson.stream JsonReader nextString

List of usage examples for com.google.gson.stream JsonReader nextString

Introduction

In this page you can find the example usage for com.google.gson.stream JsonReader nextString.

Prototype

public String nextString() throws IOException 

Source Link

Document

Returns the com.google.gson.stream.JsonToken#STRING string value of the next token, consuming it.

Usage

From source file:org.hibernate.search.backend.elasticsearch.document.model.impl.esnative.ElasticsearchFormatJsonAdapter.java

License:LGPL

@Override
public List<String> read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();//from   w w  w  . java 2  s.  c  om
        return null;
    }

    String joinedFormats = in.nextString();
    List<String> formats = Arrays.asList(joinedFormats.split(FORMAT_SEPARATOR_REGEX));
    return formats;
}

From source file:org.hibernate.search.elasticsearch.util.impl.gson.ES2IndexTypeJsonAdapter.java

License:LGPL

@Override
public IndexType read(JsonReader in) throws IOException {
    String value = in.nextString();
    switch (value) {
    case ANALYZED_STRING:
        return IndexType.ANALYZED;
    case NOT_ANALYZED_STRING:
        return IndexType.NOT_ANALYZED;
    case NO_STRING:
        return IndexType.NO;
    default://  w  w w.  j a va 2s.  c  o m
        throw new IllegalStateException("Invalid value for IndexType in ES2: " + value);
    }
}

From source file:org.imperiumstudios.Imperium1871Bungee.BukkitWarpHelper.files.JsonFile.java

License:Open Source License

/**
 * Read the config File into RAM.//w  ww .j  a va  2 s. c o  m
 */
public void readFile() {
    try {
        JsonReader reader = new JsonReader(new FileReader(jsonFile));

        reader.beginObject();

        while (reader.hasNext())
            jsonFileContent.put(reader.nextName(), reader.nextString());

        reader.endObject();
        reader.close();
    } catch (IOException ex) {
        IMP.log.error("JsonFile.java > readFile() > Unable to read " + jsonFile + ". Disabling this plugin ..");
        IMP.log.error("JsonFile.java > readFile() > Error: " + ex.getMessage());
        IMP.disable();
    }
}

From source file:org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.UUIDTypeAdapter.java

License:Open Source License

@Override
public UUID read(JsonReader in) throws IOException {
    return fromString(in.nextString());
}

From source file:org.jboss.tools.aerogear.hybrid.core.plugin.registry.CordovaPluginRegistryManager.java

License:Open Source License

private void readPluginInfo(JsonReader reader, CordovaRegistryPluginInfo plugin) throws IOException {
    Assert.isNotNull(plugin);/*  ww  w .java  2s . co m*/
    reader.beginObject();

    while (reader.hasNext()) {
        JsonToken token = reader.peek();
        switch (token) {
        case NAME: {
            String name = reader.nextName();
            if ("name".equals(name)) {
                plugin.setName(reader.nextString());
                break;
            }
            if ("description".equals(name)) {
                plugin.setDescription(reader.nextString());
                break;
            }
            if ("keywords".equals(name)) {
                parseKeywords(reader, plugin);
                break;
            }
            if ("maintainers".equals(name)) {
                parseMaintainers(reader, plugin);
                break;
            }
            if ("dist-tags".equals(name)) {
                parseLatestVersion(reader, plugin);
                break;
            }
            if ("versions".equals(name) && plugin instanceof CordovaRegistryPlugin) {
                parseDetailedVersions(reader, (CordovaRegistryPlugin) plugin);
                break;
            }
            if ("dist".equals(name) && plugin instanceof CordovaRegistryPluginVersion) {
                parseDistDetails(reader, (CordovaRegistryPluginVersion) plugin);
                break;
            }
            if ("license".equals(name) && plugin instanceof CordovaRegistryPluginVersion) {
                CordovaRegistryPluginVersion v = (CordovaRegistryPluginVersion) plugin;
                v.setLicense(reader.nextString());
                break;
            }
            break;
        }

        default:
            reader.skipValue();
            break;
        }
    }
    reader.endObject();
}

From source file:org.jboss.tools.aerogear.hybrid.core.plugin.registry.CordovaPluginRegistryManager.java

License:Open Source License

private void parseDistDetails(JsonReader reader, CordovaRegistryPluginVersion plugin) throws IOException {
    reader.beginObject();//  ww w  .  j  av a2  s .c  o  m
    JsonToken token = reader.peek();
    while (token != JsonToken.END_OBJECT) {
        switch (token) {
        case NAME:
            String name = reader.nextName();
            if ("shasum".equals(name)) {
                plugin.setDistributionSHASum(reader.nextString());
                break;
            }
            if ("tarball".equals(name)) {
                plugin.setDistributionTarball(reader.nextString());
                break;
            }
            break;

        default:
            reader.skipValue();
            break;
        }
        token = reader.peek();
    }
    reader.endObject();
}

From source file:org.jboss.tools.aerogear.hybrid.core.plugin.registry.CordovaPluginRegistryManager.java

License:Open Source License

private void parseLatestVersion(JsonReader reader, CordovaRegistryPluginInfo plugin) throws IOException {
    reader.beginObject();/*  ww w.j  a  v a  2  s .  c om*/
    JsonToken token = reader.peek();
    while (token != JsonToken.END_OBJECT) {
        switch (token) {
        case NAME:
            String tag = reader.nextName();
            if ("latest".equals(tag)) {
                plugin.setLatestVersion(reader.nextString());
            }
            break;

        default:
            reader.skipValue();
            break;
        }
        token = reader.peek();
    }
    reader.endObject();
}

From source file:org.jboss.tools.aerogear.hybrid.core.plugin.registry.CordovaPluginRegistryManager.java

License:Open Source License

private void parseMaintainers(JsonReader reader, CordovaRegistryPluginInfo plugin) throws IOException {
    reader.beginArray();/*from  ww w  . j a  v  a 2  s. c o  m*/
    String name = null, email = null;
    JsonToken token = reader.peek();

    while (token != JsonToken.END_ARRAY) {
        switch (token) {
        case BEGIN_OBJECT:
            reader.beginObject();
            name = email = null;
            break;
        case END_OBJECT:
            reader.endObject();
            plugin.addMaintainer(email, name);
            break;
        case NAME:
            String tagName = reader.nextName();
            if ("name".equals(tagName)) {
                name = reader.nextString();
                break;
            }
            if ("email".equals(tagName)) {
                email = reader.nextString();
                break;
            }
        default:
            Assert.isTrue(false, "Unexpected token");
            break;
        }
        token = reader.peek();
    }
    reader.endArray();
}

From source file:org.jboss.tools.aerogear.hybrid.core.plugin.registry.CordovaPluginRegistryManager.java

License:Open Source License

private void parseKeywords(JsonReader reader, CordovaRegistryPluginInfo plugin) throws IOException {
    reader.beginArray();//from w ww.j av a 2  s.c  o m
    while (reader.hasNext()) {
        plugin.addKeyword(reader.nextString());
    }
    reader.endArray();
}

From source file:org.jclouds.cloudstack.config.CloudStackDateAdapter.java

License:Apache License

public Date read(JsonReader reader) throws IOException {
    return parseDate(reader.nextString().replaceAll("'T'", "T"));
}