org.norther.tammi.core.base
Class AttributeSupport

java.lang.Object
  extended by org.norther.tammi.core.base.AttributeSupport
All Implemented Interfaces:
Serializable

public class AttributeSupport
extends Object
implements Serializable

A support class for maintaining MBean attributes.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
AttributeSupport(MBeanDelegate adapter)
          Constructs a new attribute support.
 
Method Summary
 boolean addAttributeValue(String name, String type, Collection c, int index, Object value)
          Adds a multi-valued attribute value at the specified position.
 boolean addAttributeValue(String name, String type, Collection c, Object value)
          Adds a multi-valued attribute value.
 boolean addAttributeValue(String name, String type, ConcurrentMap map, Object key, Object value)
          Adds a multi-valued key attribute value.
 boolean addAttributeValue(String name, String type, ConcurrentMap map, String key, int index, Object value)
          Adds a multi-valued key attribute value at the specified position.
 int attributeIndexOf(Object[] values, Object value)
          Returns index of a multi-valued attribute value.
 Set attributeKeySet(ConcurrentMap map)
          Returns a read-only set of attribute keys.
 Set attributeKeySet(ConcurrentMap map, String prefix)
          Returns a read-only set of prefixed attribute keys.
 Object[] clearAttribute(String name, String type, Collection c)
          Clears a multi-valued attribute.
 Object[] clearAttribute(String name, String type, ConcurrentMap map, Object key)
          Clears a multi-valued key attribute.
 boolean clearAttributes(String name, String type, ConcurrentMap map)
          Clears all key attributes.
 boolean clearAttributes(String name, String type, ConcurrentMap map, String prefix)
          Clears prefixed key attributes.
 boolean containsAttribute(ConcurrentMap map, Object key)
          Checks a key attribute.
 Object getAttributeValue(ConcurrentMap map, Object key)
          Gets the value of a key attribute.
 Object[] getAttributeValues(Collection c, boolean clone)
          Gets values of a multi-valued attribute.
 Object[] getAttributeValues(ConcurrentMap map, Object key, boolean clone)
          Gets values of a multi-valued key attribute.
 Object removeAttribute(String name, String type, ConcurrentMap map, Object key)
          Removes a key attribute.
 Object removeAttributeValue(String name, String type, Collection c, int index)
          Removes an indexed multi-valued attribute value.
 boolean removeAttributeValue(String name, String type, Collection c, Object value)
          Removes a multi-valued attribute value.
 Object removeAttributeValue(String name, String type, ConcurrentMap map, Object key, int index)
          Removes an indexed multi-valued attribute value.
 boolean removeAttributeValue(String name, String type, ConcurrentMap map, Object key, Object value)
          Removes a multi-valued key attribute value.
 Object setAttributeValue(String name, String type, ConcurrentMap map, Object key, Object value)
          Sets the value of a key attribute.
 void setAttributeValue(String name, String type, ConcurrentMap map, String key, int index, Object value)
          Sets a multi-valued key attribute value at the specified position.
 void setAttributeValue(String name, String type, List l, int index, Object value)
          Sets a multi-valued attribute value at the specified position.
 boolean setAttributeValue(String name, String type, OrderedMap map, int index, Object key, Object value)
          Sets an indexed value for a key attribute.
 boolean setAttributeValueIfAbsent(String name, String type, ConcurrentMap map, Object key, Object value)
          Sets a missing value for a key attribute.
 Object[] setAttributeValues(String name, String type, Collection c, Object[] values)
          Sets values of a multi-valued attribute.
 void setAttributeValues(String name, String type, ConcurrentMap map, Map values)
          Sets the values of key attributes.
 Object[] setAttributeValues(String name, String type, ConcurrentMap map, Object key, Object[] values)
          Sets values of a multi-valued key attribute.
 void setAttributeValuesIfAbsent(String name, String type, ConcurrentMap map, Map values)
          Sets missing values of key attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeSupport

public AttributeSupport(MBeanDelegate adapter)
Constructs a new attribute support.

Parameters:
adapter - the adapter MBean.
Method Detail

attributeIndexOf

public int attributeIndexOf(Object[] values,
                            Object value)
Returns index of a multi-valued attribute value.

Parameters:
values - attribute values.
value - the searched value.
Returns:
the index of the value or -1 if not found.

getAttributeValues

public Object[] getAttributeValues(Collection c,
                                   boolean clone)
Gets values of a multi-valued attribute.

Parameters:
c - the attribute collection.
clone - return a cloned array if true.
Returns:
an array of attribute values or an empty list.

setAttributeValues

public Object[] setAttributeValues(String name,
                                   String type,
                                   Collection c,
                                   Object[] values)
Sets values of a multi-valued attribute.

Parameters:
name - the attribute name.
type - the attribute type.
c - the attribute collection.
values - the attribute values.
Returns:
the previous values or null.

setAttributeValue

public void setAttributeValue(String name,
                              String type,
                              List l,
                              int index,
                              Object value)
Sets a multi-valued attribute value at the specified position.

Parameters:
name - the attribute name.
type - the attribute type.
l - the attribute list.
index - the index of the attribute.
value - the attribute value.

addAttributeValue

public boolean addAttributeValue(String name,
                                 String type,
                                 Collection c,
                                 Object value)
Adds a multi-valued attribute value.

Parameters:
name - the attribute name.
type - the attribute type.
c - the attribute collection.
value - the attribute value.
Returns:
true if accepted, false otherwise.

addAttributeValue

public boolean addAttributeValue(String name,
                                 String type,
                                 Collection c,
                                 int index,
                                 Object value)
Adds a multi-valued attribute value at the specified position.

Parameters:
name - the attribute name.
type - the attribute type.
c - the attribute collection.
index - the index of the attribute.
value - the attribute value.
Returns:
true if accepted, false otherwise.

removeAttributeValue

public boolean removeAttributeValue(String name,
                                    String type,
                                    Collection c,
                                    Object value)
Removes a multi-valued attribute value.

Parameters:
name - the attribute name.
type - the attribute type.
c - the attribute collection.
value - the attribute value.
Returns:
true if removed, false otherwise.

removeAttributeValue

public Object removeAttributeValue(String name,
                                   String type,
                                   Collection c,
                                   int index)
Removes an indexed multi-valued attribute value.

Parameters:
name - the attribute name.
type - the attribute type.
c - the attribute collection.
index - the index of the attribute.
Returns:
the removed value or null.

clearAttribute

public Object[] clearAttribute(String name,
                               String type,
                               Collection c)
Clears a multi-valued attribute.

Parameters:
name - the attribute name.
type - the attribute type.
c - the attribute collection.
Returns:
the cleared values or null.

setAttributeValues

public void setAttributeValues(String name,
                               String type,
                               ConcurrentMap map,
                               Map values)
Sets the values of key attributes.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
values - the attribute values.

setAttributeValuesIfAbsent

public void setAttributeValuesIfAbsent(String name,
                                       String type,
                                       ConcurrentMap map,
                                       Map values)
Sets missing values of key attributes.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
values - the attribute values.

containsAttribute

public boolean containsAttribute(ConcurrentMap map,
                                 Object key)
Checks a key attribute.

Parameters:
map - the attribute map.
key - the attribute key.
Returns:
true if defined, false otherwise.

getAttributeValue

public Object getAttributeValue(ConcurrentMap map,
                                Object key)
Gets the value of a key attribute.

Parameters:
map - the attribute map.
key - the attribute key.
Returns:
the attribute value or null.

setAttributeValue

public Object setAttributeValue(String name,
                                String type,
                                ConcurrentMap map,
                                Object key,
                                Object value)
Sets the value of a key attribute.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
value - the attribute value.
Returns:
the previous value or null.

setAttributeValueIfAbsent

public boolean setAttributeValueIfAbsent(String name,
                                         String type,
                                         ConcurrentMap map,
                                         Object key,
                                         Object value)
Sets a missing value for a key attribute.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
value - the attribute value.
Returns:
true if added , false otherwise.

setAttributeValue

public boolean setAttributeValue(String name,
                                 String type,
                                 OrderedMap map,
                                 int index,
                                 Object key,
                                 Object value)
Sets an indexed value for a key attribute.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
index - the attribute index.
key - the attribute key.
value - the attribute value.
Returns:
true if added , false otherwise.

removeAttribute

public Object removeAttribute(String name,
                              String type,
                              ConcurrentMap map,
                              Object key)
Removes a key attribute.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
Returns:
the removed value or null.

getAttributeValues

public Object[] getAttributeValues(ConcurrentMap map,
                                   Object key,
                                   boolean clone)
Gets values of a multi-valued key attribute.

Parameters:
map - the attribute map.
key - the attribute key.
clone - return a cloned array if true.
Returns:
an array of attribute values or null.

setAttributeValues

public Object[] setAttributeValues(String name,
                                   String type,
                                   ConcurrentMap map,
                                   Object key,
                                   Object[] values)
Sets values of a multi-valued key attribute.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
values - the attribute values.
Returns:
the previous values.

setAttributeValue

public void setAttributeValue(String name,
                              String type,
                              ConcurrentMap map,
                              String key,
                              int index,
                              Object value)
Sets a multi-valued key attribute value at the specified position.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
index - the index of the attribute.
value - the attribute value.

addAttributeValue

public boolean addAttributeValue(String name,
                                 String type,
                                 ConcurrentMap map,
                                 Object key,
                                 Object value)
Adds a multi-valued key attribute value.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
value - the attribute value.
Returns:
true if accepted, false otherwise.

addAttributeValue

public boolean addAttributeValue(String name,
                                 String type,
                                 ConcurrentMap map,
                                 String key,
                                 int index,
                                 Object value)
Adds a multi-valued key attribute value at the specified position.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
index - the index of the attribute.
value - the attribute value.
Returns:
true if accepted, false otherwise.

removeAttributeValue

public boolean removeAttributeValue(String name,
                                    String type,
                                    ConcurrentMap map,
                                    Object key,
                                    Object value)
Removes a multi-valued key attribute value.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
value - the attribute value.
Returns:
true if removed, false if already missing.

removeAttributeValue

public Object removeAttributeValue(String name,
                                   String type,
                                   ConcurrentMap map,
                                   Object key,
                                   int index)
Removes an indexed multi-valued attribute value.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
index - the index of the value.
Returns:
the removed value or null.

clearAttribute

public Object[] clearAttribute(String name,
                               String type,
                               ConcurrentMap map,
                               Object key)
Clears a multi-valued key attribute.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
key - the attribute key.
Returns:
the removed values or null.

clearAttributes

public boolean clearAttributes(String name,
                               String type,
                               ConcurrentMap map)
Clears all key attributes.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
Returns:
true if cleared, false if already empty.

clearAttributes

public boolean clearAttributes(String name,
                               String type,
                               ConcurrentMap map,
                               String prefix)
Clears prefixed key attributes.

Parameters:
name - the attribute name.
type - the attribute type.
map - the attribute map.
prefix - the attribute prefix.
Returns:
true if cleared, false if already empty.

attributeKeySet

public Set attributeKeySet(ConcurrentMap map)
Returns a read-only set of attribute keys.

Parameters:
map - the attribute map.
Returns:
a set of attribute keys or an empty set.

attributeKeySet

public Set attributeKeySet(ConcurrentMap map,
                           String prefix)
Returns a read-only set of prefixed attribute keys.

Parameters:
map - the attribute map.
prefix - the attribute prefix.
Returns:
a set of attribute keys or an empty set.


Copyright © 2004 The Norther Organization. All rights reserved.