Class JsonStreetsideDecoder
- java.lang.Object
-
- org.openstreetmap.josm.plugins.streetside.utils.api.JsonStreetsideDecoder
-
public final class JsonStreetsideDecoder extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static org.apache.log4j.Loggerlogger
-
Constructor Summary
Constructors Modifier Constructor Description privateJsonStreetsideDecoder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static double[]decodeDoublePair(javax.json.JsonArray json)Decodes a pair of double values, which are stored in aJsonArrayof exactly size 2.static <T> java.util.Collection<T>decodeFeatureCollection(javax.json.JsonObject json, java.util.function.Function<javax.json.JsonObject,T> featureDecoder)Parses a givenJsonObjectas a GeoJSON FeatureCollection into aCollectionof the desired Java objects.(package private) static LatLondecodeLatLon(javax.json.JsonArray json)Decodes aJsonArrayof exactly size 2 to aLatLoninstance.(package private) static java.lang.LongdecodeTimestamp(java.lang.String timestamp)Decodes a timestamp formatted as aStringto the equivalent UNIX epoch timestamp (number of milliseconds since 1970-01-01T00:00:00.000+0000).
-
-
-
Field Detail
-
logger
static final org.apache.log4j.Logger logger
-
-
Constructor Detail
-
JsonStreetsideDecoder
private JsonStreetsideDecoder()
-
-
Method Detail
-
decodeFeatureCollection
public static <T> java.util.Collection<T> decodeFeatureCollection(javax.json.JsonObject json, java.util.function.Function<javax.json.JsonObject,T> featureDecoder)
Parses a givenJsonObjectas a GeoJSON FeatureCollection into aCollectionof the desired Java objects. The method, which converts the GeoJSON features into Java objects is given as a parameter to this method.- Type Parameters:
T- feature type- Parameters:
json- theJsonObjectto be parsedfeatureDecoder- feature decoder which transforms JSON objects to Java objects- Returns:
- a
Collectionwhich is parsed from the givenJsonObject, which contains GeoJSON. Currently aHashSetis used, but please don't rely on it, this could change at any time without prior notice. The return value will not benull.
-
decodeLatLon
static LatLon decodeLatLon(javax.json.JsonArray json)
Decodes aJsonArrayof exactly size 2 to aLatLoninstance. The first value in theJsonArrayis treated as longitude, the second one as latitude.- Parameters:
json- theJsonArraycontaining the two numbers- Returns:
- the decoded
LatLoninstance, ornullif the parameter is not aJsonArrayof exactly size 2 containing twoJsonNumbers.
-
decodeDoublePair
static double[] decodeDoublePair(javax.json.JsonArray json)
Decodes a pair of double values, which are stored in aJsonArrayof exactly size 2.- Parameters:
json- theJsonArraycontaining the two values- Returns:
- a double array which contains the two values in the same order, or
nullif the parameter was not aJsonArrayof exactly size 2 containing twoJsonNumbers
-
decodeTimestamp
static java.lang.Long decodeTimestamp(java.lang.String timestamp)
Decodes a timestamp formatted as aStringto the equivalent UNIX epoch timestamp (number of milliseconds since 1970-01-01T00:00:00.000+0000).- Parameters:
timestamp- the timestamp formatted according to the formatyyyy-MM-dd'T'HH:mm:ss.SSSX- Returns:
- the point in time as a
Longvalue representing the UNIX epoch time, ornullif the parameter does not match the required format (this also triggers a warning viaLogger, or the parameter isnull).
-
-