Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.relations.api
Interface Graph

All Superinterfaces:
Serializable
All Known Implementing Classes:
JenaGraph

public interface Graph
extends Serializable

Interface for graphs.

New types of graphs will be registered using extension points.

Graphs have to be serializable has they will be kept as references in the RelationService bean.

Author:
Anahide Tchertchian

Method Summary
 void add(List<Statement> statements)
          Adds given list of Statement objects to the graph.
 void clear()
          Clears the graph, removing all statements in it.
 Map<String,String> getNamespaces()
          Returns namespaces for the graph.
 List<Node> getObjects(Node subject, Node predicate)
          Gets items matching the statement pattern (subject, predicate, null).
 List<Node> getPredicates(Node subject, Node object)
          Gets items matching the statement pattern (subject, null, object).
 List<Statement> getStatements()
          Returns all statements in the graph.
 List<Statement> getStatements(Statement statement)
          Returns all statements in the graph matching the pattern.
 List<Node> getSubjects(Node predicate, Node object)
          Get items matching the statement pattern (null, predicate, object).
 boolean hasResource(Resource resource)
          Returns true if given resource appears in any statement of the graph.
 boolean hasStatement(Statement statement)
          Returns true if given statement pattern is in the graph.
 QueryResult query(String queryString, String language, String baseURI)
          Query the graph using a base URI.
 boolean read(InputStream in, String lang, String base)
          Parses source into the graph.
 boolean read(String path, String lang, String base)
          Parses source into the graph.
 void remove(List<Statement> statements)
          Removes given list of Statement objects from the graph.
 void setName(String name)
          Sets name for the graph.
 void setNamespaces(Map<String,String> namespaces)
          Sets namespaces for the graph.
 void setOptions(Map<String,String> options)
          Sets options for the graph.
 Long size()
          Returns the number of statements in the graph.
 boolean write(OutputStream out, String lang, String base)
          Serializes graph.
 boolean write(String path, String lang, String base)
          Serializes graph.
 

Method Detail

setName

void setName(String name)
Sets name for the graph.

Parameters:
name - the new name

setOptions

void setOptions(Map<String,String> options)
Sets options for the graph.

Options are typically: which backend to use, additional parameters for backend (e.g. for instance SQL backend, host, port, user/password...).

Parameters:
options - map of options for the graph

setNamespaces

void setNamespaces(Map<String,String> namespaces)
Sets namespaces for the graph.

Namespaces are prefix/namespace bindings, as rdf for http://www.w3.org/1999/02/22-rdf-syntax-ns#. TODO AT: maybe share same namespaces with the relation service?

Parameters:
namespaces - map of namespace bindings for the graph

getNamespaces

Map<String,String> getNamespaces()
Returns namespaces for the graph.

Namespaces are prefix/namespace bindings, as rdf for http://www.w3.org/1999/02/22-rdf-syntax-ns#.


add

void add(List<Statement> statements)
Adds given list of Statement objects to the graph.

If the graph has reification support, the statement properties are also added to the graph too.

Parameters:
statements - list of Statement instances to add

remove

void remove(List<Statement> statements)
Removes given list of Statement objects from the graph.

If the graph has reification support, the deleted statements properties are removed too.

Parameters:
statements - List of Statement instances to remove

getStatements

List<Statement> getStatements()
Returns all statements in the graph.

If the graph has reification support, the statements properties are retrieved too.

Returns:
list of Statement instances

getStatements

List<Statement> getStatements(Statement statement)
Returns all statements in the graph matching the pattern.

If the graph has reification support, the statements properties are retrieved too.

Parameters:
statement - pattern to match, can hold null nodes as wildcards
Returns:
list of Statement instances matching the pattern

getSubjects

List<Node> getSubjects(Node predicate,
                       Node object)
Get items matching the statement pattern (null, predicate, object).

Parameters:
predicate - predicate pattern, null accepted
object - object pattern, null accepted
Returns:
list of subjects

getPredicates

List<Node> getPredicates(Node subject,
                         Node object)
Gets items matching the statement pattern (subject, null, object).

Parameters:
subject - subject pattern, null accepted
object - object pattern, null accepted
Returns:
list of predicates

getObjects

List<Node> getObjects(Node subject,
                      Node predicate)
Gets items matching the statement pattern (subject, predicate, null).

Parameters:
subject - subject pattern, null accepted
predicate - predicate pattern, null accepted
Returns:
list of node objects

hasStatement

boolean hasStatement(Statement statement)
Returns true if given statement pattern is in the graph.

Parameters:
statement - statement pattern, can use null as wild cards
Returns:
true or false

hasResource

boolean hasResource(Resource resource)
Returns true if given resource appears in any statement of the graph.

Parameters:
resource -
Returns:
true or false

size

Long size()
Returns the number of statements in the graph.

Returns:
number of statements as a Long

clear

void clear()
Clears the graph, removing all statements in it.


query

QueryResult query(String queryString,
                  String language,
                  String baseURI)
Query the graph using a base URI.

Parameters:
queryString - the query string
language - the query language (sparql, rdql,...)
baseURI - the base URI to use for query
Returns:
QueryResult instance

read

boolean read(String path,
             String lang,
             String base)
Parses source into the graph.

Parameters:
path - path on file system where to take the serialization file
lang - format for the input serialization, may be "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".
base - base uri to be used when converting relative uris to absolute uris, may be null. If set to "", allows relative uris to be used in the model.
Returns:
true on success, else false

read

boolean read(InputStream in,
             String lang,
             String base)
Parses source into the graph.

Parameters:
in - input stream
lang - format for the input serialization, may be "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".
base - base uri to be used when converting relative uris to absolute uris, may be null. If set to "", allows relative uris to be used in the model.
Returns:
true on success, else false

write

boolean write(String path,
              String lang,
              String base)
Serializes graph.

Parameters:
path - path on file system where to put the serialization file
lang - format for the input serialization, may be "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".
base - base uri to be used when converting relative uris to absolute uris, may be null. If set to "", allows relative uris to be used in the model.
Returns:
true on success, else false

write

boolean write(OutputStream out,
              String lang,
              String base)
Serializes graph.

Parameters:
out - output stream
lang - format for the input serialization, may be "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".
base - base uri to be used when converting relative uris to absolute uris, may be null. If set to "", allows relative uris to be used in the model.
Returns:
true on success, else false

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.