net.java.rdf.sommer.util
Class RDFCollection<E>

java.lang.Object
  extended by net.java.rdf.sommer.util.RDFCollection<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>

public class RDFCollection<E>
extends java.lang.Object
implements java.util.Collection<E>

An unbuffered collection. Once the elements are added to the collection, all calls go straight to the rdf database. (easier to debug) class should probably called SesameRDFCollection as it does depend on Sesame Resource...

Author:
Henry Story

Nested Class Summary
(package private)  class RDFCollection.MRIterator
           
 
Field Summary
(package private)  java.util.ArrayList cache
           
(package private)  boolean inverse
           
(package private)  SesameMapper map
           
(package private)  org.openrdf.model.URI relation
           
(package private)  org.openrdf.model.Resource source
           
(package private)  java.lang.Class superType
           
(package private)  java.util.Date updatedAt
           
 
Constructor Summary
RDFCollection(SesameMapper map, java.util.Collection<E> collection, java.lang.Class<E> supertype)
          Map all of its elements into a Semantic web collection taking this as subject
RDFCollection(SesameMapper map, java.util.Collection<E> collection, java.lang.Class<E> supertype, java.lang.Object source, org.openrdf.model.URI relation, boolean inverse)
          creates a parallel world in the database
RDFCollection(SesameMapper map, org.openrdf.model.Resource id, java.lang.Class<E> supertype)
          A pure rdf collection object, where we know the rdf name of the collection in advance.
 
Method Summary
 boolean add(E o)
           
 boolean addAll(java.util.Collection<? extends E> c)
           
private  void addRelations(java.util.Collection<E> wrapped)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
private  java.util.Collection<E> getCurrentCollection()
           
 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 void replaceWith(java.util.Collection newColl)
          replace all the members of this collection with those of the new collection the algorithm could perhaps be improoved to work out if relations already exist before removing them...
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

source

org.openrdf.model.Resource source

relation

org.openrdf.model.URI relation

inverse

boolean inverse

superType

java.lang.Class superType

map

SesameMapper map

cache

java.util.ArrayList cache

updatedAt

java.util.Date updatedAt
Constructor Detail

RDFCollection

public RDFCollection(SesameMapper map,
                     java.util.Collection<E> collection,
                     java.lang.Class<E> supertype)
Map all of its elements into a Semantic web collection taking this as subject

Parameters:
collection - the collection of objects

RDFCollection

public RDFCollection(SesameMapper map,
                     java.util.Collection<E> collection,
                     java.lang.Class<E> supertype,
                     java.lang.Object source,
                     org.openrdf.model.URI relation,
                     boolean inverse)
creates a parallel world in the database

Parameters:
collection - the java collection to map to an rdf collection
source - the source of the relations (usually the calling object)
relation - the name of the relation between the source and every member of the collection collection
inverse - is it the inverse of the relation that is desired?

RDFCollection

public RDFCollection(SesameMapper map,
                     org.openrdf.model.Resource id,
                     java.lang.Class<E> supertype)
A pure rdf collection object, where we know the rdf name of the collection in advance. Here we fill the collection with information from the database

Parameters:
id - the id of the collection.
supertype - the type of objects in the collection
Method Detail

addRelations

private void addRelations(java.util.Collection<E> wrapped)

getCurrentCollection

private java.util.Collection<E> getCurrentCollection()

replaceWith

public void replaceWith(java.util.Collection newColl)
replace all the members of this collection with those of the new collection the algorithm could perhaps be improoved to work out if relations already exist before removing them...


size

public int size()
Specified by:
size in interface java.util.Collection<E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<E>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<E>

add

public boolean add(E o)
Specified by:
add in interface java.util.Collection<E>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<E>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<E>

addAll

public boolean addAll(java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.Collection<E>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<E>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<E>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E>