Class AttributeListUtils

java.lang.Object
com.sun.enterprise.admin.util.jmx.AttributeListUtils

public class AttributeListUtils extends Object
A class that has some useful utility methods to deal with
  • Jmx Attributes
  • Jmx AttributeLists.
It is expected to enhance this class with more utility methods.
Since:
Sun Java System Application Server 8
Author:
Kedar.Mhaswade@Sun.Com
  • Method Details

    • containsNamedAttribute

      public static boolean containsNamedAttribute(AttributeList al, String name)
      Checks whether this list contains a JMX Attribute with given name. Note that this method will return true if there is at least one attribute with given name.
      Parameters:
      al - an instance of AttributeList
      name - a String representing the name of the attribute. The name may not be null.
      Returns:
      true if there is at least one attribute in the list with given name, false otherwise
      Throws:
      IllegalArgumentException - if the attribute list or name is null
    • containsNamedAttribute

      public static boolean containsNamedAttribute(AttributeList al, Attribute a)
      Checks whether an attribute with the name same as that of the given attribute exists in this list. The given name may not be null.
      Parameters:
      al - an instance of AttributeList
      a - an Attribute with a name and a value
      Returns:
      true if there exists at least one attribute with same name, false otherwise
      Throws:
      IllegalArgumentException - if the attribute list or name is null
    • asNameMap

      public static Map asNameMap(AttributeList al)
      Returns the given list as a map of attributes, keyed on the names of the attribute in the list. The passed argument may not be null. The mappings are between the names of attributes and attributes themselves.
      Parameters:
      al - the list of attributes that need to be mapped
      Returns:
      an instance of Map
      Throws:
      IllegalArgumentException - if the argument is null
    • toJmx12Attribute

      public static String toJmx12Attribute(String name)
      JMX 1.2 specification had a weird limitation that a Dynamic MBean may not have an attribute whose name is not a valid Java identifier . This method is a utility method to convert the any arbitrary name into a String that can be a valid JMX 1.2 attribute. Every character in the string passed that is neither a Character.isJavaIdentifierStart nor a Character.isJavaIdentifierPart is replace with a valid character '_'.
      Parameters:
      name - a String that represents any non null name
      Returns:
      a String that represents a name valid for a JMX 1.2 MBean.
      Throws:
      IllegalArgumentException - if the parameter is null or is of zero length
    • toString

      public static String toString(AttributeList al)
      Returns a String representation of an attribute list such that:
      • Each attribute is a name and value separated by a ','. toString() on the value is called.
      • Each pair is separated by a new line character '\n'.
      Parameters:
      al - the list of attributes - may be null, in which case an empty String is returned.
      Returns:
      a String representing the parameter passed
    • dash2CamelCase

      public static String dash2CamelCase(String dashed)