public abstract class

OpenConverter

extends Object
java.lang.Object
   ↳ com.sun.jmx.mbeanserver.OpenConverter

Class Overview

A converter between Java types and the limited set of classes defined by Open MBeans.

A Java type is an instance of java.lang.reflect.Type. For our purposes, it is either a Class, such as String.class or int.class; or a ParameterizedType, such as List or Map. On J2SE 1.4 and earlier, it can only be a Class.

Each Type is associated with an OpenConverter. The OpenConverter defines an OpenType corresponding to the Type, plus a Java class corresponding to the OpenType. For example:

   Type                     Open class     OpenType
   ----                     ----------     --------
   Integer                  Integer        SimpleType.INTEGER
   int                      int            SimpleType.INTEGER
   Integer[]                Integer[]      ArrayType(1, SimpleType.INTEGER)
   int[]                    Integer[]      ArrayType(SimpleType.INTEGER, true)
   String[][]               String[][]     ArrayType(2, SimpleType.STRING)
   List             String[]       ArrayType(1, SimpleType.STRING)
   ThreadState (an Enum)    String         SimpleType.STRING
   Map   TabularData    TabularType(
                                             CompositeType(
                                               {"key", SimpleType.INTEGER},
                                               {"value",
                                                 ArrayType(1,
                                                  SimpleType.STRING)}),
                                             indexNames={"key"})
   

Apart from simple types, arrays, and collections, Java types are converted through introspection into CompositeType. The Java type must have at least one getter (method such as "int getSize()" or "boolean isBig()"), and we must be able to deduce how to reconstruct an instance of the Java class from the values of the getters using one of various heuristics.

Summary

Public Methods
static String decapitalize(String name)
Utility method to take a string and convert it to normal Java variable name capitalization.
final Object fromOpenValue(MXBeanLookup lookup, Object value)

Convert an instance of openClass into an instance of targetType.

static String propertyName(Method m)
synchronized static OpenConverter toConverter(Type objType)
Get the converter for the given Java type, creating it if necessary.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static String decapitalize (String name)

Utility method to take a string and convert it to normal Java variable name capitalization. This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.

Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays as "URL".

Parameters
name The string to be decapitalized.
Returns
  • The decapitalized version of the string.

public final Object fromOpenValue (MXBeanLookup lookup, Object value)

Convert an instance of openClass into an instance of targetType.

public static String propertyName (Method m)

public static synchronized OpenConverter toConverter (Type objType)

Get the converter for the given Java type, creating it if necessary.