org.openanzo.model.delta
Class DeltaContainer

java.lang.Object
  extended by org.openanzo.model.delta.DeltaContainer

public class DeltaContainer
extends java.lang.Object

DeltaContainer is the underlying implementation of a overlay of delta changes to a base container

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
DeltaContainer()
          Create a container of addtions and deletions
DeltaContainer(java.util.Collection<org.openrdf.model.Statement> additions, java.util.Collection<org.openrdf.model.Statement> deletions)
          Create a container of addtions and deletions with the provided additions and deletions
 
Method Summary
 void add(org.openrdf.model.Statement... statements)
          Add statements to the delta.
 void apply(IContainer container)
          Apply the deltas contained in this container to the provided container.
 void clear()
          Clear the delta of all changes.
 boolean containsAddition(org.openrdf.model.Statement statement)
          Does the delta contain this statement in its set of additions
 boolean containsDeletion(org.openrdf.model.Statement statement)
          Does the delta contain this statement in its set of deletions
 void delete(org.openrdf.model.Statement... statements)
          Delete statements from the delta.
 void filter(java.util.Collection<org.openrdf.model.Statement> results, org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource... contexts)
          Filter a set of results with the additions and deletions in this delta that match a statement pattern
 void filter(java.util.Collection<org.openrdf.model.Statement> results, org.openrdf.model.Statement match)
          Filter a set of results with the additions and deletions in this delta that match a statement pattern
 java.util.Collection<org.openrdf.model.URI> getAdditionContexts()
          Get set of contexts affected by additions
 java.util.Collection<org.openrdf.model.Statement> getAdditions()
          Get the set of additions within this delta
 java.util.Collection<org.openrdf.model.URI> getDeletionContexts()
          Get set of contexts affected by deletions
 java.util.Collection<org.openrdf.model.Statement> getDeletions()
          Get the set of deletions within this delta
 int size()
          Return the number of changes contained in this delta
 int sizeAdditions()
          Return the number of changes contained in this delta's additions
 int sizeAdditions(org.openrdf.model.Resource... contexts)
          Return the number of changes contained in this delta's additions for a given context
 int sizeDeletions()
          Return the number of changes contained in this delta's deletions
 int sizeDeletions(org.openrdf.model.Resource... contexts)
          Return the number of changes contained in this delta's deletions for a given context
 void unapply(IContainer container)
          Unapply the deltas contained in this delta to the provided container.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeltaContainer

public DeltaContainer()
Create a container of addtions and deletions


DeltaContainer

public DeltaContainer(java.util.Collection<org.openrdf.model.Statement> additions,
                      java.util.Collection<org.openrdf.model.Statement> deletions)
Create a container of addtions and deletions with the provided additions and deletions

Parameters:
additions - Statements added in this delta
deletions - Statements deleted in this delta
Method Detail

getAdditionContexts

public java.util.Collection<org.openrdf.model.URI> getAdditionContexts()
Get set of contexts affected by additions

Returns:
set of contexts affected by additions

getDeletionContexts

public java.util.Collection<org.openrdf.model.URI> getDeletionContexts()
Get set of contexts affected by deletions

Returns:
set of contexts affected by deletions

add

public void add(org.openrdf.model.Statement... statements)
Add statements to the delta. If the statements already existed in the Base container, but had been deleted within this delta, remove the deletion from delta. If the statements are new, add them to the additions delta, and the localAdditions.

Parameters:
statements - New statements to add

delete

public void delete(org.openrdf.model.Statement... statements)
Delete statements from the delta. If the statements were added to the Base container within this delta, remove the additions from delta. If the statements existed in the base container already, add it to the deletions delta, and the localDeletions.

Parameters:
statements - New statement to add

containsDeletion

public boolean containsDeletion(org.openrdf.model.Statement statement)
Does the delta contain this statement in its set of deletions

Parameters:
statement - Statement to check
Returns:
if the statement is contained within deletions

containsAddition

public boolean containsAddition(org.openrdf.model.Statement statement)
Does the delta contain this statement in its set of additions

Parameters:
statement - Statement to check
Returns:
if the statement is contained within additions

filter

public void filter(java.util.Collection<org.openrdf.model.Statement> results,
                   org.openrdf.model.Resource s,
                   org.openrdf.model.URI p,
                   org.openrdf.model.Value o,
                   org.openrdf.model.Resource... contexts)
Filter a set of results with the additions and deletions in this delta that match a statement pattern

Parameters:
results - Set of results to filter
s - subject of statement pattern to filter by
p - property of statement pattern to filter by
o - object of statement pattern to filter by
contexts - contexts of statement pattern to filter by

filter

public void filter(java.util.Collection<org.openrdf.model.Statement> results,
                   org.openrdf.model.Statement match)
Filter a set of results with the additions and deletions in this delta that match a statement pattern

Parameters:
results - Set of results to filter
match - statement pattern to match

clear

public void clear()
Clear the delta of all changes.


apply

public void apply(IContainer container)
Apply the deltas contained in this container to the provided container.

Parameters:
container - Container to apply changes

unapply

public void unapply(IContainer container)
Unapply the deltas contained in this delta to the provided container.

Parameters:
container - Container to apply changes

size

public int size()
Return the number of changes contained in this delta

Returns:
the number of changes contained in this delta

sizeAdditions

public int sizeAdditions()
Return the number of changes contained in this delta's additions

Returns:
the number of changes contained in this delta's additions

sizeDeletions

public int sizeDeletions()
Return the number of changes contained in this delta's deletions

Returns:
the number of changes contained in this delta's deletions

sizeAdditions

public int sizeAdditions(org.openrdf.model.Resource... contexts)
Return the number of changes contained in this delta's additions for a given context

Parameters:
contexts - set of contexts to determine size
Returns:
the number of changes contained in this delta's additions for a given context

sizeDeletions

public int sizeDeletions(org.openrdf.model.Resource... contexts)
Return the number of changes contained in this delta's deletions for a given context

Parameters:
contexts - set of contexts to determine size
Returns:
the number of changes contained in this delta's deletions for a given context

getAdditions

public java.util.Collection<org.openrdf.model.Statement> getAdditions()
Get the set of additions within this delta

Returns:
the set of additions

getDeletions

public java.util.Collection<org.openrdf.model.Statement> getDeletions()
Get the set of deletions within this delta

Returns:
the set of deletions


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