Java Code Examples for com.google.gson.stream.JsonReader#skipValue()
The following examples show how to use
com.google.gson.stream.JsonReader#skipValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PackageAdapter.java From TerasologyLauncher with Apache License 2.0 | 6 votes |
@Override public Package read(JsonReader in) throws IOException { String id = null; String version = null; in.beginObject(); while (in.hasNext()) { switch (in.nextName()) { case KEY_ID: id = in.nextString(); break; case KEY_VERSION: version = in.nextString(); break; default: in.skipValue(); } } in.endObject(); return new Package(id, null, version, null, Collections.emptyList()); }
Example 2
Source File: WrapTypeAdapters.java From SimpleProject with MIT License | 6 votes |
@Override public Integer read(JsonReader in) { try { if (in.peek() == JsonToken.NULL) { in.nextNull(); return 0; } return in.nextInt(); } catch (Exception e) { try { in.skipValue(); } catch (Exception e1) { e.printStackTrace(System.out); } } return 0; }
Example 3
Source File: TestQuerySolr.java From nifi with Apache License 2.0 | 6 votes |
private int returnCheckSumForArrayOfJsonObjects(JsonReader reader) throws IOException { int checkSum = 0; reader.beginArray(); while (reader.hasNext()) { reader.beginObject(); while (reader.hasNext()) { if (reader.nextName().equals("count")) { checkSum += reader.nextInt(); } else { reader.skipValue(); } } reader.endObject(); } reader.endArray(); return checkSum; }
Example 4
Source File: QuerySolrIT.java From nifi with Apache License 2.0 | 6 votes |
private int returnCheckSumForArrayOfJsonObjects(JsonReader reader) throws IOException { int checkSum = 0; reader.beginArray(); while (reader.hasNext()) { reader.beginObject(); while (reader.hasNext()) { if (reader.nextName().equals("count")) { checkSum += reader.nextInt(); } else { reader.skipValue(); } } reader.endObject(); } reader.endArray(); return checkSum; }
Example 5
Source File: ReflectiveTypeAdapterFactory.java From letv with Apache License 2.0 | 6 votes |
public T read(JsonReader in) throws IOException { if (in.peek() == JsonToken.NULL) { in.nextNull(); return null; } T instance = this.constructor.construct(); try { in.beginObject(); while (in.hasNext()) { BoundField field = (BoundField) this.boundFields.get(in.nextName()); if (field == null || !field.deserialized) { in.skipValue(); } else { field.read(in, instance); } } in.endObject(); return instance; } catch (Throwable e) { throw new JsonSyntaxException(e); } catch (IllegalAccessException e2) { throw new AssertionError(e2); } }
Example 6
Source File: FeatureCollectionAdapter.java From geogson with Apache License 2.0 | 5 votes |
@Override public FeatureCollection read(JsonReader in) throws IOException { FeatureCollection featureCollection = null; if (in.peek() == JsonToken.NULL) { in.nextNull(); } else if (in.peek() == JsonToken.BEGIN_OBJECT) { in.beginObject(); LinkedList<Feature> features = null; while (in.hasNext()) { String name = in.nextName(); if ("features".equalsIgnoreCase(name)) { in.beginArray(); features = new LinkedList<>(); while(in.peek() == JsonToken.BEGIN_OBJECT) { Feature feature = gson.fromJson(in, Feature.class); features.add(feature); } in.endArray(); } else { in.skipValue(); } } if (features == null) { throw new IllegalArgumentException("Required field 'features' is missing"); } featureCollection = new FeatureCollection(features); in.endObject(); } else { throw new IllegalArgumentException("The given json is not a valid FeatureCollection: " + in.peek()); } return featureCollection; }
Example 7
Source File: BufferAttribute.java From BlueMap with MIT License | 5 votes |
public static BufferAttribute readJson(JsonReader json) throws IOException { List<Float> list = new ArrayList<>(1000); int itemSize = 1; boolean normalized = false; json.beginObject(); //root while (json.hasNext()){ String name = json.nextName(); if(name.equals("array")){ json.beginArray(); //array while (json.hasNext()){ list.add(new Float(json.nextDouble())); } json.endArray(); //array } else if (name.equals("itemSize")) { itemSize = json.nextInt(); } else if (name.equals("normalized")) { normalized = json.nextBoolean(); } else json.skipValue(); } json.endObject(); //root //collect values in array float[] values = new float[list.size()]; for (int i = 0; i < values.length; i++) { values[i] = list.get(i); } return new BufferAttribute(values, itemSize, normalized); }
Example 8
Source File: HistoryFragmentVM.java From chaoli-forum-for-android-2 with GNU General Public License v3.0 | 5 votes |
@Override public HistoryItem.Data read(JsonReader in) throws IOException { if (in.peek() == JsonToken.BOOLEAN) { in.skipValue(); return null; } return defaultAdapter.read(in); }
Example 9
Source File: ChannelReader.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
private Map<MetaKey, CacheEntryInformation> readCacheEntries ( final JsonReader jr ) throws IOException { final Map<MetaKey, CacheEntryInformation> result = new HashMap<> (); jr.beginObject (); while ( jr.hasNext () ) { final String entryName = jr.nextName (); jr.beginObject (); String name = null; Long size = null; String mimeType = null; Instant timestamp = null; while ( jr.hasNext () ) { final String ele = jr.nextName (); switch ( ele ) { case "name": name = jr.nextString (); break; case "size": size = jr.nextLong (); break; case "mimeType": mimeType = jr.nextString (); break; case "timestamp": timestamp = readTime ( jr ); break; default: jr.skipValue (); break; } } if ( name == null || size == null || mimeType == null || timestamp == null ) { throw new IOException ( "Invalid format" ); } jr.endObject (); final MetaKey key = MetaKey.fromString ( entryName ); result.put ( key, new CacheEntryInformation ( key, name, size, mimeType, timestamp ) ); } jr.endObject (); return result; }
Example 10
Source File: MessageJsonSerializer.java From buck with Apache License 2.0 | 4 votes |
@Override public Message read(JsonReader in) throws IOException { in.beginObject(); Message.Kind kind = Message.Kind.UNKNOWN; String text = ""; String rawMessage = null; Optional<String> toolName = Optional.absent(); ImmutableList.Builder<SourceFilePosition> positions = new ImmutableList.Builder<SourceFilePosition>(); SourceFile legacyFile = SourceFile.UNKNOWN; SourcePosition legacyPosition = SourcePosition.UNKNOWN; while (in.hasNext()) { String name = in.nextName(); if (name.equals(KIND)) { //noinspection StringToUpperCaseOrToLowerCaseWithoutLocale Message.Kind theKind = KIND_STRING_ENUM_MAP.inverse() .get(in.nextString().toLowerCase()); kind = (theKind != null) ? theKind : Message.Kind.UNKNOWN; } else if (name.equals(TEXT)) { text = in.nextString(); } else if (name.equals(RAW_MESSAGE)) { rawMessage = in.nextString(); } else if (name.equals(TOOL_NAME)) { toolName = Optional.of(in.nextString()); } else if (name.equals(SOURCE_FILE_POSITIONS)) { switch (in.peek()) { case BEGIN_ARRAY: in.beginArray(); while(in.hasNext()) { positions.add(mSourceFilePositionTypeAdapter.read(in)); } in.endArray(); break; case BEGIN_OBJECT: positions.add(mSourceFilePositionTypeAdapter.read(in)); break; default: in.skipValue(); break; } } else if (name.equals(LEGACY_SOURCE_PATH)) { legacyFile = new SourceFile(new File(in.nextString())); } else if (name.equals(LEGACY_POSITION)) { legacyPosition = mSourcePositionTypeAdapter.read(in); } else { in.skipValue(); } } in.endObject(); if (legacyFile != SourceFile.UNKNOWN || legacyPosition != SourcePosition.UNKNOWN) { positions.add(new SourceFilePosition(legacyFile, legacyPosition)); } if (rawMessage == null) { rawMessage = text; } ImmutableList<SourceFilePosition> sourceFilePositions = positions.build(); if (!sourceFilePositions.isEmpty()) { return new Message(kind, text, rawMessage, toolName, sourceFilePositions); } else { return new Message(kind, text, rawMessage, toolName, ImmutableList.of(SourceFilePosition.UNKNOWN)); } }
Example 11
Source File: MessageJsonSerializer.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public Message read(JsonReader in) throws IOException { in.beginObject(); Message.Kind kind = Message.Kind.UNKNOWN; String text = ""; String rawMessage = null; ImmutableList.Builder<SourceFilePosition> positions = new ImmutableList.Builder<SourceFilePosition>(); SourceFile legacyFile = SourceFile.UNKNOWN; SourcePosition legacyPosition = SourcePosition.UNKNOWN; while (in.hasNext()) { String name = in.nextName(); if (name.equals(KIND)) { //noinspection StringToUpperCaseOrToLowerCaseWithoutLocale Message.Kind theKind = KIND_STRING_ENUM_MAP.inverse() .get(in.nextString().toLowerCase()); kind = (theKind != null) ? theKind : Message.Kind.UNKNOWN; } else if (name.equals(TEXT)) { text = in.nextString(); } else if (name.equals(RAW_MESSAGE)) { rawMessage = in.nextString(); } else if (name.equals(SOURCE_FILE_POSITIONS)) { switch (in.peek()) { case BEGIN_ARRAY: in.beginArray(); while(in.hasNext()) { positions.add(mSourceFilePositionTypeAdapter.read(in)); } in.endArray(); break; case BEGIN_OBJECT: positions.add(mSourceFilePositionTypeAdapter.read(in)); break; default: in.skipValue(); break; } } else if (name.equals(LEGACY_SOURCE_PATH)) { legacyFile = new SourceFile(new File(in.nextString())); } else if (name.equals(LEGACY_POSITION)) { legacyPosition = mSourcePositionTypeAdapter.read(in); } else { in.skipValue(); } } in.endObject(); if (legacyFile != SourceFile.UNKNOWN || legacyPosition != SourcePosition.UNKNOWN) { positions.add(new SourceFilePosition(legacyFile, legacyPosition)); } if (rawMessage == null) { rawMessage = text; } ImmutableList<SourceFilePosition> sourceFilePositions = positions.build(); if (!sourceFilePositions.isEmpty()) { return new Message(kind, text, rawMessage, sourceFilePositions); } else { return new Message(kind, text, rawMessage, ImmutableList.of(SourceFilePosition.UNKNOWN)); } }
Example 12
Source File: TraceEvent.java From bazel with Apache License 2.0 | 4 votes |
private static TraceEvent createFromJsonReader(JsonReader reader) throws IOException { String category = null; String name = null; Duration timestamp = null; Duration duration = null; long threadId = -1; String primaryOutputPath = null; String targetLabel = null; reader.beginObject(); while (reader.hasNext()) { switch (reader.nextName()) { case "cat": category = reader.nextString(); break; case "name": name = reader.nextString(); break; case "ts": // Duration has no microseconds :-/. timestamp = Duration.ofNanos(reader.nextLong() * 1000); break; case "dur": duration = Duration.ofNanos(reader.nextLong() * 1000); break; case "tid": threadId = reader.nextLong(); break; case "out": primaryOutputPath = reader.nextString(); break; case "args": ImmutableMap<String, Object> args = parseMap(reader); Object target = args.get("target"); targetLabel = target instanceof String ? (String) target : null; break; default: reader.skipValue(); } } reader.endObject(); return TraceEvent.create( category, name, timestamp, duration, threadId, primaryOutputPath, targetLabel); }
Example 13
Source File: StreamMetadataJsonAdapter.java From esjc with MIT License | 4 votes |
@Override public StreamMetadata read(JsonReader reader) throws IOException { StreamMetadata.Builder builder = StreamMetadata.newBuilder(); if (reader.peek() == JsonToken.NULL) { return null; } reader.beginObject(); while (reader.peek() != JsonToken.END_OBJECT && reader.hasNext()) { String name = reader.nextName(); switch (name) { case MAX_COUNT: builder.maxCount(reader.nextLong()); break; case MAX_AGE: builder.maxAge(Duration.ofSeconds(reader.nextLong())); break; case TRUNCATE_BEFORE: builder.truncateBefore(reader.nextLong()); break; case CACHE_CONTROL: builder.cacheControl(Duration.ofSeconds(reader.nextLong())); break; case ACL: StreamAcl acl = streamAclJsonAdapter.read(reader); if (acl != null) { builder.aclReadRoles(acl.readRoles); builder.aclWriteRoles(acl.writeRoles); builder.aclDeleteRoles(acl.deleteRoles); builder.aclMetaReadRoles(acl.metaReadRoles); builder.aclMetaWriteRoles(acl.metaWriteRoles); } break; default: switch (reader.peek()) { case NULL: reader.nextNull(); builder.customProperty(name, (String) null); break; case BEGIN_ARRAY: List<Object> values = new ArrayList<>(); reader.beginArray(); while (reader.peek() != JsonToken.END_ARRAY) { switch (reader.peek()) { case NULL: reader.nextNull(); values.add(null); break; case BOOLEAN: values.add(reader.nextBoolean()); break; case NUMBER: values.add(new BigDecimal(reader.nextString())); break; case STRING: values.add(reader.nextString()); } } reader.endArray(); if (values.stream().anyMatch(v -> v instanceof Boolean)) { builder.customProperty(name, values.stream().toArray(Boolean[]::new)); } else if (values.stream().anyMatch(v -> v instanceof Number)) { builder.customProperty(name, values.stream().toArray(Number[]::new)); } else { builder.customProperty(name, values.stream().toArray(String[]::new)); } break; case BOOLEAN: builder.customProperty(name, reader.nextBoolean()); break; case NUMBER: builder.customProperty(name, new BigDecimal(reader.nextString())); break; case STRING: builder.customProperty(name, reader.nextString()); break; default: reader.skipValue(); } } } reader.endObject(); return builder.build(); }
Example 14
Source File: ExpandriveBookmarkCollection.java From cyberduck with GNU General Public License v3.0 | 4 votes |
@Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { try { final JsonReader reader = new JsonReader(new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8)); reader.beginArray(); while(reader.hasNext()) { reader.beginObject(); final Host current = new Host(protocols.forScheme(Scheme.ftp)); boolean skip = false; while(reader.hasNext()) { final String name = reader.nextName(); switch(name) { case "server": final String hostname = this.readNext(name, reader); if(StringUtils.isBlank(hostname)) { skip = true; } else { current.setHostname(hostname); } break; case "username": current.getCredentials().setUsername(this.readNext(name, reader)); break; case "private_key_file": final String key = this.readNext(name, reader); if(StringUtils.isNotBlank(key)) { current.getCredentials().setIdentity(LocalFactory.get(key)); } break; case "remotePath": current.setDefaultPath(this.readNext(name, reader)); break; case "type": final Protocol type = protocols.forName(this.readNext(name, reader)); if(null != type) { current.setProtocol(type); } break; case "protocol": final Protocol protocol = protocols.forName(this.readNext(name, reader)); if(null != protocol) { current.setProtocol(protocol); // Reset port to default current.setPort(-1); } break; case "name": current.setNickname(this.readNext(name, reader)); break; case "region": current.setRegion(this.readNext(name, reader)); break; default: log.warn(String.format("Ignore property %s", name)); reader.skipValue(); break; } } reader.endObject(); if(!skip) { this.add(current); } } reader.endArray(); } catch(IllegalStateException | IOException e) { throw new LocalAccessDeniedException(e.getMessage(), e); } }
Example 15
Source File: BaseGeometryTypeAdapter.java From mapbox-java with MIT License | 4 votes |
public CoordinateContainer<T> readCoordinateContainer(JsonReader jsonReader) throws IOException { if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); return null; } jsonReader.beginObject(); String type = null; BoundingBox bbox = null; T coordinates = null; while (jsonReader.hasNext()) { String name = jsonReader.nextName(); if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); continue; } switch (name) { case "type": TypeAdapter<String> stringAdapter = this.stringAdapter; if (stringAdapter == null) { stringAdapter = gson.getAdapter(String.class); this.stringAdapter = stringAdapter; } type = stringAdapter.read(jsonReader); break; case "bbox": TypeAdapter<BoundingBox> boundingBoxAdapter = this.boundingBoxAdapter; if (boundingBoxAdapter == null) { boundingBoxAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxAdapter = boundingBoxAdapter; } bbox = boundingBoxAdapter.read(jsonReader); break; case "coordinates": TypeAdapter<T> coordinatesAdapter = this.coordinatesAdapter; if (coordinatesAdapter == null) { throw new GeoJsonException("Coordinates type adapter is null"); } coordinates = coordinatesAdapter.read(jsonReader); break; default: jsonReader.skipValue(); } } jsonReader.endObject(); return createCoordinateContainer(type, bbox, coordinates); }
Example 16
Source File: TestGetSolr.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testRecordWriter() throws IOException, InitializationException { final org.apache.nifi.processors.solr.TestGetSolr.TestableProcessor proc = new org.apache.nifi.processors.solr.TestGetSolr.TestableProcessor(solrClient); TestRunner runner = createDefaultTestRunner(proc); runner.setProperty(GetSolr.RETURN_TYPE, GetSolr.MODE_REC.getValue()); runner.setProperty(GetSolr.RETURN_FIELDS, "id,created,integer_single"); runner.setProperty(GetSolr.BATCH_SIZE, "10"); final String outputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/test-schema.avsc"))); final JsonRecordSetWriter jsonWriter = new JsonRecordSetWriter(); runner.addControllerService("writer", jsonWriter); runner.setProperty(jsonWriter, SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, SchemaAccessUtils.SCHEMA_TEXT_PROPERTY); runner.setProperty(jsonWriter, SchemaAccessUtils.SCHEMA_TEXT, outputSchemaText); runner.setProperty(jsonWriter, "Pretty Print JSON", "true"); runner.setProperty(jsonWriter, "Schema Write Strategy", "full-schema-attribute"); runner.enableControllerService(jsonWriter); runner.setProperty(SolrUtils.RECORD_WRITER, "writer"); runner.run(1,true, true); runner.assertQueueEmpty(); runner.assertAllFlowFilesTransferred(GetSolr.REL_SUCCESS, 1); runner.assertAllFlowFilesContainAttribute(CoreAttributes.MIME_TYPE.key()); // Check for valid json JsonReader reader = new JsonReader(new InputStreamReader(new ByteArrayInputStream( runner.getContentAsByteArray(runner.getFlowFilesForRelationship(GetSolr.REL_SUCCESS).get(0))))); reader.beginArray(); int controlScore = 0; while (reader.hasNext()) { reader.beginObject(); while (reader.hasNext()) { if (reader.nextName().equals("integer_single")) controlScore += reader.nextInt(); else reader.skipValue(); } reader.endObject(); } assertEquals(controlScore, 45); }
Example 17
Source File: TestQuerySolr.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testRecordResponse() throws IOException, InitializationException { SolrClient solrClient = createSolrClient(); TestRunner runner = createRunnerWithSolrClient(solrClient); runner.setProperty(QuerySolr.RETURN_TYPE, QuerySolr.MODE_REC.getValue()); runner.setProperty(QuerySolr.SOLR_PARAM_FIELD_LIST, "id,created,integer_single"); runner.setProperty(QuerySolr.SOLR_PARAM_ROWS, "10"); final String outputSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/test-schema.avsc"))); final JsonRecordSetWriter jsonWriter = new JsonRecordSetWriter(); runner.addControllerService("writer", jsonWriter); runner.setProperty(jsonWriter, SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, SchemaAccessUtils.SCHEMA_TEXT_PROPERTY); runner.setProperty(jsonWriter, SchemaAccessUtils.SCHEMA_TEXT, outputSchemaText); runner.setProperty(jsonWriter, "Pretty Print JSON", "true"); runner.setProperty(jsonWriter, "Schema Write Strategy", "full-schema-attribute"); runner.enableControllerService(jsonWriter); runner.setProperty(SolrUtils.RECORD_WRITER, "writer"); runner.setNonLoopConnection(false); runner.run(1); runner.assertQueueEmpty(); runner.assertTransferCount(QuerySolr.RESULTS, 1); JsonReader reader = new JsonReader(new InputStreamReader(new ByteArrayInputStream( runner.getContentAsByteArray(runner.getFlowFilesForRelationship(QuerySolr.RESULTS).get(0))))); reader.beginArray(); int controlScore = 0; while (reader.hasNext()) { reader.beginObject(); while (reader.hasNext()) { if (reader.nextName().equals("integer_single")) { controlScore += reader.nextInt(); } else { reader.skipValue(); } } reader.endObject(); } reader.close(); solrClient.close(); assertEquals(controlScore, 45); }
Example 18
Source File: Feature.java From mapbox-java with MIT License | 4 votes |
@Override public Feature read(JsonReader jsonReader) throws IOException { if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); return null; } jsonReader.beginObject(); String type = null; BoundingBox bbox = null; String id = null; Geometry geometry = null; JsonObject properties = null; while (jsonReader.hasNext()) { String name = jsonReader.nextName(); if (jsonReader.peek() == JsonToken.NULL) { jsonReader.nextNull(); continue; } switch (name) { case "type": TypeAdapter<String> strTypeAdapter = this.stringTypeAdapter; if (strTypeAdapter == null) { strTypeAdapter = gson.getAdapter(String.class); this.stringTypeAdapter = strTypeAdapter; } type = strTypeAdapter.read(jsonReader); break; case "bbox": TypeAdapter<BoundingBox> boundingBoxTypeAdapter = this.boundingBoxTypeAdapter; if (boundingBoxTypeAdapter == null) { boundingBoxTypeAdapter = gson.getAdapter(BoundingBox.class); this.boundingBoxTypeAdapter = boundingBoxTypeAdapter; } bbox = boundingBoxTypeAdapter.read(jsonReader); break; case "id": strTypeAdapter = this.stringTypeAdapter; if (strTypeAdapter == null) { strTypeAdapter = gson.getAdapter(String.class); this.stringTypeAdapter = strTypeAdapter; } id = strTypeAdapter.read(jsonReader); break; case "geometry": TypeAdapter<Geometry> geometryTypeAdapter = this.geometryTypeAdapter; if (geometryTypeAdapter == null) { geometryTypeAdapter = gson.getAdapter(Geometry.class); this.geometryTypeAdapter = geometryTypeAdapter; } geometry = geometryTypeAdapter.read(jsonReader); break; case "properties": TypeAdapter<JsonObject> jsonObjectTypeAdapter = this.jsonObjectTypeAdapter; if (jsonObjectTypeAdapter == null) { jsonObjectTypeAdapter = gson.getAdapter(JsonObject.class); this.jsonObjectTypeAdapter = jsonObjectTypeAdapter; } properties = jsonObjectTypeAdapter.read(jsonReader); break; default: jsonReader.skipValue(); } } jsonReader.endObject(); return new Feature(type, bbox, id, geometry, properties); }
Example 19
Source File: ChannelReader.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
public ModifyContextImpl read () throws IOException { this.numberOfBytes = 0; final Reader reader = new InputStreamReader ( this.stream, StandardCharsets.UTF_8 ); final ChannelState.Builder state = new ChannelState.Builder (); Boolean locked = null; Map<MetaKey, CacheEntryInformation> cacheEntries = Collections.emptyMap (); Map<String, ArtifactInformation> artifacts = Collections.emptyMap (); Map<MetaKey, String> extractedMetaData = Collections.emptyMap (); Map<MetaKey, String> providedMetaData = Collections.emptyMap (); Map<String, String> aspects = new HashMap<> (); final JsonReader jr = new JsonReader ( reader ); jr.beginObject (); while ( jr.hasNext () ) { final String name = jr.nextName (); switch ( name ) { case "locked": state.setLocked ( locked = jr.nextBoolean () ); break; case "creationTimestamp": state.setCreationTimestamp ( readTime ( jr ) ); break; case "modificationTimestamp": state.setModificationTimestamp ( readTime ( jr ) ); break; case "cacheEntries": cacheEntries = readCacheEntries ( jr ); break; case "artifacts": artifacts = readArtifacts ( jr ); break; case "extractedMetaData": extractedMetaData = readMetadata ( jr ); break; case "providedMetaData": providedMetaData = readMetadata ( jr ); break; case "validationMessages": state.setValidationMessages ( readValidationMessages ( jr ) ); break; case "aspects": aspects = readAspects ( jr ); break; default: jr.skipValue (); break; } } jr.endObject (); if ( locked == null ) { throw new IOException ( "Missing values for channel" ); } // transient information state.setNumberOfArtifacts ( artifacts.size () ); state.setNumberOfBytes ( this.numberOfBytes ); // create result return new ModifyContextImpl ( this.channelId, this.store, this.cacheStore, state.build (), aspects, artifacts, cacheEntries, extractedMetaData, providedMetaData ); }
Example 20
Source File: InitializeParamsTypeAdapter.java From lsp4j with Eclipse Public License 2.0 | 4 votes |
public InitializeParams read(final JsonReader in) throws IOException { JsonToken nextToken = in.peek(); if (nextToken == JsonToken.NULL) { return null; } InitializeParams result = new InitializeParams(); in.beginObject(); while (in.hasNext()) { String name = in.nextName(); switch (name) { case "processId": result.setProcessId(readProcessId(in)); break; case "rootPath": result.setRootPath(readRootPath(in)); break; case "rootUri": result.setRootUri(readRootUri(in)); break; case "initializationOptions": result.setInitializationOptions(readInitializationOptions(in)); break; case "capabilities": result.setCapabilities(readCapabilities(in)); break; case "clientName": result.setClientName(readClientName(in)); break; case "clientInfo": result.setClientInfo(readClientInfo(in)); break; case "trace": result.setTrace(readTrace(in)); break; case "workspaceFolders": result.setWorkspaceFolders(readWorkspaceFolders(in)); break; default: in.skipValue(); } } in.endObject(); return result; }