com.adventnet.utils.jmx
Class SortedTable

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.TreeMap
              |
              +--com.adventnet.utils.jmx.SortedTable

public class SortedTable
extends java.util.TreeMap

This class is used to hold the table entries in a Sorted fashion. This would be useful in the case of a JMX Agent where the indices would be handled as an Object[]. This method overrides certain methods from TreeMap and those methods are declares as synchronized.

See Also:
Serialized Form

Inner classes inherited from class java.util.TreeMap
java.util.TreeMap.Entry
 
Constructor Summary
SortedTable()
          Constructor which creates a new instance of this object.
 
Method Summary
 boolean containsKey(java.lang.Object[] keys)
          Checks whether this table contains the specified keys.
 java.lang.Object firstEntry()
          Returns the first Entry from the table.
 java.lang.Object get(int index)
          Retrieves the Entry object identified by the index.
 java.lang.Object get(java.lang.Object[] keys)
          Retrieves the Entry object identified by the keys.
 java.util.List getEntries(int startIndex, int endIndex)
          Returns a List of table indices (A List of Object[]'s)
 java.lang.Object getNext(java.lang.Object[] keys)
          Returns the next element to the specified keys.
 java.lang.Object put(java.lang.Object[] keys, java.lang.Object value)
          Used to put the entry object identified by the keys.
 java.lang.Object remove(java.lang.Object[] keys)
          Removes the entry object identified by the keys, if present.
 int size()
          Returns the number of entries in the table.
 java.lang.Object[] toArray()
          Used to get the values contained in this Map as an Object[].
 java.lang.Object[] toArray(java.lang.Object[] o)
          Returns an array containing all of the values in this Map whose runtime type is that of the specified array.
 java.lang.Object[] toKeysArray()
          Used to get the keys contained in this Map as an Object[].
 
Methods inherited from class java.util.TreeMap
addAllForTreeSet, clear, clone, comparator, containsKey, containsValue, entrySet, firstKey, get, headMap, keySet, lastKey, put, putAll, readTreeSet, remove, subMap, tailMap, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, toString
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SortedTable

public SortedTable()
Constructor which creates a new instance of this object.
Method Detail

put

public java.lang.Object put(java.lang.Object[] keys,
                            java.lang.Object value)
Used to put the entry object identified by the keys.
Returns:
Any old value identified by the same key or null if not present previously.

get

public java.lang.Object get(java.lang.Object[] keys)
Retrieves the Entry object identified by the keys.

get

public java.lang.Object get(int index)
Retrieves the Entry object identified by the index. It is recommended not to invoke this method within a loop as this may affect the performance. Instead the toArray() can be used when required in a loop.
Parameters:
index - The index starting from zero.

getNext

public java.lang.Object getNext(java.lang.Object[] keys)
Returns the next element to the specified keys.
Returns:
null if no matching entry found.

containsKey

public boolean containsKey(java.lang.Object[] keys)
Checks whether this table contains the specified keys.
Returns:
true if present, false otherwise.

remove

public java.lang.Object remove(java.lang.Object[] keys)
Removes the entry object identified by the keys, if present.
Returns:
The value object identified by the key.

size

public int size()
Returns the number of entries in the table.
Overrides:
size in class java.util.TreeMap

firstEntry

public java.lang.Object firstEntry()
Returns the first Entry from the table.

getEntries

public java.util.List getEntries(int startIndex,
                                 int endIndex)
Returns a List of table indices (A List of Object[]'s)

toKeysArray

public java.lang.Object[] toKeysArray()
Used to get the keys contained in this Map as an Object[]. The values would be in a Sorted fashion.
Returns:
An Object[] of the keys contained in this Map.

toArray

public java.lang.Object[] toArray()
Used to get the values contained in this Map as an Object[]. The values would be in a Sorted fashion.
Returns:
An Object[] of the values contained in this Map.

toArray

public java.lang.Object[] toArray(java.lang.Object[] o)
Returns an array containing all of the values in this Map whose runtime type is that of the specified array.
Returns:
An Object[] of the values contained in this Map.
See Also:
Collection.toArray(Object[])