org.grinvin
Class GraphURI
public final class GraphURI
extends java.lang.Object
Utility class provides a method
load(URI,GraphBundle)
to load a graph that corresponds
to an URI.
Currently the following URIs are supported:
- Any absolute URI which can be converted to an URL with a supported protocol handler.
I.e., URIs with schemes like file:, http:, jar:.
The resources are supposed to refer to streams in .gph-format.
See package org.grinvin.io
for more information on this format.
- An absolute URI with scheme graph: which represents a graph that
can be created by a
GraphFactory
. - An absolute URI with scheme classpath: which represents a graph
resource on the class path.
- A relative URI with scheme session: which represents a graph
in the current workspace directory.
- A null URI is equivalent to an URI with scheme session:. A graph
with a null URI will be assigned a session URI when needed.
An
graph: URI has the following form:
graph:graph_factory-id[?name-value-pairs]
The
graph factory id identifies an object of type
GraphFactory
.
If present, the
name/value pairs indicate
additional parameters for that factory. They are formatted in a style similar
to that of HTTP query strings:
name1=value1&name2=value2&...&name3=value3
E.g., the following represents the complete graph of order 4
graph:org.grinvin.factories.CompleteGraphFactory?order=4
createFactory
public static URI createFactory(String ssp)
throws URISyntaxException
createSession
public static URI createSession(String ssp)
throws URISyntaxException
getType
public static GraphURIType getType(URI uri)
Return the type corresponding to the given URI.
isClasspath
public static boolean isClasspath(URI uri)
isFactoryGenerated
public static boolean isFactoryGenerated(URI uri)
isFile
public static boolean isFile(URI uri)
isGlobal
public static boolean isGlobal(URI uri)
isLocal
public static boolean isLocal(URI uri)
isSession
public static boolean isSession(URI uri)
Is this a null URI or an URI with a 'session' scheme. URIs of this
type correspond to graphs that reside in memory only (and can be
persisted to a workspace).
load
public static void load(URI uri,
GraphBundle graphBundle)
throws GraphURIException
Load the graph that corresponds to the given URI into the given graph bundle.
uri
- URI that represents the graphgraphBundle
- Graph bundle which will hold the result. Preferably empty.
translateSessionURI
public static URI translateSessionURI(URI uri,
File directory)
Translate a relative session URI to an absolute file URI with
the given base directory. Other URIs are left intact