org.autoplot.hapi.HapiServer

Utility methods for interacting with HAPI servers.

HapiServer( )


UTF8

all transactions must be done in UTF-8


createURL

createURL( java.net.URL server, String append ) → java.net.URL

return the URL by appending the text to the end of the server URL. This avoids extra slashes, etc.

Parameters

server - an URL
append - a String

Returns:

a java.net.URL

[search for examples] [view on GitHub] [view on old javadoc]

createURL( java.net.URL server, String append, java.util.Map singletonMap ) → java.net.URL

decodeURL

decodeURL( java.net.URL s ) → String

decode the URL into a string useful in Autoplot URIs.

Parameters

s - an URL

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc]


decodeURLParameters

decodeURLParameters( String s ) → String

replace %2B with pluses and pluses with spaces.

Parameters

s - a String

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc]


encodeURL

encodeURL( String s ) → java.net.URL

encode the string into a URL, handling encoded characters. Note this does nothing right now, but should still be used as the one place to handle URLs.

Parameters

s - a String

Returns:

a java.net.URL

[search for examples] [view on GitHub] [view on old javadoc]


encodeURLParameters

encodeURLParameters( String s ) → String

replace pluses with %2B and spaces with pluses.

Parameters

s - a String

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc]


getCatalog

getCatalog( java.net.URL server ) → JSONArray

return the list of datasets available at the server. This should not be called from the event thread.

Parameters

server - the root of the server, which should should contain "catalog"

Returns:

list of catalog entries, which have "id" and "title" tags.

[search for examples] [view on GitHub] [view on old javadoc]


getCatalogIds

getCatalogIds( java.net.URL server ) → java.util.List

return the list of datasets available at the server. This should not be called from the event thread.

Parameters

server - the root of the server, which should should contain "catalog"

Returns:

list of dataset ids

[search for examples] [view on GitHub] [view on old javadoc]


getDataURL

getDataURL( java.net.URL server, String id, DatumRange tr, String parameters ) → java.net.URL

return the URL for data requests.

Parameters

server - an URL
id - string like "data4" or "spase://..."
tr - the time range
parameters - zero-length, or a comma-delineated list of parameters.

Returns:

the request, with the ID and parameters URL encoded.

[search for examples] [view on GitHub] [view on old javadoc]


getHapiServerVersion

getHapiServerVersion( java.net.URL server ) → String

Parameters

server - an URL

Returns:

java.lang.String

[search for examples] [view on GitHub] [view on old javadoc]


getInfo

getInfo( java.net.URL server, String id ) → JSONObject

return the info as a JSONObject. This should not be called from the event thread.

Parameters

server - HAPI server.
id - the parameter id.

Returns:

JSONObject containing information.

[search for examples] [view on GitHub] [view on old javadoc]


getInfoURL

getInfoURL( java.net.URL server, String id ) → java.net.URL

return the URL for getting info.

Parameters

server - an URL
id - a String

Returns:

a java.net.URL

[search for examples] [view on GitHub] [view on old javadoc]


getKnownServers

getKnownServers( ) → java.util.List

get known servers.

Returns:

known servers

[search for examples] [view on GitHub] [view on old javadoc]


getKnownServersArray

getKnownServersArray( ) → String[]

get known servers

Returns:

known servers

[search for examples] [view on GitHub] [view on old javadoc]


getParameters

getParameters( java.net.URL server, String id ) → JSONArray

Parameters

server - an URL
id - a String

Returns:

JSONArray

[search for examples] [view on GitHub] [view on old javadoc]


getRange

getRange( JSONObject info ) → DatumRange

return the range of available data. For example, Polar/Hydra data is available from 1996-03-20 to 2008-04-15. Note this supports old schemas.

Parameters

info - a JSONObject

Returns:

the range of available data.

[search for examples] [view on GitHub] [view on old javadoc]


getSampleTimeRange

getSampleTimeRange( JSONObject info ) → DatumRange

return a time which is a suitable time to discover the data.

Parameters

info - a JSONObject

Returns:

a DatumRange

[search for examples] [view on GitHub] [view on old javadoc]


listHapiServers

listHapiServers( ) → java.util.List

add the default known servers, plus the ones we know about. The zeroth server will be the last server used. This should not be called from the event thread.

Returns:

list of server URLs.

[search for examples] [view on GitHub] [view on old javadoc]


listHapiServersArray

listHapiServersArray( ) → String[]

add the default known servers, plus the ones we know about.

Returns:

list of servers

[search for examples] [view on GitHub] [view on old javadoc]


readFromFile

readFromFile( java.io.File f ) → String

read the file into a string.

Parameters

f - non-empty file

Returns:

String containing file contents.

[search for examples] [view on GitHub] [view on old javadoc]


readFromURL

readFromURL( java.net.URL url, String type ) → String

read data from the URL.

Parameters

url - the URL to read from
type - the extension to use for the cache file (JSON).

Returns:

non-empty string

[search for examples] [view on GitHub] [view on old javadoc]


urlEncode

urlEncode( String id ) → String

make sure spaces are encoded.

Parameters

id - a String

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc]