Methods Summary |
---|
public static java.lang.String | capitalize(java.lang.String name)Returns a String which capitalizes the first letter of the string.
if (name == null || name.length() == 0) {
return name;
}
return name.substring(0, 1).toUpperCase() + name.substring(1);
|
public void | clear()Clears the name cache. Should be called to near the end of
the encoding cycle.
valueToName.clear();
nameToCount.clear();
|
public java.lang.String | instanceName(java.lang.Object instance)Returns a unique string which identifies the object instance.
Invocations are cached so that if an object has been previously
passed into this method then the same identifier is returned.
if (instance == null) {
return "null";
}
if (instance instanceof Class) {
return unqualifiedClassName((Class)instance);
}
else {
String result = (String)valueToName.get(instance);
if (result != null) {
return result;
}
Class type = instance.getClass();
String className = unqualifiedClassName(type);
Object size = nameToCount.get(className);
int instanceNumber = (size == null) ? 0 : ((Integer)size).intValue() + 1;
nameToCount.put(className, new Integer(instanceNumber));
result = className + instanceNumber;
valueToName.put(instance, result);
return result;
}
|
public static java.lang.String | unqualifiedClassName(java.lang.Class type)Returns the root name of the class.
if (type.isArray()) {
return unqualifiedClassName(type.getComponentType())+"Array";
}
String name = type.getName();
return name.substring(name.lastIndexOf('.")+1);
|