Class JenaGraph
java.lang.Object
org.nuxeo.ecm.platform.relations.jena.JenaGraph
- All Implemented Interfaces:
Serializable,Graph
Jena plugin for NXRelations.
Graph implementation using the Jena framework.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classClass holding graph and connection so that we can close the connection after having used the graph. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds given list of Statement objects to the graph.voidAdds the statement object to the graph.voidclear()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).booleanhasResource(Resource resource) Returns true if given resource appears in any statement of the graph.booleanhasStatement(Statement statement) Returns true if given statement pattern is in the graph.protected JenaGraph.GraphConnectionGenerates the Jena graph using options.protected JenaGraph.GraphConnectionopenGraph(boolean forceReload) Gets the Jena graph using options.Query the graph using a base URI.intqueryCount(String queryString, String language, String baseURI) Counts the number of results of a query.booleanread(InputStream in, String lang, String base) Parses source into the graph.booleanParses source into the graph.voidRemoves given list of Statement objects from the graph.voidRemoves the statement object from the graph.voidsetDescription(GraphDescription graphDescription) Sets the graph description.voidsetNamespaces(Map<String, String> namespaces) protected voidsetOptions(Map<String, String> options) size()Returns the number of statements in the graph.booleanwrite(OutputStream out, String lang, String base) Serializes graph.booleanSerializes graph.
-
Constructor Details
-
JenaGraph
public JenaGraph()
-
-
Method Details
-
openGraph
Generates the Jena graph using options.- Returns:
- the Jena graph (model)
-
openGraph
Gets the Jena graph using options.The Jena "Convenient" reification style is used when opening models: it allows to ignore reification quadlets when calling the statements list.
- Parameters:
forceReload- boolean stating if the jena graph has to be reloaded using options- Returns:
- the Jena graph (model)
-
setDescription
Description copied from interface:GraphSets the graph description.- Specified by:
setDescriptionin interfaceGraph
-
setOptions
-
setNamespaces
-
getNamespaces
Description copied from interface:GraphReturns namespaces for the graph.Namespaces are prefix/namespace bindings, as rdf for http://www.w3.org/1999/02/22-rdf-syntax-ns#.
- Specified by:
getNamespacesin interfaceGraph- Returns:
- namespaces map of namespace bindings for the graph
-
add
Description copied from interface:GraphAdds the statement object to the graph. -
add
Description copied from interface:GraphAdds given list of Statement objects to the graph. -
remove
Description copied from interface:GraphRemoves the statement object from the graph. -
remove
Description copied from interface:GraphRemoves given list of Statement objects from the graph. -
getStatements
Description copied from interface:GraphReturns all statements in the graph.- Specified by:
getStatementsin interfaceGraph- Returns:
- list of Statement instances
-
getStatements
Description copied from interface:GraphReturns all statements in the graph matching the pattern.- Specified by:
getStatementsin interfaceGraph- Returns:
- list of Statement instances matching the pattern
-
getStatements
Description copied from interface:GraphReturns all statements in the graph matching the pattern.- Specified by:
getStatementsin interfaceGraph- Parameters:
statement- pattern to match, can hold null nodes as wildcards- Returns:
- list of Statement instances matching the pattern
-
getSubjects
Description copied from interface:GraphGet items matching the statement pattern (null, predicate, object).- Specified by:
getSubjectsin interfaceGraph- Parameters:
predicate- predicate pattern, null acceptedobject- object pattern, null accepted- Returns:
- list of subjects
-
getPredicates
Description copied from interface:GraphGets items matching the statement pattern (subject, null, object).- Specified by:
getPredicatesin interfaceGraph- Parameters:
subject- subject pattern, null acceptedobject- object pattern, null accepted- Returns:
- list of predicates
-
getObjects
Description copied from interface:GraphGets items matching the statement pattern (subject, predicate, null).- Specified by:
getObjectsin interfaceGraph- Parameters:
subject- subject pattern, null acceptedpredicate- predicate pattern, null accepted- Returns:
- list of node objects
-
hasStatement
Description copied from interface:GraphReturns true if given statement pattern is in the graph.- Specified by:
hasStatementin interfaceGraph- Parameters:
statement- statement pattern, can use null as wild cards- Returns:
- true or false
-
hasResource
Description copied from interface:GraphReturns true if given resource appears in any statement of the graph.- Specified by:
hasResourcein interfaceGraph- Returns:
- true or false
-
size
Returns the number of statements in the graph.XXX AT: this size may not be equal to the number of statements retrieved via getStatements() because it counts each statement property.
-
clear
public void clear()Description copied from interface:GraphClears the graph, removing all statements in it. -
query
Description copied from interface:GraphQuery the graph using a base URI. -
queryCount
Description copied from interface:GraphCounts the number of results of a query.- Specified by:
queryCountin interfaceGraph- Parameters:
queryString- the query stringlanguage- the query language (sparql, rdql,...)baseURI- the base URI to use for query- Returns:
- the count
-
read
Description copied from interface:GraphParses source into the graph.- Specified by:
readin interfaceGraph- 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
-
read
Description copied from interface:GraphParses source into the graph.- Specified by:
readin interfaceGraph- 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
-
write
Description copied from interface:GraphSerializes graph.- Specified by:
writein interfaceGraph- 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
-
write
Description copied from interface:GraphSerializes graph.- Specified by:
writein interfaceGraph- 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
-