@Test public void parsePropertiesNull() throws Exception { Map<String, Object> properties = (new GeoJSONParser(new ByteArrayInputStream("null".getBytes()), this.fType, null)) .parseProperties(); assertEquals(0, properties.size()); }
public Map<String, Object> parseProperties() throws JsonSyntaxException, IOException, IllegalStateException { Map<String, Object> props = new HashMap<String, Object>(); String name; try { if (this.reader.peek() == JsonToken.NULL) { this.reader.nextNull(); throw (new MalformedJsonException( "just here to avoid repeating the return statement")); } } catch (IllegalStateException | MalformedJsonException e) { return props; } this.reader.beginObject(); try { while (this.reader.hasNext()) { name = this.reader.nextName(); switch (this.reader.peek()) { case BOOLEAN: props.put(name, this.reader.nextBoolean()); break; case NUMBER: if (this.featureType.getDescriptor(name) != null && this.featureType .getDescriptor(name) .getType() .getBinding() .getName() .equalsIgnoreCase("java.util.Date")) { props.put( name, (new SimpleDateFormat(GeoJSONParser.DATETIME_FORMAT)) .format(new Date(this.reader.nextLong()))); } else { props.put(name, this.reader.nextDouble()); } break; case STRING: props.put(name, this.reader.nextString()); break; case NULL: this.reader.nextNull(); props.put(name, null); break; default: throw (new JsonSyntaxException("Value expected")); } } } catch (IOException | IllegalStateException e) { throw (new NoSuchElementException(e.getMessage())); } this.reader.endObject(); return props; }
GeoJSONParser implements SimpleFeatureIterator { public Map<String, Object> parseProperties() throws JsonSyntaxException, IOException, IllegalStateException { Map<String, Object> props = new HashMap<String, Object>(); String name; try { if (this.reader.peek() == JsonToken.NULL) { this.reader.nextNull(); throw (new MalformedJsonException( "just here to avoid repeating the return statement")); } } catch (IllegalStateException | MalformedJsonException e) { return props; } this.reader.beginObject(); try { while (this.reader.hasNext()) { name = this.reader.nextName(); switch (this.reader.peek()) { case BOOLEAN: props.put(name, this.reader.nextBoolean()); break; case NUMBER: if (this.featureType.getDescriptor(name) != null && this.featureType .getDescriptor(name) .getType() .getBinding() .getName() .equalsIgnoreCase("java.util.Date")) { props.put( name, (new SimpleDateFormat(GeoJSONParser.DATETIME_FORMAT)) .format(new Date(this.reader.nextLong()))); } else { props.put(name, this.reader.nextDouble()); } break; case STRING: props.put(name, this.reader.nextString()); break; case NULL: this.reader.nextNull(); props.put(name, null); break; default: throw (new JsonSyntaxException("Value expected")); } } } catch (IOException | IllegalStateException e) { throw (new NoSuchElementException(e.getMessage())); } this.reader.endObject(); return props; } }
GeoJSONParser implements SimpleFeatureIterator { public Map<String, Object> parseProperties() throws JsonSyntaxException, IOException, IllegalStateException { Map<String, Object> props = new HashMap<String, Object>(); String name; try { if (this.reader.peek() == JsonToken.NULL) { this.reader.nextNull(); throw (new MalformedJsonException( "just here to avoid repeating the return statement")); } } catch (IllegalStateException | MalformedJsonException e) { return props; } this.reader.beginObject(); try { while (this.reader.hasNext()) { name = this.reader.nextName(); switch (this.reader.peek()) { case BOOLEAN: props.put(name, this.reader.nextBoolean()); break; case NUMBER: if (this.featureType.getDescriptor(name) != null && this.featureType .getDescriptor(name) .getType() .getBinding() .getName() .equalsIgnoreCase("java.util.Date")) { props.put( name, (new SimpleDateFormat(GeoJSONParser.DATETIME_FORMAT)) .format(new Date(this.reader.nextLong()))); } else { props.put(name, this.reader.nextDouble()); } break; case STRING: props.put(name, this.reader.nextString()); break; case NULL: this.reader.nextNull(); props.put(name, null); break; default: throw (new JsonSyntaxException("Value expected")); } } } catch (IOException | IllegalStateException e) { throw (new NoSuchElementException(e.getMessage())); } this.reader.endObject(); return props; } GeoJSONParser(InputStream iStream, SimpleFeatureType featureTypeIn, Logger loggerIn); }
GeoJSONParser implements SimpleFeatureIterator { public Map<String, Object> parseProperties() throws JsonSyntaxException, IOException, IllegalStateException { Map<String, Object> props = new HashMap<String, Object>(); String name; try { if (this.reader.peek() == JsonToken.NULL) { this.reader.nextNull(); throw (new MalformedJsonException( "just here to avoid repeating the return statement")); } } catch (IllegalStateException | MalformedJsonException e) { return props; } this.reader.beginObject(); try { while (this.reader.hasNext()) { name = this.reader.nextName(); switch (this.reader.peek()) { case BOOLEAN: props.put(name, this.reader.nextBoolean()); break; case NUMBER: if (this.featureType.getDescriptor(name) != null && this.featureType .getDescriptor(name) .getType() .getBinding() .getName() .equalsIgnoreCase("java.util.Date")) { props.put( name, (new SimpleDateFormat(GeoJSONParser.DATETIME_FORMAT)) .format(new Date(this.reader.nextLong()))); } else { props.put(name, this.reader.nextDouble()); } break; case STRING: props.put(name, this.reader.nextString()); break; case NULL: this.reader.nextNull(); props.put(name, null); break; default: throw (new JsonSyntaxException("Value expected")); } } } catch (IOException | IllegalStateException e) { throw (new NoSuchElementException(e.getMessage())); } this.reader.endObject(); return props; } GeoJSONParser(InputStream iStream, SimpleFeatureType featureTypeIn, Logger loggerIn); @Override void close(); @Override boolean hasNext(); @Override SimpleFeature next(); void parseFeatureCollection(); static double[] listToArray(List<Double> coords); double[] parseCoordinateArray(); double[] parsePointCoordinates(); List<double[]> parseMultiPointCoordinates(); double[] parseLineStringCoordinates(); List<double[]> parseMultiLineStringCoordinates(); List<double[]> parsePolygonCoordinates(); List<List<double[]>> parseMultiPolygonCoordinates(); Geometry parseGeometry(); Map<String, Object> parseProperties(); SimpleFeature parseFeature(); IOException parseError(); }
GeoJSONParser implements SimpleFeatureIterator { public Map<String, Object> parseProperties() throws JsonSyntaxException, IOException, IllegalStateException { Map<String, Object> props = new HashMap<String, Object>(); String name; try { if (this.reader.peek() == JsonToken.NULL) { this.reader.nextNull(); throw (new MalformedJsonException( "just here to avoid repeating the return statement")); } } catch (IllegalStateException | MalformedJsonException e) { return props; } this.reader.beginObject(); try { while (this.reader.hasNext()) { name = this.reader.nextName(); switch (this.reader.peek()) { case BOOLEAN: props.put(name, this.reader.nextBoolean()); break; case NUMBER: if (this.featureType.getDescriptor(name) != null && this.featureType .getDescriptor(name) .getType() .getBinding() .getName() .equalsIgnoreCase("java.util.Date")) { props.put( name, (new SimpleDateFormat(GeoJSONParser.DATETIME_FORMAT)) .format(new Date(this.reader.nextLong()))); } else { props.put(name, this.reader.nextDouble()); } break; case STRING: props.put(name, this.reader.nextString()); break; case NULL: this.reader.nextNull(); props.put(name, null); break; default: throw (new JsonSyntaxException("Value expected")); } } } catch (IOException | IllegalStateException e) { throw (new NoSuchElementException(e.getMessage())); } this.reader.endObject(); return props; } GeoJSONParser(InputStream iStream, SimpleFeatureType featureTypeIn, Logger loggerIn); @Override void close(); @Override boolean hasNext(); @Override SimpleFeature next(); void parseFeatureCollection(); static double[] listToArray(List<Double> coords); double[] parseCoordinateArray(); double[] parsePointCoordinates(); List<double[]> parseMultiPointCoordinates(); double[] parseLineStringCoordinates(); List<double[]> parseMultiLineStringCoordinates(); List<double[]> parsePolygonCoordinates(); List<List<double[]>> parseMultiPolygonCoordinates(); Geometry parseGeometry(); Map<String, Object> parseProperties(); SimpleFeature parseFeature(); IOException parseError(); static final String ENCODING; static final String DATETIME_FORMAT; static final String ERROR; static final String ERROR_CODE; static final String ERROR_MESSAGE; static final String ERROR_DETAILS; static final String GEOJSON_TYPE; static final String GEOJSON_TYPE_VALUE_FC; static final String GEOJSON_PROPERTIES; static final String GEOJSON_TOTALFEATURES; static final String FEATURES; static final String CRS; static final String CRS_TYPE; static final String CRS_TYPE_VALUE; static final String CRS_PROPERTIES; static final String CRS_PROPERTIES_NAME; static final String FEATURE_TYPE; static final String FEATURE_ID; static final String FEATURE_GEOMETRY; static final String FEATURE_GEOMETRY_TYPE; static final String FEATURE_TYPE_VALUE; static final String FEATURE_GEOMETRY_COORDINATES; static final String FEATURE_PROPERTIES; static final String GEOMETRY_POINT; static final String GEOMETRY_MULTIPOINT; static final String GEOMETRY_LINE; static final String GEOMETRY_MULTILINE; static final String GEOMETRY_POLYGON; static final String GEOMETRY_MULTIPOLYGON; }