Class ServerQuery

java.lang.Object
noaa.coastwatch.net.ServerQuery

public class ServerQuery extends Object

A server query interfaces to a CoastWatch data server and handles the query URL connection and response text. The response is read as a series of results, each with the same number of values. Values may be retrieved by specifying the desired result index and value key or index.

The specifics of the query are handled using a set of key/value pairs specified by a map. Each key and value in the map is expected to be a string. The allowed key/values pairs are as follows:

  • query = datasetDetails | serverStatus
  • details = comma-separated list of desired dataset attributes
  • projection_type = swath | mapped
  • satellite = regular expression match string
  • sensor = regular expression match string
  • scene_time = regular expression match string
  • file_name = regular expression match string
  • region_id = regular expression match string
  • station_id = regular expression match string
  • before = yyyy-mm-dd hh:mm:ss time stamp
  • after = yyyy-mm-dd hh:mm:ss time stamp
  • order = comma-separated list of desired ordering attributes
  • coverage = minimum coverage as a percentage

where valid dataset attributes include the following:

  • satellite
  • sensor
  • date
  • time
  • scene_time
  • file_name
  • format
  • data_url
  • preview_url
Since:
3.1.0
Author:
Peter Hollemans
  • Constructor Details

    • ServerQuery

      public ServerQuery(String host, String path, Map query) throws IOException
      Creates a new server query using the server protocol, host, query path, and query key/value set.
      Parameters:
      host - the server host name to use for the query. The host name must be a valid Internet domain name.
      path - the absolute path to the query program.
      query - a map containing the query key/value pairs.
      Throws:
      IOException - if the host, path, or query were not valid or the server responded with an error.
    • ServerQuery

      public ServerQuery(String protocol, String host, String path, Map query) throws IOException
      Creates a new server query using the server host, query path, and query key/value set.
      Parameters:
      protocol - the connection protocol, either 'http' or 'https'.
      host - the server host name to use for the query. The host name must be a valid Internet domain name.
      path - the absolute path to the query program.
      query - a map containing the query key/value pairs.
      Throws:
      IOException - if the host, path, or query were not valid or the server responded with an error.
      Since:
      3.4.1
  • Method Details

    • getValues

      public int getValues()
      Gets the number of values in each result.
    • getValueKey

      public String getValueKey(int value)
      Gets the value key at the specified value index.
      Parameters:
      value - the value index.
      Returns:
      the value key.
    • getResults

      public int getResults()
      Gets the number of query results.
    • getValue

      public String getValue(int result, int value)
      Gets a result value.
      Parameters:
      result - the result index.
      value - the value index.
      Returns:
      the value string.
    • getValueIndex

      public int getValueIndex(String valueKey)
      Gets the value index using the specified value key.
      Parameters:
      valueKey - the value key to find.
      Returns:
      the value index, or -1 if the value key is not found.
    • getValue

      public String getValue(int result, String valueKey)
      Gets a result value.
      Parameters:
      result - the result index.
      valueKey - the value key.
      Returns:
      the value string.
    • getHost

      public String getHost()
      Gets the host name used for the query.
    • getURL

      public String getURL()
      Gets the query URL as a string.