org.gcube.data.tml.uri
Class URIs

java.lang.Object
  extended by org.gcube.data.tml.uri.URIs

public class URIs
extends Object

Utility methods for data URI creation and manipulation.

Author:
Fabio Simeoni

Field Summary
static String PROTOCOL
          Scheme of cms URIs.
 
Constructor Summary
URIs()
           
 
Method Summary
static URLConnection connection(URI uri, String scope)
          Deprecated. since 2.3.1. Use URLConnection normally in current scope.
static URI make(String sourceId, String... identifiers)
          Constructs a data URI from a source identifier and one or more node identifiers.
static String nodeID(URI uri)
          Returns the identifier of the node identified by a data URI.
static String[] nodeIDs(URI uri)
          Returns the identifiers in a data URI.
static URI parentURI(URI uri)
          Returns a data URI for the parent of the node identified by another data URI.
static org.gcube.data.trees.patterns.Pattern pattern(URI uri)
          Returns a Pattern for the existence of the path of identifiers in a data URI.
static String rootId(URI uri)
          Returns the root identifier in a data URI.
static String sourceId(URI uri)
          Returns the source identifier in a data URI.
static gr.uoa.di.madgik.grs.record.GenericRecord toRSElement(URI uri)
          Returns the serialisation of a data URI as an element of ResultSet, as expected by the service.
static URI treeURI(URI uri)
          Returns a data URI for the tree of the node identified by another data URI.
static URI uri(org.gcube.data.trees.data.Node node)
          Returns the data URI of a Node.
static void validate(URI uri)
          Indicates whether a URI is a valid data URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL

public static final String PROTOCOL
Scheme of cms URIs.

See Also:
Constant Field Values
Constructor Detail

URIs

public URIs()
Method Detail

validate

public static void validate(URI uri)
                     throws URISyntaxException
Indicates whether a URI is a valid data URI.

Parameters:
uri - the URI.
Throws:
URISyntaxException - if the URI fails validation.

make

public static URI make(String sourceId,
                       String... identifiers)
                throws IllegalArgumentException
Constructs a data URI from a source identifier and one or more node identifiers.

Parameters:
sourceId - the source identifier.
identifiers - the node identifiers.
Returns:
the URI.
Throws:
IllegalArgumentException - if the input is null or empty.

sourceId

public static String sourceId(URI uri)
                       throws URISyntaxException
Returns the source identifier in a data URI.

Parameters:
uri - the URI.
Returns:
the identifier.
Throws:
URISyntaxException - if the URI is not a data URI.

rootId

public static String rootId(URI uri)
                     throws URISyntaxException
Returns the root identifier in a data URI.

Parameters:
uri - the URI.
Returns:
the identifier.
Throws:
URISyntaxException - if the URI is not a data URI.

nodeID

public static String nodeID(URI uri)
                     throws URISyntaxException
Returns the identifier of the node identified by a data URI.

Parameters:
uri - the URI.
Returns:
the identifier.
Throws:
URISyntaxException - if the URI is not a data URI.

nodeIDs

public static String[] nodeIDs(URI uri)
                        throws URISyntaxException
Returns the identifiers in a data URI.

Parameters:
uri - the URI.
Returns:
the identifiers.
Throws:
URISyntaxException - if the URI is not a data URI.

parentURI

public static URI parentURI(URI uri)
                     throws URISyntaxException
Returns a data URI for the parent of the node identified by another data URI.

Parameters:
uri - the input URI.
Returns:
the parent URI.
Throws:
URISyntaxException - if the input URI is not a content URL.

treeURI

public static URI treeURI(URI uri)
                   throws URISyntaxException
Returns a data URI for the tree of the node identified by another data URI.

Parameters:
uri - the input URI.
Returns:
the tree URI.
Throws:
URISyntaxException - if the input URI is not a data URI.

pattern

public static final org.gcube.data.trees.patterns.Pattern pattern(URI uri)
                                                           throws URISyntaxException
Returns a Pattern for the existence of the path of identifiers in a data URI.

Parameters:
uri - the URI.
Returns:
the predicate.
Throws:
URISyntaxException - if the URI is not a data URI.

toRSElement

public static final gr.uoa.di.madgik.grs.record.GenericRecord toRSElement(URI uri)
                                                                   throws URISyntaxException,
                                                                          Exception
Returns the serialisation of a data URI as an element of ResultSet, as expected by the service.

Parameters:
uri - the URI.
Returns:
the element.
Throws:
URISyntaxException - if the URI is not a data URI.
Exception - if the URI could not be serialised as an element.

connection

public static URLConnection connection(URI uri,
                                       String scope)
                                throws IOException,
                                       URISyntaxException
Deprecated. since 2.3.1. Use URLConnection normally in current scope.

Returns a URL connection in a given scope.

Parameters:
uri - a data URI.
scope - the scope.
Returns:
the connection.
Throws:
IOException - if the connections could not be established.
URISyntaxException - if the URI is not a data URI or if the protocol handler for the cms scheme is not active.

uri

public static URI uri(org.gcube.data.trees.data.Node node)
               throws IllegalStateException
Returns the data URI of a Node.

tm://id0/id1/.../idN

where

Parameters:
node - the node
Returns:
the URI
Throws:
IllegalStateException - if the node or one of its ancestors does not have an identifier, or if the root of the tree does not specify a source identifier


Copyright © 2012. All Rights Reserved.