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

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

Introduction

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

Prototype

public void endObject() throws IOException 

Source Link

Document

Consumes the next token from the JSON stream and asserts that it is the end of the current object.

Usage

From source file:org.komodo.rest.relational.json.QueryResultSerializer.java

License:Open Source License

@Override
public RestQueryResult read(JsonReader in) throws IOException {
    final RestQueryResult queryResult = new RestQueryResult();
    in.beginObject();/*from w ww.  j  a v a2  s  .c om*/

    while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
        case RestQueryResult.COLUMNS_LABEL:
            RestQueryColumn[] columns = BUILDER.fromJson(in, RestQueryColumn[].class);
            queryResult.setColumns(columns);
            break;
        case RestQueryResult.ROWS_LABEL:
            RestQueryRow[] rows = BUILDER.fromJson(in, RestQueryRow[].class);
            queryResult.setRows(rows);
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return queryResult;
}

From source file:org.komodo.rest.relational.json.QueryRowSerializer.java

License:Open Source License

/**
 * {@inheritDoc}//from ww  w.  j a va2  s  . c o m
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public RestQueryRow read(final JsonReader in) throws IOException {
    final RestQueryRow queryRow = new RestQueryRow();
    in.beginObject();

    while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
        case RestQueryRow.ROW_LABEL:
            String[] values = BUILDER.fromJson(in, String[].class);
            queryRow.setValues(values);
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return queryRow;
}

From source file:org.komodo.rest.relational.json.SavedSearcherSerializer.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w  ww  .  j av  a  2 s. co  m*/
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public KomodoSavedSearcher read(final JsonReader in) throws IOException {
    final KomodoSavedSearcher status = new KomodoSavedSearcher();
    in.beginObject();

    while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
        case KomodoSavedSearcher.NAME_LABEL:
            status.setName(in.nextString());
            break;
        case KomodoSavedSearcher.QUERY_LABEL:
            status.setQuery(in.nextString());
            break;
        case KomodoSavedSearcher.PARAMETER_LABEL:
            final String[] parameters = BUILDER.fromJson(in, String[].class);
            status.setParameters(Arrays.asList(parameters));
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return status;
}

From source file:org.komodo.rest.relational.json.SearcherAttributesSerializer.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w  ww  .j a v a 2  s . c  o m*/
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public KomodoSearcherAttributes read(final JsonReader in) throws IOException {
    final KomodoSearcherAttributes searcherAttr = createEntity();
    in.beginObject();

    while (in.hasNext()) {
        final String name = in.nextName();

        if (readPath(in, name, searcherAttr) != null)
            continue;

        switch (name) {
        case KomodoSearcherAttributes.SEARCH_NAME_LABEL:
            searcherAttr.setSearchName(in.nextString());
            break;
        case KomodoSearcherAttributes.TYPE_LABEL:
            searcherAttr.setType(in.nextString());
            break;
        case KomodoSearcherAttributes.PARENT_LABEL:
            searcherAttr.setParent(in.nextString());
            break;
        case KomodoSearcherAttributes.ANCESTOR_LABEL:
            searcherAttr.setAncestor(in.nextString());
            break;
        case KomodoSearcherAttributes.CONTAINS_LABEL:
            searcherAttr.setContains(in.nextString());
            break;
        case KomodoSearcherAttributes.OBJECT_NAME_LABEL:
            searcherAttr.setObjectName(in.nextString());
            break;
        case KomodoSearcherAttributes.PARAMETERS_LABEL:
            Map<String, String> parameters = BUILDER.fromJson(in, Map.class);
            for (Map.Entry<String, String> parameter : parameters.entrySet()) {
                searcherAttr.setParameter(parameter.getKey(), parameter.getValue());
            }
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return searcherAttr;
}

From source file:org.komodo.rest.relational.json.StatusObjectSerializer.java

License:Open Source License

/**
 * {@inheritDoc}//ww  w  .j a  va 2  s.c om
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public KomodoStatusObject read(final JsonReader in) throws IOException {
    final KomodoStatusObject status = new KomodoStatusObject();
    in.beginObject();

    while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
        case KomodoStatusObject.TITLE_LABEL:
            status.setTitle(in.nextString());
            break;
        case KomodoStatusObject.INFO_LABEL:
            Map<String, String> attributes = BUILDER.fromJson(in, Map.class);
            status.setAttributes(attributes);
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return status;
}

From source file:org.komodo.rest.relational.json.StorageAttributesSerializer.java

License:Open Source License

/**
 * {@inheritDoc}//from  w w  w  .j a  va  2  s . c  o  m
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public KomodoStorageAttributes read(final JsonReader in) throws IOException {
    final KomodoStorageAttributes storageAttr = new KomodoStorageAttributes();
    in.beginObject();

    while (in.hasNext()) {
        final String name = in.nextName();

        if (readContent(in, storageAttr, name) != null)
            continue;

        switch (name) {
        case KomodoStorageAttributes.STORAGE_TYPE_LABEL:
            storageAttr.setStorageType(in.nextString());
            break;
        case KomodoStorageAttributes.ARTIFACT_PATH_LABEL:
            storageAttr.setArtifactPath(in.nextString());
            break;
        case KomodoStorageAttributes.PARAMETERS_LABEL:
            Map<String, String> parameters = BUILDER.fromJson(in, Map.class);
            for (Map.Entry<String, String> parameter : parameters.entrySet()) {
                storageAttr.setParameter(parameter.getKey(), parameter.getValue());
            }
            break;
        case KomodoStorageAttributes.DOCUMENT_TYPE_LABEL:
            String docTypeValue = in.nextString();
            DocumentType docType = DocumentType.documentType(docTypeValue);
            storageAttr.setDocumentType(docType);
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return storageAttr;
}

From source file:org.komodo.rest.relational.json.StorageTypeDescriptorSerializer.java

License:Open Source License

@Override
public RestStorageTypeDescriptor read(JsonReader in) throws IOException {
    final RestStorageTypeDescriptor storageTypeDescriptor = new RestStorageTypeDescriptor();
    in.beginObject();//from w  w  w. j a  v  a2s  .  c o m

    while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
        case RestStorageTypeDescriptor.NAME_LABEL:
            storageTypeDescriptor.setName(in.nextString());
            break;
        case RestStorageTypeDescriptor.DESCRIPTION_LABEL:
            storageTypeDescriptor.setDescription(in.nextString());
            break;
        case RestStorageTypeDescriptor.REQUIRED_LABEL:
            storageTypeDescriptor.setRequired(in.nextBoolean());
            break;
        case RestStorageTypeDescriptor.ENCODED_LABEL:
            storageTypeDescriptor.setEncoded(in.nextBoolean());
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return storageTypeDescriptor;
}

From source file:org.komodo.rest.relational.json.StorageTypeSerializer.java

License:Open Source License

/**
 * {@inheritDoc}/* www. j  a  v  a2 s . co  m*/
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public RestStorageType read(final JsonReader in) throws IOException {
    final RestStorageType storageType = new RestStorageType();
    in.beginObject();

    while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
        case RestStorageType.NAME_LABEL:
            storageType.setName(in.nextString());
            break;
        case RestStorageType.DESCRIPTION_LABEL:
            storageType.setDescription(in.nextString());
            break;
        case RestStorageType.DESCRIPTORS_LABEL:
            RestStorageTypeDescriptor[] descriptors = BUILDER.fromJson(in, RestStorageTypeDescriptor[].class);
            storageType.setDescriptors(descriptors);
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return storageType;
}

From source file:org.komodo.rest.relational.json.TeiidAttributesSerializer.java

License:Open Source License

/**
 * {@inheritDoc}//from w w w.j a  v  a2  s.c  om
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public KomodoTeiidAttributes read(final JsonReader in) throws IOException {
    final KomodoTeiidAttributes teiidAttrs = new KomodoTeiidAttributes();
    in.beginObject();

    while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
        case KomodoTeiidAttributes.ADMIN_USER_LABEL:
            teiidAttrs.setAdminUser(in.nextString());
            break;
        case KomodoTeiidAttributes.ADMIN_PASSWD_LABEL:
            teiidAttrs.setAdminPasswd(in.nextString());
            break;
        case KomodoTeiidAttributes.ADMIN_PORT_LABEL:
            teiidAttrs.setAdminPort(in.nextInt());
            break;
        case KomodoTeiidAttributes.ADMIN_SECURE_LABEL:
            teiidAttrs.setAdminSecure(in.nextBoolean());
            break;
        case KomodoTeiidAttributes.JDBC_USER_LABEL:
            teiidAttrs.setJdbcUser(in.nextString());
            break;
        case KomodoTeiidAttributes.JDBC_PASSWD_LABEL:
            teiidAttrs.setJdbcPasswd(in.nextString());
            break;
        case KomodoTeiidAttributes.JDBC_PORT_LABEL:
            teiidAttrs.setJdbcPort(in.nextInt());
            break;
        case KomodoTeiidAttributes.JDBC_SECURE_LABEL:
            teiidAttrs.setJdbcSecure(in.nextBoolean());
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return teiidAttrs;
}

From source file:org.komodo.rest.relational.json.TeiidVdbStatusVdbSerializer.java

License:Open Source License

/**
 * {@inheritDoc}/*w  w  w  . j a v  a  2 s. co m*/
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public RestTeiidVdbStatusVdb read(final JsonReader in) throws IOException {
    final RestTeiidVdbStatusVdb vdb = new RestTeiidVdbStatusVdb();
    in.beginObject();

    while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
        case RestTeiidVdbStatusVdb.TEIID_VDB_STATUS_NAME:
            vdb.setName(in.nextString());
            break;
        case RestTeiidVdbStatusVdb.TEIID_VDB_STATUS_DEPLOYED_NAME:
            vdb.setDeployedName(in.nextString());
            break;
        case RestTeiidVdbStatusVdb.TEIID_VDB_STATUS_VERSION:
            vdb.setVersion(in.nextString());
            break;
        case RestTeiidVdbStatusVdb.TEIID_VDB_STATUS_ACTIVE:
            vdb.setActive(in.nextBoolean());
            break;
        case RestTeiidVdbStatusVdb.TEIID_VDB_STATUS_LOADING:
            vdb.setLoading(in.nextBoolean());
            break;
        case RestTeiidVdbStatusVdb.TEIID_VDB_STATUS_FAILED:
            vdb.setFailed(in.nextBoolean());
            break;
        case RestTeiidVdbStatusVdb.TEIID_VDB_STATUS_ERROR:
            final String[] errors = BUILDER.fromJson(in, String[].class);
            vdb.setErrors(Arrays.asList(errors));
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return vdb;
}