List of usage examples for com.google.gson.stream JsonReader beginObject
public void beginObject() throws IOException
From source file:org.komodo.rest.relational.json.ImportExportStatusSerializer.java
License:Open Source License
/** * {@inheritDoc}//w ww . j av a 2s . co 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 w w . j a va2 s . c o m*/ * * @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}/*from w w w .jav a 2s. 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 ww .j a v a 2 s. c o 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(); 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);/*w ww .j av a2s. co m*/ 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 v a2 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 ww w. j a v a 2s .c o 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 w w . ja 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}//from www .ja v a 2 s . c o m * * @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}// w w w .j a v a 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; }