net.sf.taverna.t2.partition
Class Partition<ItemType extends java.lang.Comparable,PartitionValueType,ChildPartitionValueType>

java.lang.Object
  extended by net.sf.taverna.t2.partition.Partition<ItemType,PartitionValueType,ChildPartitionValueType>
Type Parameters:
ItemType - all items in the underlying set of which this is a subset are instances of this type or can be cast to it according to conventional java language rules.
PartitionValueType - the partition value type used by the parent partition algorithm to create this partition object. As an example, if this partition object represented all those entries with a particular host institution this would be a String or possibly URL.
ChildPartitionValueType - the partition value type used by this partition's partition algorithm to create sub-partitions, it's used in the signature here because ordering of children is done based on these values. Any child partition will have a getPartitionValue return type cast-able to this type.
Direct Known Subclasses:
RootPartition

public class Partition<ItemType extends java.lang.Comparable,PartitionValueType,ChildPartitionValueType>
extends java.lang.Object

A partition represents a set of items which can be exclusively classified into one or more distinct subsets along with the algorithm to perform this subset operation.

Author:
Tom Oinn

Method Summary
 java.util.Comparator<ChildPartitionValueType> getChildPartitionOrder()
          Sub-partitions of this partition are ordered based on a comparator over the child partition value type.
 java.util.List<Partition<ItemType,ChildPartitionValueType,?>> getChildren()
          Sub-partitions of this partition defined by the partition algorithm at index 0 of the list.
 int getItemCount()
          Return the number of items below this node in the partition tree; in the case of leaf partitions this is the number of items in the member set, for non-leaf partitions it is the sum of the item count for all immediate child partitions.
 java.util.List<ItemType> getMembers()
          If this is a leaf partition, defined as one with an empty list of partition algorithms, then this method returns the set of all items which have been classified as belonging to this leaf partition.
 Partition<ItemType,?,PartitionValueType> getParent()
          Return the parent partition of which this is a sub-partition, or null if this is the root partition.
 java.util.List<PartitionAlgorithm<?>> getPartitionAlgorithms()
          The list of partition algorithms applicable to this node (at index 0) and subsequent downstream sub-partitions of it.
 java.util.List<Partition<ItemType,?,?>> getPartitionPath()
          Return a list of Partition objects from the root (at index 0) to this node at the final position in the list.
 PartitionValueType getPartitionValue()
          The parent partition created this partition based on a particular value of a property of the members of the sub-partition.
 void setChildPartitionOrder(java.util.Comparator<ChildPartitionValueType> order)
          Set a comparator for child partition ordering - if the supplied comparator is different to the current one this will also trigger a re-order of all child partitions and corresponding events in the root partition's tree view.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getItemCount

public int getItemCount()
Return the number of items below this node in the partition tree; in the case of leaf partitions this is the number of items in the member set, for non-leaf partitions it is the sum of the item count for all immediate child partitions.


getChildPartitionOrder

public java.util.Comparator<ChildPartitionValueType> getChildPartitionOrder()
Sub-partitions of this partition are ordered based on a comparator over the child partition value type.

Returns:
a comparator over child partition value types, or null if no comparator has been specified (by default this returns null)

setChildPartitionOrder

public void setChildPartitionOrder(java.util.Comparator<ChildPartitionValueType> order)
Set a comparator for child partition ordering - if the supplied comparator is different to the current one this will also trigger a re-order of all child partitions and corresponding events in the root partition's tree view. In the current implementation this is the very broad 'tree structure changed' event for this node in the tree view.

Parameters:
order - a new comparator to order child partitions

getParent

public Partition<ItemType,?,PartitionValueType> getParent()
Return the parent partition of which this is a sub-partition, or null if this is the root partition.


getPartitionValue

public PartitionValueType getPartitionValue()
The parent partition created this partition based on a particular value of a property of the members of the sub-partition. This returns that value, and is the result returned from the parent partition's first partition algorithm when run on all members of this partition or its direct or indirect sub-partitions.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getPartitionPath

public java.util.List<Partition<ItemType,?,?>> getPartitionPath()
Return a list of Partition objects from the root (at index 0) to this node at the final position in the list. Computes the first time then caches, as it should be impossible for this to be modified without recreation of the entire structure from scratch.


getMembers

public final java.util.List<ItemType> getMembers()
If this is a leaf partition, defined as one with an empty list of partition algorithms, then this method returns the set of all items which have been classified as belonging to this leaf partition. For non-leaf partitions it will return an empty set.


getPartitionAlgorithms

public final java.util.List<PartitionAlgorithm<?>> getPartitionAlgorithms()
The list of partition algorithms applicable to this node (at index 0) and subsequent downstream sub-partitions of it. If this is empty then the partition is a leaf partition.


getChildren

public final java.util.List<Partition<ItemType,ChildPartitionValueType,?>> getChildren()
Sub-partitions of this partition defined by the partition algorithm at index 0 of the list. If this is a leaf partition this will always be empty.