Package com.reportmill.base
Class RMGroup
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList
-
- com.reportmill.base.RMGroup
-
- All Implemented Interfaces:
RMKey.ValueForKey
,RMKey.ValueForKeyChain
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable
,java.util.Collection
,java.util.List
,java.util.RandomAccess
- Direct Known Subclasses:
RMGroup.Running
public class RMGroup extends java.util.ArrayList implements RMKey.ValueForKey, RMKey.ValueForKeyChain
This class is a smart List subclass used to hold objects from an original list broken down by grouping keys.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RMGroup.Running
This RMGroup subclass/inner-class represents a subset of a group up to the given endGroup.
-
Constructor Summary
Constructors Constructor Description RMGroup()
Creates an empty group.RMGroup(java.lang.Object obj, RMGroup aGroup)
Creates a leaf group for the given object and parent group.RMGroup(java.util.List aList)
Creates a group with the (assumed) list of groups.RMGroup(java.util.List aList, RMGrouper aGrouper)
Creates a group by grouping the objects in the given list by the groupings in the given grouper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStubGroupsAtLevel(int aLevel, java.util.List[] allValues, boolean includeNulls)
Make sure allValues are represented at aLevel (add empty value-group for missing values) Currently assumes that children are sorted by allValues.boolean
childrenAreLeafs()
Returns whether children of this group are leafs.boolean
equals(java.lang.Object o)
java.util.List[]
getAllDistinctValuesAtLevel(int aLevel, java.lang.Object nullValue, java.util.List[] allValues)
Returns two lists - (1) all distinct values at a given group level and (2) a sample group for each value.RMGroup
getGroup(int anIndex)
Returns the sub-group at the given index.RMGroup
getGroupLast()
Returns the last sub-group.java.lang.String
getKey()
Returns the key associated with this group.static java.lang.String
getKey(java.util.List l)
Returns the key for the given List if it is an RMGroup instance.RMGroup
getMaster()
Returns the master for this group (generally a leaf from another RMGroup hierarchy).RMGroup
getNextPeer()
Returns the next group which is a peer to this one.RMGroup
getParent()
Returns the parent for this group.int
getParentCount()
Returns the number of parents that this group has.RMGroup
getParentOrMaster()
Returns the parent or master for this group.RMTable
getTable()
Returns the table associated with this group.int
index()
Returns the index of this group in its parent.boolean
isLeaf()
Returns whether this group is a leaf group.static boolean
isLeaf(java.util.List l)
Returns whether the given List is an RMGroup instance that also isLeaf.boolean
isTopNOthers()
Returns whether this group is made up of the remainders from a TopN sort.void
setMaster(RMGroup aGroup)
Sets the master for this group.void
setTable(RMTable aTable)
Sets the table associated with this group.void
setTopNOthers(boolean aFlag)
Sets whether this group is made up of the remainders from a TopN sort.void
sortBySortsInGrouper(RMGrouper aGrouper)
Sorts the group byte the sorts listed in the grouper (recursively).RMGroup
subgroup(int start, int end)
Returns a subset of this group from start index, inclusive, to end index, exclusive.RMGroup
subgroup(RMGroup startGroup, RMGroup endGroup)
Returns a subset of this group, running deep, which only includes the subset of the tree starting at startGroup and ending at (but not including) endGroup.void
topN(int count, RMSort aSort, boolean includeOthers)
Performs top N sort on group for an individual sort.void
topNWithGrouper(RMGrouper aGrouper)
Performs Top N sort on group for a grouper.void
turnObjectsIntoLeafs()
Turns all list objects into leaf groups.java.lang.Object
valueForKey(java.lang.String aKey)
Custom implementation of valueForKey to handle group heritage keys.java.lang.Object
valueForKeyChain(java.lang.Object aKeyChain)
Custom implementation of valueForKeyChain to handle top N groups.-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Constructor Detail
-
RMGroup
public RMGroup()
Creates an empty group.
-
RMGroup
public RMGroup(java.util.List aList)
Creates a group with the (assumed) list of groups.
-
RMGroup
public RMGroup(java.lang.Object obj, RMGroup aGroup)
Creates a leaf group for the given object and parent group.
-
RMGroup
public RMGroup(java.util.List aList, RMGrouper aGrouper)
Creates a group by grouping the objects in the given list by the groupings in the given grouper.
-
-
Method Detail
-
getKey
public java.lang.String getKey()
Returns the key associated with this group.
-
getKey
public static java.lang.String getKey(java.util.List l)
Returns the key for the given List if it is an RMGroup instance.
-
getParent
public RMGroup getParent()
Returns the parent for this group.
-
getParentCount
public int getParentCount()
Returns the number of parents that this group has.
-
getMaster
public RMGroup getMaster()
Returns the master for this group (generally a leaf from another RMGroup hierarchy).
-
setMaster
public void setMaster(RMGroup aGroup)
Sets the master for this group.
-
getParentOrMaster
public RMGroup getParentOrMaster()
Returns the parent or master for this group.
-
getTable
public RMTable getTable()
Returns the table associated with this group.
-
setTable
public void setTable(RMTable aTable)
Sets the table associated with this group.
-
isLeaf
public boolean isLeaf()
Returns whether this group is a leaf group.
-
isLeaf
public static boolean isLeaf(java.util.List l)
Returns whether the given List is an RMGroup instance that also isLeaf.
-
isTopNOthers
public boolean isTopNOthers()
Returns whether this group is made up of the remainders from a TopN sort.
-
setTopNOthers
public void setTopNOthers(boolean aFlag)
Sets whether this group is made up of the remainders from a TopN sort.
-
index
public int index()
Returns the index of this group in its parent.
-
getGroup
public RMGroup getGroup(int anIndex)
Returns the sub-group at the given index.
-
getGroupLast
public RMGroup getGroupLast()
Returns the last sub-group.
-
getNextPeer
public RMGroup getNextPeer()
Returns the next group which is a peer to this one.
-
childrenAreLeafs
public boolean childrenAreLeafs()
Returns whether children of this group are leafs.
-
subgroup
public RMGroup subgroup(int start, int end)
Returns a subset of this group from start index, inclusive, to end index, exclusive.
-
subgroup
public RMGroup subgroup(RMGroup startGroup, RMGroup endGroup)
Returns a subset of this group, running deep, which only includes the subset of the tree starting at startGroup and ending at (but not including) endGroup.
-
topNWithGrouper
public void topNWithGrouper(RMGrouper aGrouper)
Performs Top N sort on group for a grouper.
-
topN
public void topN(int count, RMSort aSort, boolean includeOthers)
Performs top N sort on group for an individual sort.
-
sortBySortsInGrouper
public void sortBySortsInGrouper(RMGrouper aGrouper)
Sorts the group byte the sorts listed in the grouper (recursively).
-
addStubGroupsAtLevel
public void addStubGroupsAtLevel(int aLevel, java.util.List[] allValues, boolean includeNulls)
Make sure allValues are represented at aLevel (add empty value-group for missing values) Currently assumes that children are sorted by allValues.
-
getAllDistinctValuesAtLevel
public java.util.List[] getAllDistinctValuesAtLevel(int aLevel, java.lang.Object nullValue, java.util.List[] allValues)
Returns two lists - (1) all distinct values at a given group level and (2) a sample group for each value.
-
turnObjectsIntoLeafs
public void turnObjectsIntoLeafs()
Turns all list objects into leaf groups.
-
valueForKey
public java.lang.Object valueForKey(java.lang.String aKey)
Custom implementation of valueForKey to handle group heritage keys.- Specified by:
valueForKey
in interfaceRMKey.ValueForKey
-
valueForKeyChain
public java.lang.Object valueForKeyChain(java.lang.Object aKeyChain)
Custom implementation of valueForKeyChain to handle top N groups.- Specified by:
valueForKeyChain
in interfaceRMKey.ValueForKeyChain
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfacejava.util.Collection
- Specified by:
equals
in interfacejava.util.List
- Overrides:
equals
in classjava.util.ArrayList
-
-