Class RMGroup

All Implemented Interfaces:
RMKey.ValueForKey, RMKey.ValueForKeyChain, Serializable, Cloneable, Iterable, Collection, List, RandomAccess
Direct Known Subclasses:
RMGroup.Running

public class RMGroup extends 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:
  • Constructor Details

    • RMGroup

      public RMGroup()
      Creates an empty group.
    • RMGroup

      public RMGroup(List aList)
      Creates a group with the (assumed) list of groups.
    • RMGroup

      public RMGroup(Object obj, RMGroup aGroup)
      Creates a leaf group for the given object and parent group.
    • RMGroup

      public RMGroup(List aList, RMGrouper aGrouper)
      Creates a group by grouping the objects in the given list by the groupings in the given grouper.
  • Method Details

    • getKey

      public String getKey()
      Returns the key associated with this group.
    • getKey

      public static String getKey(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(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, 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 List[] getAllDistinctValuesAtLevel(int aLevel, Object nullValue, 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 Object valueForKey(String aKey)
      Custom implementation of valueForKey to handle group heritage keys.
      Specified by:
      valueForKey in interface RMKey.ValueForKey
    • valueForKeyChain

      public Object valueForKeyChain(Object aKeyChain)
      Custom implementation of valueForKeyChain to handle top N groups.
      Specified by:
      valueForKeyChain in interface RMKey.ValueForKeyChain
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Collection
      Specified by:
      equals in interface List
      Overrides:
      equals in class ArrayList