org.opengis.cite.ogcapifeatures10.util

## Class JsonUtils

- java.lang.Object
- - org.opengis.cite.ogcapifeatures10.util.JsonUtils

-     public class JsonUtils
      extends Object

  Author:
    Lyn Goltz

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `collectNumberOfAllReturnedFeatures(io.restassured.path.json.JsonPath jsonPath, int maximumLimit)` Collects the number of all returned features by iterating over all 'next' links and summarizing the size of features in 'features' array property.
    `static Map<String,Object>` | `findLinkByRel(List<Map<String,Object>> links, String expectedRel)` Parses the link with 'rel=self'.
    `static List<String>` | `findLinksWithoutRelOrType(List<Map<String,Object>> links, Set<String> rels)` Parses the links without 'rel' or 'type' property.
    `static List<Map<String,Object>>` | `findLinksWithSupportedMediaTypeByRel(List<Map<String,Object>> links, List<String> mediaTypesToSupport, String expectedRel)` Parses all links with 'type' of one of the passed mediaTypes and the 'rel' property with the passed value.
    `static List<String>` | `findUnsupportedTypes(List<Map<String,Object>> links, List<String> mediaTypesToSuppport)` Parsing the media types which does not have a link woth property 'type' for.
    `static String` | `formatDate(LocalDate date)` Formats the passed string as ISO 8601 date.
    `static String` | `formatDate(ZonedDateTime dateTime)` Formats the passed string as ISO 8601 date.
    `static String` | `formatDateRange(ZonedDateTime beginDateTime, ZonedDateTime endDateTime)` Formats the passed string as a period using a start and end time.
    `static String` | `formatDateRangeWithDuration(LocalDate beginDate, LocalDate endDate)` Formats the passed string as a period using start time and a duration.
    `static boolean` | `hasProperty(String propertyName, io.restassured.path.json.JsonPath jsonPath)` Checks if a property with the passed name exists in the jsonPath.
    `static boolean` | `linkIncludesRelAndType(Map<String,Object> link)` Checks if the passed link contains 'rel' and 'type' properties.
    `static ZonedDateTime` | `parseAsDate(String dateTime)` Parses the passed string as ISO 8601 date.
    `static String` | `parseFeatureId(io.restassured.path.json.JsonPath collectionItemJson)` Parses the id of the first feature from the passed json.
    `static BBox` | `parseSpatialExtent(Map<String,Object> collection)` Parses the spatial extent from the passed collection.
    `static TemporalExtent` | `parseTemporalExtent(Map<String,Object> collection)` Parses the temporal extent from the passed collection.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### parseFeatureId

          public static String parseFeatureId(io.restassured.path.json.JsonPath collectionItemJson)

      Parses the id of the first feature from the passed json.
      Parameters:
        `collectionItemJson` - the json document containing the features, never `null`
      Returns:
        the parsed id, may be `null` if no feature could be found

    - #### parseTemporalExtent

          public static TemporalExtent parseTemporalExtent(Map<String,Object> collection)

      Parses the temporal extent from the passed collection.
      Parameters:
        `collection` - the collection containing the extent to parse, never `null`
      Returns:
        the parsed temporal extent, `null` if no extent exists
      Throws:
        `IllegalArgumentException` - if the number of items in the extent invalid

    - #### parseAsDate

          public static ZonedDateTime parseAsDate(String dateTime)

      Parses the passed string as ISO 8601 date.
      Parameters:
        `dateTime` - the dateTime to parse, never `null`
      Returns:
        the parsed date, never `null`

    - #### formatDate

          public static String formatDate(ZonedDateTime dateTime)

      Formats the passed string as ISO 8601 date. Example: "2018-02-12T23:20:50Z"
      Parameters:
        `dateTime` - the dateTime to format, never `null`
      Returns:
        the formatted date, never `null`

    - #### formatDate

          public static String formatDate(LocalDate date)

      Formats the passed string as ISO 8601 date. Example: "2018-02-12"
      Parameters:
        `date` - the dateTime to format, never `null`
      Returns:
        the formatted date, never `null`

    - #### formatDateRange

          public static String formatDateRange(ZonedDateTime beginDateTime,
                                               ZonedDateTime endDateTime)

      Formats the passed string as a period using a start and end time. Example: "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z"
      Parameters:
        `beginDateTime` - the begin dateTime to format, never `null`
        `endDateTime` - the end dateTime to format, never `null`
      Returns:
        the formatted date, never `null`

    - #### formatDateRangeWithDuration

          public static String formatDateRangeWithDuration(LocalDate beginDate,
                                                           LocalDate endDate)

      Formats the passed string as a period using start time and a duration. Example: "2018-02-12T00:00:00Z/P1M6DT12H31M12S"
      Parameters:
        `beginDate` - the begin date to format, never `null`
        `endDate` - the end date to format, never `null`
      Returns:
        the formatted date, never `null`

    - #### parseSpatialExtent

          public static BBox parseSpatialExtent(Map<String,Object> collection)

      Parses the spatial extent from the passed collection.
      Parameters:
        `collection` - the collection containing the extent to parse, never `null`
      Returns:
        the parsed bbox, `null` if no extent exists
      Throws:
        `IllegalArgumentException` - if the number of items in the extent invalid

    - #### findLinksWithSupportedMediaTypeByRel

          public static List<Map<String,Object>> findLinksWithSupportedMediaTypeByRel(List<Map<String,Object>> links,
                                                                                      List<String> mediaTypesToSupport,
                                                                                      String expectedRel)

      Parses all links with 'type' of one of the passed mediaTypes and the 'rel' property with the passed value.
      Parameters:
        `links` - list of all links, never `null`
        `mediaTypesToSupport` - a list of media types the links searched for should support, may be empty but never `null`
        `expectedRel` - the expected value of the property 'rel', never `null`
      Returns:
        a list of links supporting one of the media types and with the expected 'rel' property, may be empty but never `null`

    - #### findUnsupportedTypes

          public static List<String> findUnsupportedTypes(List<Map<String,Object>> links,
                                                          List<String> mediaTypesToSuppport)

      Parsing the media types which does not have a link woth property 'type' for.
      Parameters:
        `links` - list of links to search in, never `null`
        `mediaTypesToSuppport` - a list of media types which should be supported, never `null`
      Returns:
        the media types which does not have a link for.

    - #### findLinksWithoutRelOrType

          public static List<String> findLinksWithoutRelOrType(List<Map<String,Object>> links,
                                                               Set<String> rels)

      Parses the links without 'rel' or 'type' property.
      Parameters:
        `links` - list of links to search in, never `null`
      Returns:
        the links without 'rel' or 'type' property

    - #### findLinkByRel

          public static Map<String,Object> findLinkByRel(List<Map<String,Object>> links,
                                                         String expectedRel)

      Parses the link with 'rel=self'.
      Parameters:
        `links` - list of links to search in, never `null`
        `expectedRel` - the expected value of the property 'rel', never `null`
      Returns:
        the link to itself or `null` if no such link exists

    - #### linkIncludesRelAndType

          public static boolean linkIncludesRelAndType(Map<String,Object> link)

      Checks if the passed link contains 'rel' and 'type' properties.
      Parameters:
        `link` - to check, never `null`
      Returns:
        `true` if the link contains 'rel' and 'type' properties, `false` otherwise

    - #### hasProperty

          public static boolean hasProperty(String propertyName,
                                            io.restassured.path.json.JsonPath jsonPath)

      Checks if a property with the passed name exists in the jsonPath.
      Parameters:
        `propertyName` - name of the property to check, never `null`
        `jsonPath` - to check, never `null`
      Returns:
        `true` if the property exists, `false` otherwise

    - #### collectNumberOfAllReturnedFeatures

          public static int collectNumberOfAllReturnedFeatures(io.restassured.path.json.JsonPath jsonPath,
                                                               int maximumLimit)
                                                        throws URISyntaxException

      Collects the number of all returned features by iterating over all 'next' links and summarizing the size of features in 'features' array property.
      Parameters:
        `jsonPath` - the initial collection, never `null`
        `maximumLimit` - the limit parameter value to use, if <= 0 the parameter is omitted
      Returns:
        the number of all returned features
      Throws:
        `URISyntaxException` - if the creation of a uri fails

Copyright © 2020 Open Geospatial Consortium. All rights reserved.