Methods Summary |
---|
public static boolean | equals(java.lang.Object a, java.lang.Object b)
Class cl = a.getClass();
if (!cl.equals(b.getClass()))
return false;
Field[] fields = cl.getDeclaredFields();
setAccessible(fields);
for (int i = 0; i < fields.length; i++)
{
Field f = fields[i];
try
{
if (!f.get(a).equals(f.get(b)))
return false;
}
catch(IllegalAccessException e)
{
return false;
}
}
return true;
|
private static com.sun.enterprise.config.backup.util.FieldInfoVector | getFieldInfo(java.lang.Object obj, boolean doSuperClasses)
FieldInfoVector fiv = new FieldInfoVector();
Class cl = safeGetClass(obj);
if(doSuperClasses == false)
{
getFieldInfo(cl, obj, fiv);
return fiv;
}
for(Class theClass = cl; theClass != null && !theClass.equals(Object.class); theClass = safeGetSuperclass(theClass))
getFieldInfo(theClass, obj, fiv);
return fiv;
|
private static void | getFieldInfo(java.lang.Class cl, java.lang.Object obj, com.sun.enterprise.config.backup.util.FieldInfoVector fiv)
Field[] fields = null;
try
{
fields = cl.getDeclaredFields();
}
catch(SecurityException e)
{
throw new ObjectAnalyzerException("got a SecurityException when calling getDeclaredFields() on " + cl.getName());//NOI18N
}
if(fields == null)
throw new ObjectAnalyzerException("calling getDeclaredFields() on " + cl.getName() + " returned null");//NOI18N
setAccessible(fields);
for(int i = 0; i < fields.length; i++)
{
Field f = fields[i];
String sval;
String modifiers = Modifier.toString(f.getModifiers());
String className = cl.getName();
if(useShortClassNames_)
className = StringUtils.toShortClassName(className);
if(modifiers.length() <= 0)
modifiers = "(package)";//NOI18N
try
{
Object val = f.get(obj);
if(val == null)
sval = "<null>";//NOI18N
else
sval = val.toString();
}
catch (IllegalAccessException e)
{
sval = "<IllegalAccessException>";//NOI18N
}
fiv.addElement(new FieldInfo(className, f, sval, modifiers));
}
|
public static java.lang.String | getMethods(java.lang.String className)
try
{
Class clazz = Class.forName(className);
return getMethods(clazz, false);
}
catch(Exception e)
{
return "Error loading class: " + e.getMessage();//NOI18N
}
|
public static java.lang.String | getMethods(java.lang.Object obj)
return getMethods(obj, false);
|
public static java.lang.String | getMethods(java.lang.Object obj, boolean settersOnly)
try
{
Class clazz = safeGetClass(obj);
return getMethods(clazz, settersOnly);
}
catch(Exception e)
{
return e.getMessage();
}
|
public static java.lang.String | getMethods(java.lang.Class clazz, boolean settersOnly)
String s = new String();
Method[] methods = clazz.getMethods();
for(int i = 0; i < methods.length; i++)
{
Method m = methods[i];
boolean isSetter = m.getName().startsWith("set");//NOI18N
if(settersOnly && isSetter == false)
continue;
s = s + m.toString() + '\n";
}
return s;
|
public static java.lang.String | getSetters(java.lang.Object obj)
return getMethods(obj, true);
|
public static java.lang.String | getSetters(java.lang.Class clazz)
return getMethods(clazz, true);
|
public static void | main(java.lang.String[] args)
setupSetAccessibleMethod();
String s = new String("Hello!");//NOI18N
System.out.println("Regular: \n" + toString(s) + "\n\n");//NOI18N
System.out.println("Super: \n" + toStringWithSuper(s) + "\n\n");//NOI18N
|
private static java.lang.Class | safeGetClass(java.lang.Object obj)
if(obj == null)
throw new ObjectAnalyzerException(fatal + "null Object parameter");//NOI18N
if(! (obj instanceof Object))
throw new ObjectAnalyzerException(fatal + "Object parameter is not really a java.lang.Object");//NOI18N
Class cl = obj.getClass();
if(cl == null)
throw new ObjectAnalyzerException(fatal + "getClass() on parameter Object returned null");//NOI18N
return cl;
|
private static java.lang.Class | safeGetSuperclass(java.lang.Class cl)
Class sc = cl.getSuperclass();
if(sc == null)
throw new ObjectAnalyzerException("getSuperclass() on parameter Object returned null");//NOI18N
return sc;
|
private static void | setAccessible(java.lang.reflect.Field[] fields)
if(setAccessibleMethod == null)
return; // Must be pre JDK 1.2.x
try
{
Boolean b = Boolean.valueOf(true);
setAccessibleMethod.invoke(null, new Object[] { fields, b } );
}
catch(Exception e)
{
}
|
private static void | setupSetAccessibleMethod()
// whoa! what's this reflection crap doing here?
// AccessibleObject is a JDK 1.2 class that lets you peek at
// private variable values. Since we need to support JDK 1.1
// for the VCafe plug-in -- it is now called via 100% reflection
// techniques...
setAccessibleMethod = null;
Class AO;
try
{
AO = Class.forName("java.lang.reflect.AccessibleObject");//NOI18N
}
catch(ClassNotFoundException e)
{
return;
}
Method[] methods = AO.getDeclaredMethods();
for(int i = 0; i < methods.length; i++)
{
Method m = methods[i];
if(m.getName().equals("setAccessible") && m.getParameterTypes().length == 2)//NOI18N
{
setAccessibleMethod = m;
break;
}
}
|
private static java.lang.String | toString(java.lang.Object obj, boolean doSuperClasses)
try
{
return getFieldInfo(obj, doSuperClasses).toString();
}
catch(ObjectAnalyzerException e)
{
return e.getMessage();
}
|
public static java.lang.String | toString(java.lang.Object obj)
return toString(obj, false);
|
public static java.lang.String | toStringWithSuper(java.lang.Object obj)
return toString(obj, true);
|
public static void | useLongClassNames()
useShortClassNames_ = false;
|
public static void | useShortClassNames()
useShortClassNames_ = true;
|