Interface Graph
- All Superinterfaces:
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
Modifier and TypeMethodDescriptionvoid
Adds given list of Statement objects to the graph.void
Adds the statement object to the graph.void
clear()
Clears the graph, removing all statements in it.Returns namespaces for the graph.getObjects
(Node subject, Node predicate) Gets items matching the statement pattern (subject, predicate, null).getPredicates
(Node subject, Node object) Gets items matching the statement pattern (subject, null, object).Returns all statements in the graph.getStatements
(Node subject, Node predicate, Node object) Returns all statements in the graph matching the pattern.getStatements
(Statement statement) Returns all statements in the graph matching the pattern.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.Query the graph using a base URI.int
queryCount
(String queryString, String language, String baseURI) Counts the number of results of a query.boolean
read
(InputStream in, String lang, String base) Parses source into the graph.boolean
Parses source into the graph.void
Removes given list of Statement objects from the graph.void
Removes the statement object from the graph.void
setDescription
(GraphDescription graphDescription) Sets the graph description.size()
Returns the number of statements in the graph.boolean
write
(OutputStream out, String lang, String base) Serializes graph.boolean
Serializes graph.
-
Method Details
-
setDescription
Sets the graph description. -
getNamespaces
Returns namespaces for the graph.Namespaces are prefix/namespace bindings, as rdf for http://www.w3.org/1999/02/22-rdf-syntax-ns#.
- Returns:
- namespaces map of namespace bindings for the graph
-
add
Adds the statement object to the graph.- Parameters:
statement
- statement to add- Since:
- 5.5
-
add
Adds given list of Statement objects to the graph.- Parameters:
statements
- list of Statement instances to add
-
remove
Removes the statement object from the graph.- Parameters:
statement
- statement to remove- Since:
- 5.5
-
remove
Removes given list of Statement objects from the graph.- Parameters:
statements
- List of Statement instances to remove
-
getStatements
Returns all statements in the graph.- Returns:
- list of Statement instances
-
getStatements
Returns all statements in the graph matching the pattern.- Parameters:
statement
- pattern to match, can hold null nodes as wildcards- Returns:
- list of Statement instances matching the pattern
-
getStatements
Returns all statements in the graph matching the pattern.- Returns:
- list of Statement instances matching the pattern
- Since:
- 5.5
-
getSubjects
Get items matching the statement pattern (null, predicate, object).- Parameters:
predicate
- predicate pattern, null acceptedobject
- object pattern, null accepted- Returns:
- list of subjects
-
getPredicates
Gets items matching the statement pattern (subject, null, object).- Parameters:
subject
- subject pattern, null acceptedobject
- object pattern, null accepted- Returns:
- list of predicates
-
getObjects
Gets items matching the statement pattern (subject, predicate, null).- Parameters:
subject
- subject pattern, null acceptedpredicate
- predicate pattern, null accepted- Returns:
- list of node objects
-
hasStatement
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
Returns true if given resource appears in any statement of the graph.- 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
Query the graph using a base URI.- Parameters:
queryString
- the query stringlanguage
- the query language (sparql, rdql,...)baseURI
- the base URI to use for query- Returns:
- QueryResult instance
-
queryCount
Counts the number of results of a query.- Parameters:
queryString
- the query stringlanguage
- the query language (sparql, rdql,...)baseURI
- the base URI to use for query- Returns:
- the count
-
read
Parses source into the graph.- Parameters:
path
- path on file system where to take the serialization filelang
- 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
Parses source into the graph.- Parameters:
in
- input streamlang
- 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
Serializes graph.- Parameters:
path
- path on file system where to put the serialization filelang
- 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
Serializes graph.- Parameters:
out
- output streamlang
- 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
-