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

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

Introduction

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

Prototype

public String nextName() throws IOException 

Source Link

Document

Returns the next token, a com.google.gson.stream.JsonToken#NAME property name , and consumes it.

Usage

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

License:Open Source License

/**
 * {@inheritDoc}/*ww  w.ja va  2s.c om*/
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public KomodoConnectionAttributes read(final JsonReader in) throws IOException {
    final KomodoConnectionAttributes ConnectionAttr = createEntity();
    in.beginObject();

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

        switch (name) {
        case KomodoConnectionAttributes.JNDI_LABEL:
            ConnectionAttr.setJndi(in.nextString());
            break;
        case KomodoConnectionAttributes.JDBC_LABEL:
            ConnectionAttr.setJdbc(in.nextBoolean());
            break;
        case KomodoConnectionAttributes.DRIVER_LABEL:
            ConnectionAttr.setDriver(in.nextString());
            break;
        case KomodoConnectionAttributes.PARAMETERS_LABEL:
            Map<String, String> parameters = BUILDER.fromJson(in, Map.class);
            for (Map.Entry<String, String> parameter : parameters.entrySet()) {
                ConnectionAttr.setParameter(parameter.getKey(), parameter.getValue());
            }
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return ConnectionAttr;
}

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

License:Open Source License

/**
 * {@inheritDoc}// www .  j av  a  2  s.c o  m
 *
 * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
 */
@Override
public KomodoDataserviceUpdateAttributes read(final JsonReader in) throws IOException {
    final KomodoDataserviceUpdateAttributes updateAttrs = new KomodoDataserviceUpdateAttributes();
    in.beginObject();

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

        switch (name) {
        case KomodoDataserviceUpdateAttributes.DATASERVICE_NAME_LABEL:
            updateAttrs.setDataserviceName(in.nextString());
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_TABLE_PATH_LABEL:
            updateAttrs.setTablePath(in.nextString());
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_MODEL_SOURCE_PATH_LABEL:
            updateAttrs.setModelSourcePath(in.nextString());
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_COLUMN_NAMES_LABEL:
            List<String> colNames = BUILDER.fromJson(in, List.class);
            updateAttrs.setColumnNames(colNames);
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_RH_TABLE_PATH_LABEL:
            updateAttrs.setRhTablePath(in.nextString());
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_RH_MODEL_SOURCE_PATH_LABEL:
            updateAttrs.setRhModelSourcePath(in.nextString());
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_RH_COLUMN_NAMES_LABEL:
            List<String> rhColNames = BUILDER.fromJson(in, List.class);
            updateAttrs.setRhColumnNames(rhColNames);
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_JOIN_TYPE_LABEL:
            updateAttrs.setJoinType(in.nextString());
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_CRITERIA_PREDICATES_LABEL:
            List<Map<String, String>> predicates = BUILDER.fromJson(in, List.class);
            updateAttrs.setCriteriaPredicates(predicates);
            break;
        case KomodoDataserviceUpdateAttributes.DATASERVICE_VIEW_DDL_LABEL:
            updateAttrs.setViewDdl(in.nextString());
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return updateAttrs;
}

From source file:org.komodo.rest.relational.json.DataSourceJdbcTableAttributesSerializer.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 KomodoDataSourceJdbcTableAttributes read(final JsonReader in) throws IOException {
    final KomodoDataSourceJdbcTableAttributes updateAttrs = new KomodoDataSourceJdbcTableAttributes();
    in.beginObject();

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

        switch (name) {
        case KomodoDataSourceJdbcTableAttributes.DATA_SOURCE_NAME_LABEL:
            updateAttrs.setDataSourceName(in.nextString());
            break;
        case KomodoDataSourceJdbcTableAttributes.CATALOG_FILTER_LABEL:
            updateAttrs.setCatalogFilter(in.nextString());
            break;
        case KomodoDataSourceJdbcTableAttributes.SCHEMA_FILTER_LABEL:
            updateAttrs.setSchemaFilter(in.nextString());
            break;
        case KomodoDataSourceJdbcTableAttributes.TABLE_FILTER_LABEL:
            updateAttrs.setTableFilter(in.nextString());
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return updateAttrs;
}

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

License:Open Source License

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

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

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

        switch (name) {
        case KomodoFileAttributes.NAME_LABEL:
            fileAttr.setName(in.nextString());
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return fileAttr;
}

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

License:Open Source License

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

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

        switch (name) {
        case ImportExportStatus.NAME_LABEL:
            status.setName(in.nextString());
            break;
        case ImportExportStatus.TYPE_LABEL:
            status.setType(in.nextString());
            break;
        case ImportExportStatus.SUCCESS_LABEL:
            status.setSuccess(in.nextBoolean());
            break;
        case ImportExportStatus.DOWNLOADABLE_LABEL:
            status.setDownloadable(in.nextBoolean());
            break;
        case ImportExportStatus.CONTENT_LABEL:
            status.setContent(in.nextString());
            break;
        case ImportExportStatus.MESSAGE_LABEL:
            status.setMessage(in.nextString());
            break;
        case ImportExportStatus.DOWNLOADABLE_SIZE_LABEL:
            status.setDownloadableSize(in.nextLong());
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return status;
}

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

License:Open Source License

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

    while (in.hasNext()) {
        final String name = in.nextName();
        readPath(in, name, pathAttr);
    }

    in.endObject();

    return pathAttr;
}

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

License:Open Source License

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

    while (in.hasNext()) {
        final String name = in.nextName();
        switch (name) {
        case KomodoQueryAttribute.QUERY_LABEL:
            queryAttr.setQuery(in.nextString());
            break;
        case KomodoQueryAttribute.TARGET_LABEL:
            queryAttr.setTarget(in.nextString());
            break;
        case KomodoQueryAttribute.LIMIT_LABEL:
            queryAttr.setLimit(in.nextInt());
            break;
        case KomodoQueryAttribute.OFFSET_LABEL:
            queryAttr.setOffset(in.nextInt());
            break;
        }
    }

    in.endObject();

    return queryAttr;
}

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

License:Open Source License

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

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

        switch (name) {
        case RestQueryColumn.NAME_LABEL:
            queryColumn.setName(in.nextString());
            break;
        case RestQueryColumn.LABEL_LABEL:
            queryColumn.setLabel(in.nextString());
            break;
        case RestQueryColumn.TYPE_LABEL:
            queryColumn.setType(in.nextString());
            break;
        default:
            throw new IOException(Messages.getString(UNEXPECTED_JSON_TOKEN, name));
        }
    }

    in.endObject();

    return queryColumn;
}

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  w w.  j a  v a 2 s. c o m*/

    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}/* w ww .j  a va 2 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;
}