org.mulgara.mrg
Interface Graph

All Superinterfaces:
GraphExt
All Known Subinterfaces:
AppendableGraph, WritableGraph
All Known Implementing Classes:
AbstractGraph, AbstractGraphExt, GraphImpl, IndexedGraph, PackedGraphImpl, PackedIndexedGraph

public interface Graph
extends GraphExt

An RDF graph.


Field Summary
static Uri X
          A wildcard for use when matching triples.
 
Method Summary
 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<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 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.
 long size()
          Gets the number of triples in this graph.
 
Methods inherited from interface org.mulgara.mrg.GraphExt
doesResourceExist, doesResourceExist, getProperties, getProperties, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, getValues, getValues, getValues, getValues, getValues, getValues, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX
 

Field Detail

X

static final Uri X
A wildcard for use when matching triples.

Method Detail

isAsserted

boolean isAsserted(Triple t)
Tests if a triple has been asserted. Be careful of blank nodes, as they will only match if they are exactly alike.

Parameters:
t - The triple to test for.
Returns:
true only if the triple exists in the graph.

isAsserted

boolean isAsserted(SubjectNode s,
                   PredicateNode p,
                   ObjectNode o)
Tests if a triple has been asserted. Be careful of blank nodes, as they will only match if they are exactly alike.

Parameters:
s - 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.
Returns:
true only if the triple exists in the graph.

doesResourceExist

boolean doesResourceExist(Node r)
Tests if a resource exists anywhere in the graph.

Parameters:
r - The resource to test.
Returns:
true only if the resource is used somewhere in the graph.

getProperties

List<PropertyValue> getProperties(SubjectNode s)
Gets all the properties for a given subject.

Parameters:
s - The subject.
Returns:
A list of property/value pairs.

getValues

List<ObjectNode> getValues(SubjectNode s,
                           PredicateNode p)
Gets all the values for a given property on a subject.

Parameters:
s - The subject to get the properties for.
p - The property of interest.
Returns:
The list of values for the property on that subject.

getValue

ObjectNode getValue(SubjectNode s,
                    PredicateNode p)
Gets a single value for a given property on a subject.

Parameters:
s - The subject to get the properties for.
p - The property of interest.
Returns:
The first values for the property on that subject.

getRdfList

List<ObjectNode> getRdfList(SubjectNode s,
                            PredicateNode p)
Gets an rdf:List property from an object. If more than one value exists for this property, then returns the first and assumes it's a list.

Parameters:
s - The subject to get the property for.
p - The property of interest.
Returns:
The list associates with the property on that subject.

getSubjects

List<SubjectNode> getSubjects(PredicateNode property,
                              ObjectNode value)
Gets all the subjects that share a given property/value.

Parameters:
property - The property being looked for.
value - The value being looked for.
Returns:
The subjects that have the value for the property.

getSubjects

Collection<SubjectNode> getSubjects()
Gets all the subjects in the graph.

Returns:
All the subjects in the graph.

getPredicates

Collection<PredicateNode> getPredicates()
Gets all the predicates in the graph.

Returns:
All the predicatess in the graph.

getObjects

Collection<ObjectNode> getObjects()
Gets all the objects in the graph.

Returns:
All the objects in the graph.

getTriples

List<Triple> getTriples()
Gets the entire graph as a list of triples.

Returns:
All the triples in the graph.

exportN3

void exportN3(OutputStream out)
              throws IOException
Writes the contents of the graph to an output stream as N3.

Parameters:
out - The stream to write to.
Throws:
IOException

exportN3

void exportN3(OutputStream out,
              URI base)
              throws IOException
Writes the contents of the graph to an output stream as N3.

Parameters:
out - The stream to write to.
base - The base to write to.
Throws:
IOException

exportXML

void exportXML(OutputStream out)
               throws IOException
Writes the contents of the graph to an output stream as RDF/XML.

Parameters:
out - The stream to write to.
Throws:
IOException

exportXML

void exportXML(OutputStream out,
               URI base)
               throws IOException
Writes the contents of the graph to an output stream as RDF/XML.

Parameters:
out - The stream to write to.
base - The base to write to.
Throws:
IOException

size

long size()
Gets the number of triples in this graph.

Returns:
the number of triples in the graph.

isEmpty

boolean isEmpty()
Tests if the graph has any entries.

Returns:
true if there are no entries.

match

Iterator<Triple> match(SubjectNode s,
                       PredicateNode p,
                       ObjectNode o)
Find all triples that match a given pattern. The resulting iterator may be live, and can lead to a ConcurrentModificationException if the graph is modified. If this is a possibility, then use matchSubgraph(SubjectNode, PredicateNode, ObjectNode) instead.

Parameters:
s - The subject of the triples to match. If null or X then all subjects match.
p - The predicate of the triple to add. If null or X then all predicates match.
o - The object of the triple to add. If null or X then all objects match.
Returns:
An Iterator on the matching triples.

matchSubgraph

Graph matchSubgraph(SubjectNode s,
                    PredicateNode p,
                    ObjectNode o)
Returns a subgraph of this graph that only contains the triples that match a given pattern. This method copies all of the required triples. To avoid the overhead of this operation, use match(SubjectNode, PredicateNode, ObjectNode) instead.

Parameters:
s - The subject of the triples to match. If null or X then all subjects match.
p - The predicate of the triple to add. If null or X then all predicates match.
o - The object of the triple to add. If null or X then all objects match.
Returns:
A Graph containing only the matching triples.


Copyright © 2011. All Rights Reserved.