prefuse.data.tuple
Class DefaultTupleSet

java.lang.Object
  extended by prefuse.data.tuple.AbstractTupleSet
      extended by prefuse.data.tuple.DefaultTupleSet
All Implemented Interfaces:
EventConstants, TupleSet
Direct Known Subclasses:
SearchTupleSet

public class DefaultTupleSet
extends AbstractTupleSet
implements EventConstants

TupleSet implementation that maintains a set of heterogeneous Tuples -- tuples that can come from any backing data source. This class supports addTuple(Tuple) and removeTuple(Tuple) but does not support adding new columns to contained tuples.

This TupleSet uses a LinkedHashSet to support fast lookup of contained tuples while mainting Tuples in the order in which they are added to the set.

Author:
jeffrey heer

Field Summary
protected  java.util.LinkedHashSet m_tuples
           
 
Fields inherited from interface prefuse.data.event.EventConstants
ALL_COLUMNS, DELETE, INSERT, UPDATE
 
Fields inherited from interface prefuse.data.tuple.TupleSet
EMPTY_ARRAY
 
Constructor Summary
DefaultTupleSet()
          Create a new, empty DefaultTupleSet.
 
Method Summary
protected  Tuple addInternal(Tuple t)
          Adds a tuple without firing a notification.
 Tuple addTuple(Tuple t)
          Add a Tuple to this TupleSet.
 void clear()
          Clear this TupleSet, removing all contained Tuples.
 Tuple[] clearInternal()
          Clear the internal state without firing a notification.
 boolean containsTuple(Tuple t)
          Indicates if a given Tuple is contained within this TupleSet.
 int getTupleCount()
          Get the number of tuples in this set.
protected  boolean removeInternal(Tuple t)
          Removes a tuple without firing a notification.
 boolean removeTuple(Tuple t)
          Remove a Tuple from this TupleSet.
 Tuple setTuple(Tuple t)
          Set the TupleSet contents to be a single Tuple.
 Tuple[] toArray()
          Get the contents of this TupleSet as an array.
 java.util.Iterator tuples()
          Return an iterator over the tuples in this tuple set.
 
Methods inherited from class prefuse.data.tuple.AbstractTupleSet
addColumn, addColumn, addColumn, addColumn, addColumns, addPropertyChangeListener, addPropertyChangeListener, addTupleSetListener, fireTupleEvent, fireTupleEvent, fireTupleEvent, getClientProperty, isAddColumnSupported, putClientProperty, removePropertyChangeListener, removePropertyChangeListener, removeTupleSetListener, tuples, tuples
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_tuples

protected java.util.LinkedHashSet m_tuples
Constructor Detail

DefaultTupleSet

public DefaultTupleSet()
Create a new, empty DefaultTupleSet.

Method Detail

getTupleCount

public int getTupleCount()
Description copied from interface: TupleSet
Get the number of tuples in this set.

Specified by:
getTupleCount in interface TupleSet
Returns:
the tuple count
See Also:
TupleSet.getTupleCount()

addTuple

public Tuple addTuple(Tuple t)
Description copied from interface: TupleSet
Add a Tuple to this TupleSet. This method is optional, and may result in an UnsupportedOperationException on some TupleSet implementations.

Specified by:
addTuple in interface TupleSet
Parameters:
t - the Tuple add
Returns:
the actual Tuple instance stored in the TupleSet. This may be null to signify that the add failed, may be a new Tuple with values copied from the input tuple, or may be the input Tuple itself.
See Also:
TupleSet.addTuple(prefuse.data.Tuple)

setTuple

public Tuple setTuple(Tuple t)
Description copied from interface: TupleSet
Set the TupleSet contents to be a single Tuple. This method is optional, and may result in an UnsupportedOperationException on some TupleSet implementations.

Specified by:
setTuple in interface TupleSet
Parameters:
t - the Tuple to set as the content of this TupleSet
Returns:
the actual Tuple instance stored in the TupleSet. This may be null to signify that the add failed, may be a new Tuple with values copied from the input tuple, or may be the input Tuple itself.
See Also:
TupleSet.setTuple(prefuse.data.Tuple)

addInternal

protected final Tuple addInternal(Tuple t)
Adds a tuple without firing a notification.

Parameters:
t - the Tuple to add
Returns:
the added Tuple

containsTuple

public boolean containsTuple(Tuple t)
Description copied from interface: TupleSet
Indicates if a given Tuple is contained within this TupleSet.

Specified by:
containsTuple in interface TupleSet
Parameters:
t - the tuple to check for containment
Returns:
true if the Tuple is in this TupleSet, false otherwise
See Also:
TupleSet.containsTuple(prefuse.data.Tuple)

removeTuple

public boolean removeTuple(Tuple t)
Description copied from interface: TupleSet
Remove a Tuple from this TupleSet.

Specified by:
removeTuple in interface TupleSet
Parameters:
t - the Tuple to remove
Returns:
true if the Tuple was found and removed, false otherwise
See Also:
TupleSet.removeTuple(prefuse.data.Tuple)

removeInternal

protected final boolean removeInternal(Tuple t)
Removes a tuple without firing a notification.

Parameters:
t - the tuple to remove
Returns:
true if the tuple is removed successfully, false otherwise

clear

public void clear()
Description copied from interface: TupleSet
Clear this TupleSet, removing all contained Tuples.

Specified by:
clear in interface TupleSet
See Also:
TupleSet.clear()

clearInternal

public Tuple[] clearInternal()
Clear the internal state without firing a notification.

Returns:
an array of removed tuples

tuples

public java.util.Iterator tuples()
Description copied from interface: TupleSet
Return an iterator over the tuples in this tuple set.

Specified by:
tuples in interface TupleSet
Returns:
an iterator over this set's tuples
See Also:
TupleSet.tuples()

toArray

public Tuple[] toArray()
Get the contents of this TupleSet as an array.

Returns:
the contents of this TupleSet as an array


Copyright © 2007 Regents of the University of California