Methods Summary |
---|
public static final java.util.Map | asNameMap(javax.management.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.
if (al == null) {
throw new IllegalArgumentException ("null arg");
}
final Map m = new HashMap();
final Iterator it = al.iterator();
while (it.hasNext()) {
final Attribute a = (Attribute) it.next();
m.put(a.getName(), a);
}
return ( m );
|
public static final boolean | containsNamedAttribute(javax.management.AttributeList al, java.lang.String name)Checks whether this list contains a JMX {@link Attribute} with given name. Note that
this method will return true if there is at least one attribute with given name.
if (al == null || name == null)
throw new IllegalArgumentException ("null arg");
boolean contains = false;
final Iterator it = al.iterator();
while (it.hasNext()) {
final Attribute at = (Attribute) it.next();
if (name.equals(at.getName())) { //attribute name may not be null - guaranteed
contains = true;
break;
}
}
return ( contains );
|
public static final boolean | containsNamedAttribute(javax.management.AttributeList al, javax.management.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.
if (al == null || a == null)
throw new IllegalArgumentException ("null arg");
return ( containsNamedAttribute(al, a.getName()) );
|
public static java.lang.String | dash2CamelCase(java.lang.String dashed)
/* This algorithm is obviously not accurate, as I have not written
* a generic parser/lexical analyzer, nor have I written a BNF. All it
* does is it converts Strings like abc-def-ghi to AbcDefGhi. A hyphen, if followed
* by an alphabet, will be removed and the alphabet is capitalized. No more
* complications. The passed String is converted into lower case by default.
*/
if (dashed == null)
throw new IllegalArgumentException ("Null Arg");
dashed = dashed.toLowerCase();
final ArrayList list = new ArrayList();
final StringTokenizer tz = new StringTokenizer(dashed, "-");
while (tz.hasMoreTokens()) {
list.add(tz.nextToken());
}
final String[] tmp = new String[list.size()];
final String[] strings = getCamelCaseArray((String[])list.toArray(tmp));
return ( strings2String(strings) );
|
private static java.lang.String[] | getCamelCaseArray(java.lang.String[] from)
final String[] humps = new String[from.length];
for (int i = 0 ; i < from.length ; i++) {
final StringBuffer sb = new StringBuffer(from[i]);
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
humps[i] = sb.toString();
}
return ( humps );
|
private static java.lang.String | strings2String(java.lang.String[] a)
final StringBuffer sb = new StringBuffer();
for (int i = 0 ; i < a.length ; i++) {
sb.append(a[i]);
}
return ( sb.toString() );
|
public static final java.lang.String | toJmx12Attribute(java.lang.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
'_'.
if (name == null || name.length() == 0)
throw new IllegalArgumentException ("invalid arg");
final char rc = '_";
assert (Character.isJavaIdentifierStart(rc) && Character.isJavaIdentifierPart(rc));
final char[] chars = new char[name.length()];
name.getChars(0, name.length(), chars, 0);
if (! Character.isJavaIdentifierStart(chars[0])) {
chars[0] = rc;
}
for (int i = 1 ; i < name.length() ; i++) { //note the index
if (! Character.isJavaIdentifierPart(chars[i])) {
chars[i] = rc;
}
}
return ( new String(chars) );
|
public static final java.lang.String | toString(javax.management.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'.
final StringBuffer sb = new StringBuffer();
final char SEP = ',";
final char NL = '\n";
if (al != null) {
final Iterator it = al.iterator();
while (it.hasNext()) {
final Attribute a = (Attribute) it.next();
sb.append(a.getName()).append(SEP).append(a.getValue().toString()).append(NL);
}
}
return (sb.toString());
|