org.openanzo.model.impl
Class ContainerDataset

java.lang.Object
  extended by org.openanzo.model.impl.ADataset
      extended by org.openanzo.model.impl.Dataset
          extended by org.openanzo.model.impl.ContainerDataset
All Implemented Interfaces:
IContainer, IDataset

public class ContainerDataset
extends Dataset

ContainerDataset is a Dataset that gets stores its data in an IContainer. ContainerDataset is dynamic in nature in terms to graph creation, which means if a graph is asked for with a getNamedGraph or getDefaultNamedGraph method call, and the graph isn't currently in the dataset, the graph is created and added.

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
ContainerDataset(IContainer container)
          Create a new ContainerDataset with the given container as the data source
 
Method Summary
 void add(java.util.Iterator<org.openrdf.model.Statement> statements)
          Add statements to their given NamedGraph.
 void add(org.openrdf.model.Resource subj, org.openrdf.model.URI pred, org.openrdf.model.Value obj, org.openrdf.model.Resource namedGraphUri)
          Add a statement to the given NamedGraph if said NamedGraph is contained within this dataset.
 void add(org.openrdf.model.Statement... statements)
          Add statements to the given NamedGraph if said NamedGraph is contained within this dataset.
 void clear()
          Delete all statements in container
 void clear(org.openrdf.model.Resource... context)
          Delete all statements in container for given contexts
 boolean contains(org.openrdf.model.Resource subj, org.openrdf.model.URI prop, org.openrdf.model.Value obj, org.openrdf.model.Resource... namedGraphUris)
          Return true if the container contains atleast 1 statement that matches the pattern of subj,prop,obj,context
 boolean contains(org.openrdf.model.Statement statement)
          Return true if the container contains atleast 1 statement that matches the statement provided
 void delete(java.util.Iterator<org.openrdf.model.Statement> statements)
          Delete statements from their given NamedGraph.
 void delete(org.openrdf.model.Resource subj, org.openrdf.model.URI pred, org.openrdf.model.Value obj, org.openrdf.model.Resource namedGraphUri)
          Delete statements from the given NamedGraph if said NamedGraph is contained within this dataset.
 void delete(org.openrdf.model.Statement... statements)
          Delete statements from the given NamedGraph if said NamedGraph is contained within this dataset.
 QueryResult executeQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphsIn, java.util.Set<org.openrdf.model.URI> namedGraphsIn, java.lang.String query)
          Execute a SPARQL query against the data within this container
 QueryResult executeQuery(java.lang.String query)
          Execute a SPARQL query against the data within this dataset, using the dataset's DefaultGraph and NameGraph sets
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> find(org.openrdf.model.Resource subj, org.openrdf.model.URI prop, org.openrdf.model.Value obj, org.openrdf.model.Resource... namedGraphUris)
          Return an iterator over all statements that match the pattern of subj,prop,obj
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findAll(org.openrdf.model.Resource subj, org.openrdf.model.URI prop, org.openrdf.model.Value obj, org.openrdf.model.Resource... namedGraphUris)
          Return an iterator of all statements that match the pattern of subj,prop,obj Difference between find, and findall, is that with findAll, if contexts are provided, they are used to sort results, but not limit results, ie the results contains all statements that match the subj,prop,obj, with matching statements within the given contexts earlier in the iterator than statements not in the provided contexts.
 INamedGraph getDefaultNamedGraph(org.openrdf.model.URI uri)
          Get the INamedGraph for the given URI if it is within this dataset's default model
 INamedGraphEventManager getEventManager()
          Return INamedGraphEventManager for this container
 INamedGraph getNamedGraph(org.openrdf.model.URI uri)
          Remove named graph from set of graphs
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> getStatements()
          Get an iterator over all statements within this container
 int size()
          Return number of statements in container
 int size(org.openrdf.model.Resource... context)
          Return number of statements in container
 
Methods inherited from class org.openanzo.model.impl.Dataset
addDefaultGraphUri, addDefaultNamedGraph, addNamedGraph, addNamedGraphUri, close, containsDefaultNamedGraph, containsNamedGraph, getDefaulNamedGraphsSize, getDefaultNamedGraphs, getNamedGraphs, getNamedGraphsSize, getTransactionManager, removeDefaultGraphUri, removeDefaultNamedGraph, removeNamedGraph, removeNamedGraphUri, setDefaultGraphs, setEventManager, setNamedGraphs, setTransactionManager
 
Methods inherited from class org.openanzo.model.impl.ADataset
connect, getContexts, getURI, isClosed, isConnected, isEmpty, isEmpty, setDatasetURI
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerDataset

public ContainerDataset(IContainer container)
Create a new ContainerDataset with the given container as the data source

Parameters:
container - containing data
Method Detail

getDefaultNamedGraph

public INamedGraph getDefaultNamedGraph(org.openrdf.model.URI uri)
Description copied from interface: IDataset
Get the INamedGraph for the given URI if it is within this dataset's default model

Specified by:
getDefaultNamedGraph in interface IDataset
Overrides:
getDefaultNamedGraph in class Dataset
Parameters:
uri - URI of INamedGraph
Returns:
the INamedGraph for the given URI if it is within this dataset's default model

getNamedGraph

public INamedGraph getNamedGraph(org.openrdf.model.URI uri)
Description copied from class: Dataset
Remove named graph from set of graphs

Specified by:
getNamedGraph in interface IDataset
Overrides:
getNamedGraph in class Dataset
Parameters:
uri - of graph to remove
Returns:
the INamedGraph for the given URI if it is within this dataset

executeQuery

public QueryResult executeQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphsIn,
                                java.util.Set<org.openrdf.model.URI> namedGraphsIn,
                                java.lang.String query)
                         throws AnzoException
Description copied from interface: IContainer
Execute a SPARQL query against the data within this container

Specified by:
executeQuery in interface IContainer
Overrides:
executeQuery in class Dataset
Parameters:
defaultNamedGraphsIn - Set<URI> of URIs for NamedGraphs that will make up the default graph for this query
namedGraphsIn - Set<URI> of URIs for NamedGraphs that will make up the NamedGraphs for this query
query - SPARQL query string
Returns:
Results of running query
Throws:
AnzoException

executeQuery

public QueryResult executeQuery(java.lang.String query)
                         throws AnzoException
Description copied from interface: IDataset
Execute a SPARQL query against the data within this dataset, using the dataset's DefaultGraph and NameGraph sets

Specified by:
executeQuery in interface IDataset
Overrides:
executeQuery in class Dataset
Parameters:
query - SPARQL query string
Returns:
Results of running query
Throws:
AnzoException

findAll

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findAll(org.openrdf.model.Resource subj,
                                                                                               org.openrdf.model.URI prop,
                                                                                               org.openrdf.model.Value obj,
                                                                                               org.openrdf.model.Resource... namedGraphUris)
Description copied from interface: IDataset
Return an iterator of all statements that match the pattern of subj,prop,obj Difference between find, and findall, is that with findAll, if contexts are provided, they are used to sort results, but not limit results, ie the results contains all statements that match the subj,prop,obj, with matching statements within the given contexts earlier in the iterator than statements not in the provided contexts.

Specified by:
findAll in interface IDataset
Overrides:
findAll in class ADataset
Parameters:
subj - Subject resource to match, or null for any
prop - Predicate uri to match, or null for any
obj - Object value to match, or null for any
namedGraphUris - Set of contexts to search first, before searching the rest of the dataset
Returns:
an iterator of all statements that match the pattern of subj,prop,obj

add

public void add(java.util.Iterator<org.openrdf.model.Statement> statements)
Description copied from class: ADataset
Add statements to their given NamedGraph. Context of each statement is used to determine which NamedGraph statement is to be added.

Specified by:
add in interface IContainer
Overrides:
add in class ADataset
Parameters:
statements - Iterator of statement to add

add

public void add(org.openrdf.model.Resource subj,
                org.openrdf.model.URI pred,
                org.openrdf.model.Value obj,
                org.openrdf.model.Resource namedGraphUri)
Description copied from class: ADataset
Add a statement to the given NamedGraph if said NamedGraph is contained within this dataset. No exception is thrown if NamedGraph is not contained within dataset, statement is simple ignored.

Specified by:
add in interface IContainer
Overrides:
add in class ADataset
Parameters:
subj - Subject of statement
pred - Property of statement
obj - Object of statement
namedGraphUri - URI of NamedGraph to which statement is to be added

add

public void add(org.openrdf.model.Statement... statements)
Description copied from class: ADataset
Add statements to the given NamedGraph if said NamedGraph is contained within this dataset. No exception is thrown if NamedGraph is not contained within dataset, statement is simple ignored.

Specified by:
add in interface IContainer
Overrides:
add in class ADataset
Parameters:
statements - to add

clear

public void clear()
Description copied from interface: IContainer
Delete all statements in container

Specified by:
clear in interface IContainer
Overrides:
clear in class ADataset

clear

public void clear(org.openrdf.model.Resource... context)
Description copied from interface: IContainer
Delete all statements in container for given contexts

Specified by:
clear in interface IContainer
Overrides:
clear in class ADataset
Parameters:
context - Contexts to clear from container

contains

public boolean contains(org.openrdf.model.Resource subj,
                        org.openrdf.model.URI prop,
                        org.openrdf.model.Value obj,
                        org.openrdf.model.Resource... namedGraphUris)
Description copied from interface: IContainer
Return true if the container contains atleast 1 statement that matches the pattern of subj,prop,obj,context

Specified by:
contains in interface IContainer
Overrides:
contains in class ADataset
Parameters:
subj - Subject resource to match, or wildcard if null
prop - Predicate uri to match, or wildcard if null
obj - Object value to match, or wildcard if null
namedGraphUris - Context values to match, or wildcard if null
Returns:
true if the container contains atleast 1 statement that matches the pattern of subj,prop,obj

contains

public boolean contains(org.openrdf.model.Statement statement)
Description copied from interface: IContainer
Return true if the container contains atleast 1 statement that matches the statement provided

Specified by:
contains in interface IContainer
Overrides:
contains in class ADataset
Parameters:
statement - Statement to check for existence in container
Returns:
true if the container contains atleast 1 statement that matches the statement provided

delete

public void delete(java.util.Iterator<org.openrdf.model.Statement> statements)
Description copied from class: ADataset
Delete statements from their given NamedGraph. Context of each statement is used to determine which NamedGraph statement is to be removed.

Specified by:
delete in interface IContainer
Overrides:
delete in class ADataset
Parameters:
statements - Iterator of statement to delete

delete

public void delete(org.openrdf.model.Resource subj,
                   org.openrdf.model.URI pred,
                   org.openrdf.model.Value obj,
                   org.openrdf.model.Resource namedGraphUri)
Description copied from class: ADataset
Delete statements from the given NamedGraph if said NamedGraph is contained within this dataset. No exception is thrown if NamedGraph is not contained within dataset, statement is simple ignored.

Specified by:
delete in interface IContainer
Overrides:
delete in class ADataset
Parameters:
subj - Subject of statement
pred - Property of statement
obj - Object of statement
namedGraphUri - URI of NamedGraph to which statement is to be deleted

delete

public void delete(org.openrdf.model.Statement... statements)
Description copied from class: ADataset
Delete statements from the given NamedGraph if said NamedGraph is contained within this dataset. No exception is thrown if NamedGraph is not contained within dataset, statement is simple ignored.

Specified by:
delete in interface IContainer
Overrides:
delete in class ADataset
Parameters:
statements - statements to remove

find

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> find(org.openrdf.model.Resource subj,
                                                                                            org.openrdf.model.URI prop,
                                                                                            org.openrdf.model.Value obj,
                                                                                            org.openrdf.model.Resource... namedGraphUris)
Description copied from interface: IContainer
Return an iterator over all statements that match the pattern of subj,prop,obj

Specified by:
find in interface IContainer
Overrides:
find in class ADataset
Parameters:
subj - Subject resource to match, or wildcard if null
prop - Predicate uri to match, or wildcard if null
obj - Object value to match, or wildcard if null
namedGraphUris - Context values to match, or wildcard if null
Returns:
an iterator of all statements that match the pattern of subj,prop,obj,context

getStatements

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> getStatements()
Description copied from interface: IContainer
Get an iterator over all statements within this container

Specified by:
getStatements in interface IContainer
Overrides:
getStatements in class ADataset
Returns:
CloseableIterator of all statements within this container

size

public int size()
Description copied from interface: IContainer
Return number of statements in container

Specified by:
size in interface IContainer
Overrides:
size in class ADataset
Returns:
number of statements in container

size

public int size(org.openrdf.model.Resource... context)
Description copied from interface: IContainer
Return number of statements in container

Specified by:
size in interface IContainer
Overrides:
size in class ADataset
Parameters:
context - Contexts of statements to count
Returns:
number of statements in container for given contexts

getEventManager

public INamedGraphEventManager getEventManager()
Description copied from interface: IContainer
Return INamedGraphEventManager for this container

Specified by:
getEventManager in interface IContainer
Overrides:
getEventManager in class Dataset
Returns:
INamedGraphEventManager for this container


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.