|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mulgara.mrg.AbstractGraphExt
org.mulgara.mrg.AbstractGraph
public abstract class AbstractGraph
An RDF graph. This uses a single index by default, and the indexes are built out of maps and collections
that are returned by the abstract methods createMap and createCollection respectively.
To implement this graph, simply define these methods to return appropriate Map and Collection
implementations. Extra indexes may also be added, which will allow getObjects and getPredicates
to be more efficiently implemented. An example of this is shown in IndexedGraph.
TODO: test objects on insertion to avoid storing duplicate nodes
| Field Summary |
|---|
| Fields inherited from interface org.mulgara.mrg.Graph |
|---|
X |
| Constructor Summary | |
|---|---|
AbstractGraph()
Default constructor for an empty graph. |
|
AbstractGraph(Collection<Triple> triples)
Builds a graph with a collection of triples. |
|
| Method Summary | ||
|---|---|---|
protected abstract
|
createCollection()
Defines the collection type to use in this implementation. |
|
protected abstract
|
createMap()
Defines the map type to use in this implementation. |
|
boolean |
delete(SubjectNode s,
PredicateNode p,
ObjectNode o)
Remove a triple from the graph. |
|
boolean |
delete(Triple triple)
Remove a triple from the graph. |
|
boolean |
doesResourceExist(Node r)
Tests if a resource exists anywhere in the graph. |
|
void |
exportN3(OutputStream out)
Writes the contents of the graph to an output stream as N3. |
|
void |
exportN3(OutputStream out,
URI base)
Writes the contents of the graph to an output stream as N3. |
|
void |
exportXML(OutputStream out)
Writes the contents of the graph to an output stream as RDF/XML. |
|
void |
exportXML(OutputStream out,
URI base)
Writes the contents of the graph to an output stream as RDF/XML. |
|
Collection<ObjectNode> |
getObjects()
Gets all the objects in the graph. |
|
Collection<PredicateNode> |
getPredicates()
Gets all the predicates in the graph. |
|
List<PropertyValue> |
getProperties(SubjectNode s)
Gets all the properties for a given subject. |
|
List<Pair<PredicateNode,ObjectNode>> |
getRawProperties(SubjectNode s)
Gets all the properties for a given subject as raw pairs. |
|
List<ObjectNode> |
getRdfList(SubjectNode s,
PredicateNode p)
Gets an rdf:List property from an object. |
|
Collection<SubjectNode> |
getSubjects()
Gets all the subjects in the graph. |
|
List<SubjectNode> |
getSubjects(PredicateNode property,
ObjectNode value)
Gets all the subjects that share a given property/value. |
|
List<Triple> |
getTriples()
Gets the entire graph as a list of triples. |
|
ObjectNode |
getValue(SubjectNode s,
PredicateNode p)
Gets a single value for a given property on a subject. |
|
List<ObjectNode> |
getValues(SubjectNode s,
PredicateNode p)
Gets all the values for a given property on a subject. |
|
boolean |
insert(SubjectNode s,
PredicateNode p,
ObjectNode o)
Add a new triple to the graph. |
|
boolean |
insert(Triple triple)
Add a new triple to the graph. |
|
boolean |
isAsserted(SubjectNode s,
PredicateNode p,
ObjectNode o)
Tests if a triple has been asserted. |
|
boolean |
isAsserted(Triple t)
Tests if a triple has been asserted. |
|
boolean |
isEmpty()
Tests if the graph has any entries. |
|
Iterator<Triple> |
match(SubjectNode s,
PredicateNode p,
ObjectNode o)
Find all triples that match a given pattern. |
|
Graph |
matchSubgraph(SubjectNode s,
PredicateNode p,
ObjectNode o)
Returns a subgraph of this graph that only contains the triples that match a given pattern. |
|
Graph |
mergeInto(Graph g)
Adds the contents of another graph to this one, creating new blank nodes as required (not re-using the blank nodes from the original graph). |
|
long |
size()
Gets the number of triples in this graph. |
|
Graph |
unionInto(Graph g)
Adds the contents of another graph to this one, re-using all the blank nodes from the new graph. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractGraph()
public AbstractGraph(Collection<Triple> triples)
triples - The initial triples for the graph.| Method Detail |
|---|
public boolean insert(SubjectNode s,
PredicateNode p,
ObjectNode o)
insert in interface AppendableGraphs - The subject of the triple.p - The predicate of the triple.o - The object of the triple.
true if the triple was already in the graph.public boolean insert(Triple triple)
insert in interface AppendableGraphtriple - The complete triple to add.
true if the triple was already in the graph.public Graph mergeInto(Graph g)
mergeInto in interface AppendableGraphg - The graph to merge into this one.
public Graph unionInto(Graph g)
unionInto in interface AppendableGraphg - The graph to merge into this one.
public boolean delete(SubjectNode s,
PredicateNode p,
ObjectNode o)
delete in interface WritableGraphs - The subject of the triple.p - The predicate of the triple.o - The object of the triple.
true if the triple was already in the graph.public boolean delete(Triple triple)
delete in interface WritableGraphtriple - The complete triple to remove.
true if the triple was already in the graph.public List<PropertyValue> getProperties(SubjectNode s)
getProperties in interface Graphs - The subject.
public boolean isAsserted(Triple t)
isAsserted in interface Grapht - The triple to test for.
true only if the triple exists in the graph.
public boolean isAsserted(SubjectNode s,
PredicateNode p,
ObjectNode o)
isAsserted in interface Graphs - The subject of the triple to search for.p - The predicate of the triple to search for.o - The object of the triple to search for.
true only if the triple exists in the graph.public List<Pair<PredicateNode,ObjectNode>> getRawProperties(SubjectNode s)
s - The subject.
public List<ObjectNode> getValues(SubjectNode s,
PredicateNode p)
getValues in interface Graphs - The subject to get the properties for.p - The property of interest.
public ObjectNode getValue(SubjectNode s,
PredicateNode p)
getValue in interface Graphs - The subject to get the properties for.p - The property of interest.
public List<ObjectNode> getRdfList(SubjectNode s,
PredicateNode p)
getRdfList in interface Graphs - The subject to get the property for.p - The property of interest.
public List<SubjectNode> getSubjects(PredicateNode property,
ObjectNode value)
getSubjects in interface Graphproperty - The property being looked for.value - The value being looked for.
public boolean doesResourceExist(Node r)
doesResourceExist in interface Graphr - The resource to test.
true only if the resource is used somewhere in the graph.public Collection<SubjectNode> getSubjects()
getSubjects in interface Graphpublic Collection<PredicateNode> getPredicates()
getPredicates in interface Graphpublic Collection<ObjectNode> getObjects()
getObjects in interface Graph
public void exportN3(OutputStream out)
throws IOException
exportN3 in interface Graphout - The stream to write to.
IOException
public void exportN3(OutputStream out,
URI base)
throws IOException
exportN3 in interface Graphout - The stream to write to.base - The base to write to.
IOException
public void exportXML(OutputStream out)
throws IOException
exportXML in interface Graphout - The stream to write to.
IOException
public void exportXML(OutputStream out,
URI base)
throws IOException
exportXML in interface Graphout - The stream to write to.base - The base to write to.
IOExceptionpublic List<Triple> getTriples()
getTriples in interface Graph
public Iterator<Triple> match(SubjectNode s,
PredicateNode p,
ObjectNode o)
ConcurrentModificationException if the graph is modified.
If this is a possibility, then use matchSubgraph(SubjectNode, PredicateNode, ObjectNode) instead.
match in interface Graphs - The subject of the triples to match. If null that all subjects match.p - The predicate of the triple to add. If null that all predicates match.o - The object of the triple to add. If null that all objects match.
public Graph matchSubgraph(SubjectNode s,
PredicateNode p,
ObjectNode o)
match(SubjectNode, PredicateNode, ObjectNode) instead.
matchSubgraph in interface Graphs - The subject of the triples to match. If null that all subjects match.p - The predicate of the triple to add. If null that all predicates match.o - The object of the triple to add. If null that all objects match.
public long size()
size in interface Graphpublic boolean isEmpty()
isEmpty in interface Graphtrue if there are no entries.protected abstract <X,Y> Map<X,Y> createMap()
protected abstract <X> Collection<X> createCollection()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||