|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap
java.util.HashMap
com.timeindexing.util.Grouper
This class represents a collection that has been grouped using a criteria specified as a Grouping object. The method getGroup() of Grouping returns an object which acts as the identifier for a group. Every object in the source collection which has the same value returned by getGroup() will be in the same group.
A Grouper is a kind of Map and can therefore be used in any context that accepts a Map.
As an example, consider taking a set of Path objects. The following will build a Grouper based on the length of the paths.
Grouper grouper = new Grouper(pathSet, new Grouping() { public Object getGroup(Object obj) { Path path = (Path)obj; return new Integer(path.length()); } });
The resulting Grouper will have keys which are the lengths of the paths, and the values will be a list of paths that have that length.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Constructor Summary | |
protected |
Grouper()
Only used internally. |
|
Grouper(java.util.Collection collection,
Grouping grouping)
This constructor takes a collection and a Grouping object and creates a grouper. |
|
Grouper(Grouper grouper,
Grouping grouping)
This constructor takes a grouper and a Grouping object and creates a sub grouper for each existing group in the grouper argumrnt. |
Method Summary | |
void |
add(java.lang.Object groupSpecifier,
java.lang.Object obj)
Add an element to a group. |
boolean |
doGrouping(java.util.Collection collection,
Grouping grouping)
Actually do the grouping. |
java.util.List |
getGroup(java.lang.Object groupSpecifier)
Get the list of elements associated with a particular group. |
Grouper |
groupAGrouper(Grouping grouping)
This takes a grouper and a Grouping object and creates a sub grouper for each existing group in the grouper argumrnt. |
Methods inherited from class java.util.HashMap |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Constructor Detail |
public Grouper(java.util.Collection collection, Grouping grouping)
public Grouper(Grouper grouper, Grouping grouping)
protected Grouper()
Method Detail |
public boolean doGrouping(java.util.Collection collection, Grouping grouping)
public Grouper groupAGrouper(Grouping grouping)
public void add(java.lang.Object groupSpecifier, java.lang.Object obj)
groupSpecifier
- the identifier for the groupobj
- the object to add to the grouppublic java.util.List getGroup(java.lang.Object groupSpecifier)
groupSpecifier
- the identifier for the group
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |