org.jfree.report.util
Class LevelList

java.lang.Object
  extended byorg.jfree.report.util.LevelList
All Implemented Interfaces:
java.lang.Cloneable

public class LevelList
extends java.lang.Object
implements java.lang.Cloneable

A list that associates a level (instance of Integer) with each element in the list.

Author:
Thomas Morgner

Constructor Summary
LevelList()
          Creates a new list (initially empty).
 
Method Summary
 void add(java.lang.Object o)
          Adds an element at level zero.
 void add(java.lang.Object o, int level)
          Adds an element at a given level.
 void clear()
          Clears the list.
 java.lang.Object clone()
          Clones the list.
 java.lang.Object get(int index)
          Returns the element with the given index.
 java.lang.Object[] getElementArrayForLevel(int level)
          Returns an iterator for all the elements at a given level.
 java.lang.Object[] getElementArrayForLevel(int level, java.lang.Object[] target)
          Returns an iterator for all the elements at a given level.
 int getElementCountForLevel(int level)
          Returns the numer of elements registered for an certain level.
protected  java.util.Iterator getElementsForLevel(int level)
          Deprecated. use the array methods for best performance.
 int getLevel(int index)
          Returns the level for an element.
 int getLevel(java.lang.Object o)
          Returns the level of an element.
 java.util.Iterator getLevelsAscending()
          Returns an iterator that iterates through the levels in ascending order.
 java.util.Iterator getLevelsDescending()
          Returns an iterator that iterates through the levels in descending order.
protected  java.lang.Object[] getRawElements()
          Returns all stored objects as object array.
protected  java.lang.Integer[] getRawLevels()
          Returns all active levels as java.lang.Integer array.
 int indexOf(java.lang.Object o)
          Returns the index of an element.
 void setLevel(int index, int level)
          Sets the level for an element.
 void setLevel(java.lang.Object o, int level)
          Sets the level of an element.
 int size()
          Returns the number of elements in the list.
 java.lang.Object[] toArray()
          Returns the elements as an array.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LevelList

public LevelList()
Creates a new list (initially empty).

Method Detail

size

public int size()
Returns the number of elements in the list.

Returns:
the element count.

getLevelsAscending

public java.util.Iterator getLevelsAscending()
Returns an iterator that iterates through the levels in ascending order.

Returns:
an iterator.

getLevelsDescending

public java.util.Iterator getLevelsDescending()
Returns an iterator that iterates through the levels in descending order.

Returns:
an iterator.

toArray

public java.lang.Object[] toArray()
Returns the elements as an array.

Returns:
the array.

getElementArrayForLevel

public java.lang.Object[] getElementArrayForLevel(int level,
                                                  java.lang.Object[] target)
Returns an iterator for all the elements at a given level.

Parameters:
level - the level.
target - the target array that should receive the contentes
Returns:
the data for the level as object array.

getElementArrayForLevel

public java.lang.Object[] getElementArrayForLevel(int level)
Returns an iterator for all the elements at a given level.

Parameters:
level - the level.
Returns:
the data for the level as object array.

getElementCountForLevel

public int getElementCountForLevel(int level)
Returns the numer of elements registered for an certain level.

Parameters:
level - the level that should be queried
Returns:
the numer of elements in that level

getElementsForLevel

protected java.util.Iterator getElementsForLevel(int level)
Deprecated. use the array methods for best performance.

Creates an iterator for the elements in the list at the given level.

Parameters:
level - the level.
Returns:
An iterator.

get

public java.lang.Object get(int index)
Returns the element with the given index.

Parameters:
index - the index.
Returns:
the element.

add

public void add(java.lang.Object o)
Adds an element at level zero.

Parameters:
o - the element.

add

public void add(java.lang.Object o,
                int level)
Adds an element at a given level.

Parameters:
o - the element.
level - the level.

setLevel

public void setLevel(int index,
                     int level)
Sets the level for an element.

Parameters:
index - the element index.
level - the level.

getLevel

public int getLevel(int index)
Returns the level for an element.

Parameters:
index - the element index.
Returns:
the level.

indexOf

public int indexOf(java.lang.Object o)
Returns the index of an element.

Parameters:
o - the element.
Returns:
the index.

getLevel

public int getLevel(java.lang.Object o)
Returns the level of an element.

Parameters:
o - the element.
Returns:
the level.

setLevel

public void setLevel(java.lang.Object o,
                     int level)
Sets the level of an element.

Parameters:
o - the element.
level - the level.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the list.

Returns:
the clone.
Throws:
java.lang.CloneNotSupportedException - should never happen.

clear

public void clear()
Clears the list.


getRawElements

protected java.lang.Object[] getRawElements()
Returns all stored objects as object array.

Returns:
all elements as object array.

getRawLevels

protected java.lang.Integer[] getRawLevels()
Returns all active levels as java.lang.Integer array.

Returns:
all levels as Integer array.