APIdia Launch Partner
Top Description Fields Constructors Methods
javax.management.openmbean

public Class TabularDataSupport

extends Object
implements TabularData, Map<Object, Object>, Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable, java.util.Map, javax.management.openmbean.TabularData
Imports
com.sun.jmx.mbeanserver.Util, java.io.IOException, .ObjectInputStream, .Serializable, java.util.ArrayList, .Arrays, .Collection, .Collections, .HashMap, .Iterator, .LinkedHashMap, .List, .Map, .Set, jdk.internal.access.SharedSecrets

The TabularDataSupport class is the open data class which implements the TabularData and the Map interfaces, and which is internally based on a hash map data structure.
Since
1.5

Field Summary

Modifier and TypeField and Description
private Map<Object, CompositeData>
private transient String[]
indexNamesArray

The array of item names that define the index used for rows (convenience field)

pack-priv static final long
private final TabularType

Constructor Summary

AccessConstructor and Description
public
TabularDataSupport(TabularType
the tabular type describing this TabularData instance; cannot be null.
tabularType
)

Creates an empty TabularDataSupport instance whose open-type is tabularType, and whose underlying HashMap has a default initial capacity (101) and default load factor (0.75).

public
TabularDataSupport(TabularType
the tabular type describing this TabularData instance; cannot be null.
tabularType
,
int
the initial capacity of the HashMap.
initialCapacity
,
float
the load factor of the HashMap
loadFactor
)

Creates an empty TabularDataSupport instance whose open-type is tabularType, and whose underlying HashMap has the specified initial capacity and load factor.

Method Summary

Modifier and TypeMethod and Description
public Object[]

Returns:

the index that the specified value would have in this TabularData instance.
calculateIndex
(CompositeData
the composite data value whose index in this TabularData instance is to be calculated; must be of the same composite type as this instance's row type; must not be null.
value
)

Implements javax.management.openmbean.TabularData.calculateIndex.

Calculates the index that would be used in this TabularData instance to refer to the specified composite data value parameter if it were added to this instance.

private void
checkKeyType(Object[] key)

Checks if the specified key is valid for this TabularData instance.

private List<?>
checkValueAndIndex(CompositeData value)

Checks if the specified value can be put (ie added) in this TabularData instance (ie value is not null, its composite type is equal to row type, and its index is not already used), and returns the index calculated for this value.

private void
checkValueType(CompositeData value)

Checks the specified value's type is valid for this TabularData instance (ie value is not null, and its composite type is equal to row type).

public void
clear()

Implements javax.management.openmbean.TabularData.clear, java.util.Map.clear.

Removes all rows from this TabularDataSupport instance.

public Object
clone()

Overrides java.lang.Object.clone.

Returns a clone of this TabularDataSupport instance: the clone is obtained by calling super.clone(), and then cloning the underlying map.

public boolean

Returns:

true if this TabularData indexes a row value with the specified key.
containsKey
(Object
the index value whose presence in this TabularData instance is to be tested.
key
)

Implements java.util.Map.containsKey.

Returns true if and only if this TabularData instance contains a CompositeData value (ie a row) whose index is the specified key.

public boolean

Returns:

true if this TabularData indexes a row value with the specified key.
containsKey
(Object[]
the index value whose presence in this TabularData instance is to be tested.
key
)

Implements javax.management.openmbean.TabularData.containsKey.

Returns true if and only if this TabularData instance contains a CompositeData value (ie a row) whose index is the specified key.

public boolean

Returns:

true if this TabularData instance contains the specified row value.
containsValue
(CompositeData
the row value whose presence in this TabularData instance is to be tested.
value
)

Implements javax.management.openmbean.TabularData.containsValue.

Returns true if and only if this TabularData instance contains the specified CompositeData value.

public boolean

Returns:

true if this TabularData instance contains the specified row value.
containsValue
(Object
the row value whose presence in this TabularData instance is to be tested.
value
)

Implements java.util.Map.containsValue.

Returns true if and only if this TabularData instance contains the specified value.

public Set<Map.Entry<Object, Object>>

Returns:

a collection view (Set<Map.Entry<List<?>,CompositeData>>) of the mappings contained in this map.
entrySet
()

Implements java.util.Map.entrySet.

Returns a collection view of the index to row mappings contained in this TabularDataSupport instance.

public boolean

Returns:

true if the specified object is equal to this TabularDataSupport instance.
equals
(Object
the object to be compared for equality with this TabularDataSupport instance;
obj
)

Overrides java.lang.Object.equals.

Implements javax.management.openmbean.TabularData.equals, java.util.Map.equals.

Compares the specified obj parameter with this TabularDataSupport instance for equality.

public Object
get(Object key)

Implements java.util.Map.get.

This method simply calls get((Object[]) key).

public CompositeData

Returns:

the value corresponding to key.
get
(Object[]
the index of the value to get in this TabularData instance; must be valid with this TabularData instance's row type definition; must not be null.
key
)

Implements javax.management.openmbean.TabularData.get.

Returns the CompositeData value whose index is key, or null if there is no value mapping to key, in this TabularData instance.

public TabularType
getTabularType()

Implements javax.management.openmbean.TabularData.getTabularType.

Returns the tabular type describing this TabularData instance.

public int

Returns:

the hash code value for this TabularDataSupport instance
hashCode
()

Overrides java.lang.Object.hashCode.

Implements javax.management.openmbean.TabularData.hashCode, java.util.Map.hashCode.

Returns the hash code value for this TabularDataSupport instance.

private List<?>
internalCalculateIndex(CompositeData value)

Returns the index for value, assuming value is valid for this TabularData instance (ie value is not null, and its composite type is equal to row type).

private CompositeData
public boolean

Returns:

true if this TabularDataSupport instance contains no rows.
isEmpty
()

Implements javax.management.openmbean.TabularData.isEmpty, java.util.Map.isEmpty.

Returns true if this TabularDataSupport instance contains no rows.

public Set<Object>

Returns:

a set view (Set<List<?>>) of the keys used to index the rows of this TabularDataSupport instance.
keySet
()

Implements javax.management.openmbean.TabularData.keySet, java.util.Map.keySet.

Returns a set view of the keys contained in the underlying map of this TabularDataSupport instance used to index the rows.

public Object

Returns:

the value which is put
put
(Object
an ignored parameter.
key
,
Object
the CompositeData to put.
value
)

Implements java.util.Map.put.

This method simply calls put((CompositeData) value) and therefore ignores its key parameter which can be null.

public void
put(CompositeData value)

Implements javax.management.openmbean.TabularData.put.

Adds value to this TabularData instance.

public void
putAll(Map<?, ?>
the map whose values are to be added as new rows to this TabularData instance; if t is null or empty, this method returns without doing anything.
t
)

Implements java.util.Map.putAll.

Add all the values contained in the specified map t to this TabularData instance.

public void
putAll(CompositeData[]
the array of composite data values to be added as new rows to this TabularData instance; if values is null or empty, this method returns without doing anything.
values
)

Implements javax.management.openmbean.TabularData.putAll.

Add all the elements in values to this TabularData instance.

private void
public Object

Returns:

previous value associated with specified key, or null if there was no mapping for key.
remove
(Object
an Object[] representing the key to remove.
key
)

Implements java.util.Map.remove.

This method simply calls remove((Object[]) key).

public CompositeData

Returns:

previous value associated with specified key, or null if there was no mapping for key.
remove
(Object[]
the index of the value to get in this TabularData instance; must be valid with this TabularData instance's row type definition; must not be null.
key
)

Implements javax.management.openmbean.TabularData.remove.

Removes the CompositeData value whose index is key from this TabularData instance, and returns the removed value, or returns null if there is no value whose index is key.

public int

Returns:

the number of rows in this TabularDataSupport instance.
size
()

Implements javax.management.openmbean.TabularData.size, java.util.Map.size.

Returns the number of rows in this TabularDataSupport instance.

public String

Returns:

a string representation of this TabularDataSupport instance
toString
()

Overrides java.lang.Object.toString.

Implements javax.management.openmbean.TabularData.toString.

Returns a string representation of this TabularDataSupport instance.

public Collection<Object>

Returns:

a collection view (Collection<CompositeData>) of the values contained in this TabularDataSupport instance.
values
()

Implements javax.management.openmbean.TabularData.values, java.util.Map.values.

Returns a collection view of the rows contained in this TabularDataSupport instance.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

dataMapback to summary
private Map<Object, CompositeData> dataMap
Annotations
@SuppressWarnings:serial
indexNamesArrayback to summary
private transient String[] indexNamesArray

The array of item names that define the index used for rows (convenience field)

serialVersionUIDback to summary
pack-priv static final long serialVersionUID
tabularTypeback to summary
private final TabularType tabularType

Constructor Detail

TabularDataSupportback to summary
public TabularDataSupport(TabularType tabularType)

Creates an empty TabularDataSupport instance whose open-type is tabularType, and whose underlying HashMap has a default initial capacity (101) and default load factor (0.75).

This constructor simply calls this(tabularType, 101, 0.75f);

Parameters
tabularType:TabularType

the tabular type describing this TabularData instance; cannot be null.

Exceptions
IllegalArgumentException:
if the tabular type is null.
TabularDataSupportback to summary
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor)

Creates an empty TabularDataSupport instance whose open-type is tabularType, and whose underlying HashMap has the specified initial capacity and load factor.

Parameters
tabularType:TabularType

the tabular type describing this TabularData instance; cannot be null.

initialCapacity:int

the initial capacity of the HashMap.

loadFactor:float

the load factor of the HashMap

Exceptions
IllegalArgumentException:
if the initial capacity is less than zero, or the load factor is nonpositive, or the tabular type is null.

Method Detail

calculateIndexback to summary
public Object[] calculateIndex(CompositeData value)

Implements javax.management.openmbean.TabularData.calculateIndex.

Calculates the index that would be used in this TabularData instance to refer to the specified composite data value parameter if it were added to this instance. This method checks for the type validity of the specified value, but does not check if the calculated index is already used to refer to a value in this TabularData instance.

Parameters
value:CompositeData

the composite data value whose index in this TabularData instance is to be calculated; must be of the same composite type as this instance's row type; must not be null.

Returns:Object[]

the index that the specified value would have in this TabularData instance.

Exceptions
NullPointerException:
if value is null.
InvalidOpenTypeException:
if value does not conform to this TabularData instance's row type definition.
checkKeyTypeback to summary
private void checkKeyType(Object[] key)

Checks if the specified key is valid for this TabularData instance.

checkValueAndIndexback to summary
private List<?> checkValueAndIndex(CompositeData value)

Checks if the specified value can be put (ie added) in this TabularData instance (ie value is not null, its composite type is equal to row type, and its index is not already used), and returns the index calculated for this value. The index is a List, and not an array, so that an index.equals(otherIndex) call will actually compare contents, not just the objects references as is done for an array object.

checkValueTypeback to summary
private void checkValueType(CompositeData value)

Checks the specified value's type is valid for this TabularData instance (ie value is not null, and its composite type is equal to row type).

clearback to summary
public void clear()

Implements javax.management.openmbean.TabularData.clear, java.util.Map.clear.

Removes all rows from this TabularDataSupport instance.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Returns a clone of this TabularDataSupport instance: the clone is obtained by calling super.clone(), and then cloning the underlying map. Only a shallow clone of the underlying map is made, i.e. no cloning of the indexes and row values is made as they are immutable.

containsKeyback to summary
public boolean containsKey(Object key)

Implements java.util.Map.containsKey.

Returns true if and only if this TabularData instance contains a CompositeData value (ie a row) whose index is the specified key. If key cannot be cast to a one dimension array of Object instances, this method simply returns false; otherwise it returns the result of the call to this.containsKey((Object[]) key).

Parameters
key:Object

the index value whose presence in this TabularData instance is to be tested.

Returns:boolean

true if this TabularData indexes a row value with the specified key.

containsKeyback to summary
public boolean containsKey(Object[] key)

Implements javax.management.openmbean.TabularData.containsKey.

Returns true if and only if this TabularData instance contains a CompositeData value (ie a row) whose index is the specified key. If key is null or does not conform to this TabularData instance's TabularType definition, this method simply returns false.

Parameters
key:Object[]

the index value whose presence in this TabularData instance is to be tested.

Returns:boolean

true if this TabularData indexes a row value with the specified key.

containsValueback to summary
public boolean containsValue(CompositeData value)

Implements javax.management.openmbean.TabularData.containsValue.

Returns true if and only if this TabularData instance contains the specified CompositeData value. If value is null or does not conform to this TabularData instance's row type definition, this method simply returns false.

Parameters
value:CompositeData

the row value whose presence in this TabularData instance is to be tested.

Returns:boolean

true if this TabularData instance contains the specified row value.

containsValueback to summary
public boolean containsValue(Object value)

Implements java.util.Map.containsValue.

Returns true if and only if this TabularData instance contains the specified value.

Parameters
value:Object

the row value whose presence in this TabularData instance is to be tested.

Returns:boolean

true if this TabularData instance contains the specified row value.

entrySetback to summary
public Set<Map.Entry<Object, Object>> entrySet()

Implements java.util.Map.entrySet.

Returns a collection view of the index to row mappings contained in this TabularDataSupport instance. Each element in the returned collection is a Map.Entry<List<?>,CompositeData> but is declared as a Map.Entry<Object,Object> for compatibility reasons. Each of the map entry keys is an unmodifiable List<?>. The collection is backed by the underlying map of this TabularDataSupport instance, so changes to the TabularDataSupport instance are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator#remove, Collection#remove, Collection#removeAll, Collection#retainAll, and Collection#clear operations. It does not support the Collection#add or Collection#addAll operations.

IMPORTANT NOTICE: Do not use the setValue method of the Map.Entry elements contained in the returned collection view. Doing so would corrupt the index to row mappings contained in this TabularDataSupport instance.

Returns:Set<Map.Entry<Object, Object>>

a collection view (Set<Map.Entry<List<?>,CompositeData>>) of the mappings contained in this map.

See Also
java.util.Map.Entry
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Implements javax.management.openmbean.TabularData.equals, java.util.Map.equals.

Compares the specified obj parameter with this TabularDataSupport instance for equality.

Returns true if and only if all of the following statements are true:

  • obj is non null,
  • obj also implements the TabularData interface,
  • their tabular types are equal
  • their contents (ie all CompositeData values) are equal.
This ensures that this equals method works properly for obj parameters which are different implementations of the TabularData interface.
 
Parameters
obj:Object

the object to be compared for equality with this TabularDataSupport instance;

Returns:boolean

true if the specified object is equal to this TabularDataSupport instance.

getback to summary
public Object get(Object key)

Implements java.util.Map.get.

This method simply calls get((Object[]) key).

Exceptions
NullPointerException:
if the key is null
ClassCastException:
if the key is not of the type Object[]
InvalidKeyException:
if the key does not conform to this TabularData instance's TabularType definition
getback to summary
public CompositeData get(Object[] key)

Implements javax.management.openmbean.TabularData.get.

Returns the CompositeData value whose index is key, or null if there is no value mapping to key, in this TabularData instance.

Parameters
key:Object[]

the index of the value to get in this TabularData instance; must be valid with this TabularData instance's row type definition; must not be null.

Returns:CompositeData

the value corresponding to key.

Exceptions
NullPointerException:
if the key is null
InvalidKeyException:
if the key does not conform to this TabularData instance's TabularType type definition.
getTabularTypeback to summary
public TabularType getTabularType()

Implements javax.management.openmbean.TabularData.getTabularType.

Returns the tabular type describing this TabularData instance.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements javax.management.openmbean.TabularData.hashCode, java.util.Map.hashCode.

Returns the hash code value for this TabularDataSupport instance.

The hash code of a TabularDataSupport instance is the sum of the hash codes of all elements of information used in equals comparisons (ie: its tabular type and its content, where the content is defined as all the CompositeData values).

This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two TabularDataSupport instances t1 and t2, as required by the general contract of the method Object.hashCode().

However, note that another instance of a class implementing the TabularData interface may be equal to this TabularDataSupport instance as defined by equals, but may have a different hash code if it is calculated differently.

Returns:int

the hash code value for this TabularDataSupport instance

internalCalculateIndexback to summary
private List<?> internalCalculateIndex(CompositeData value)

Returns the index for value, assuming value is valid for this TabularData instance (ie value is not null, and its composite type is equal to row type). The index is a List, and not an array, so that an index.equals(otherIndex) call will actually compare contents, not just the objects references as is done for an array object. The returned List is unmodifiable so that once a row has been put into the dataMap, its index cannot be modified, for example by a user that would attempt to modify an index contained in the Set returned by keySet().

internalPutback to summary
private CompositeData internalPut(CompositeData value)
isEmptyback to summary
public boolean isEmpty()

Implements javax.management.openmbean.TabularData.isEmpty, java.util.Map.isEmpty.

Returns true if this TabularDataSupport instance contains no rows.

Returns:boolean

true if this TabularDataSupport instance contains no rows.

keySetback to summary
public Set<Object> keySet()

Implements javax.management.openmbean.TabularData.keySet, java.util.Map.keySet.

Returns a set view of the keys contained in the underlying map of this TabularDataSupport instance used to index the rows. Each key contained in this Set is an unmodifiable List<?> so the returned set view is a Set<List<?>> but is declared as a Set<Object> for compatibility reasons. The set is backed by the underlying map of this TabularDataSupport instance, so changes to the TabularDataSupport instance are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding row from this TabularDataSupport instance, via the Iterator#remove, Set#remove, Set#removeAll, Set#retainAll, and Set#clear operations. It does not support the Set#add or Set#addAll operations.

Returns:Set<Object>

a set view (Set<List<?>>) of the keys used to index the rows of this TabularDataSupport instance.

putback to summary
public Object put(Object key, Object value)

Implements java.util.Map.put.

This method simply calls put((CompositeData) value) and therefore ignores its key parameter which can be null.

Parameters
key:Object

an ignored parameter.

value:Object

the CompositeData to put.

Returns:Object

the value which is put

Exceptions
NullPointerException:
if the value is null
ClassCastException:
if the value is not of the type CompositeData
InvalidOpenTypeException:
if the value does not conform to this TabularData instance's TabularType definition
KeyAlreadyExistsException:
if the key for the value parameter, calculated according to this TabularData instance's TabularType definition already maps to an existing value
putback to summary
public void put(CompositeData value)

Implements javax.management.openmbean.TabularData.put.

Doc from javax.management.openmbean.TabularData.put.

Adds value to this TabularData instance. The composite type of value must be the same as this instance's row type (ie the composite type returned by this.getTabularType().getRowType()), and there must not already be an existing value in this TabularData instance whose index is the same as the one calculated for the value to be added. The index for value is calculated according to this TabularData instance's TabularType definition (see TabularType.getIndexNames()).

putAllback to summary
public void putAll(Map<?, ?> t)

Implements java.util.Map.putAll.

Add all the values contained in the specified map t to this TabularData instance. This method converts the collection of values contained in this map into an array of CompositeData values, if possible, and then call the method putAll(CompositeData[]). Note that the keys used in the specified map t are ignored. This method allows, for example to add the content of another TabularData instance with the same row type (but possibly different index names) into this instance.

Parameters
t:Map<?, ?>

the map whose values are to be added as new rows to this TabularData instance; if t is null or empty, this method returns without doing anything.

Exceptions
NullPointerException:
if a value in t is null.
ClassCastException:
if a value in t is not an instance of CompositeData.
InvalidOpenTypeException:
if a value in t does not conform to this TabularData instance's row type definition.
KeyAlreadyExistsException:
if the index for a value in t, calculated according to this TabularData instance's TabularType definition already maps to an existing value in this instance, or two values in t have the same index.
putAllback to summary
public void putAll(CompositeData[] values)

Implements javax.management.openmbean.TabularData.putAll.

Add all the elements in values to this TabularData instance. If any element in values does not satisfy the constraints defined in put, or if any two elements in values have the same index calculated according to this TabularData instance's TabularType definition, then an exception describing the failure is thrown and no element of values is added, thus leaving this TabularData instance unchanged.

Parameters
values:CompositeData[]

the array of composite data values to be added as new rows to this TabularData instance; if values is null or empty, this method returns without doing anything.

Exceptions
NullPointerException:
if an element of values is null
InvalidOpenTypeException:
if an element of values does not conform to this TabularData instance's row type definition (ie its TabularType definition)
KeyAlreadyExistsException:
if the index for an element of values, calculated according to this TabularData instance's TabularType definition already maps to an existing value in this instance, or two elements of values have the same index
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException

Deserializes a TabularDataSupport from an ObjectInputStream.

removeback to summary
public Object remove(Object key)

Implements java.util.Map.remove.

This method simply calls remove((Object[]) key).

Parameters
key:Object

an Object[] representing the key to remove.

Returns:Object

previous value associated with specified key, or null if there was no mapping for key.

Exceptions
NullPointerException:
if the key is null
ClassCastException:
if the key is not of the type Object[]
InvalidKeyException:
if the key does not conform to this TabularData instance's TabularType definition
removeback to summary
public CompositeData remove(Object[] key)

Implements javax.management.openmbean.TabularData.remove.

Removes the CompositeData value whose index is key from this TabularData instance, and returns the removed value, or returns null if there is no value whose index is key.

Parameters
key:Object[]

the index of the value to get in this TabularData instance; must be valid with this TabularData instance's row type definition; must not be null.

Returns:CompositeData

previous value associated with specified key, or null if there was no mapping for key.

Exceptions
NullPointerException:
if the key is null
InvalidKeyException:
if the key does not conform to this TabularData instance's TabularType definition
sizeback to summary
public int size()

Implements javax.management.openmbean.TabularData.size, java.util.Map.size.

Returns the number of rows in this TabularDataSupport instance.

Returns:int

the number of rows in this TabularDataSupport instance.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements javax.management.openmbean.TabularData.toString.

Returns a string representation of this TabularDataSupport instance.

The string representation consists of the name of this class (ie javax.management.openmbean.TabularDataSupport), the string representation of the tabular type of this instance, and the string representation of the contents (ie list the key=value mappings as returned by a call to dataMap.toString()).

Returns:String

a string representation of this TabularDataSupport instance

valuesback to summary
public Collection<Object> values()

Implements javax.management.openmbean.TabularData.values, java.util.Map.values.

Returns a collection view of the rows contained in this TabularDataSupport instance. The returned Collection is a Collection<CompositeData> but is declared as a Collection<Object> for compatibility reasons. The returned collection can be used to iterate over the values. The collection is backed by the underlying map, so changes to the TabularDataSupport instance are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding index to row mapping from this TabularDataSupport instance, via the Iterator#remove, Collection#remove, Collection#removeAll, Collection#retainAll, and Collection#clear operations. It does not support the Collection#add or Collection#addAll operations.

Returns:Collection<Object>

a collection view (Collection<CompositeData>) of the values contained in this TabularDataSupport instance.