/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
* WBN -- generic mechanism for simulating toString() and equals()
* for any class
*/
//
public class ObjectAnalyzer
{
/**
* @param className
* @return */
{
try
{
return getMethods(clazz, false);
}
catch(Exception e)
{
}
}
////////////////////////////////////////////////////////////////////////////
/**
* @param obj
* @return */
{
return getMethods(obj, false);
}
////////////////////////////////////////////////////////////////////////////
/**
* @param obj
* @param settersOnly
* @return */
{
try
{
}
catch(Exception e)
{
return e.getMessage();
}
}
////////////////////////////////////////////////////////////////////////////
/**
* @param clazz
* @param settersOnly
* @return */
{
{
if(settersOnly && isSetter == false)
continue;
s = s + m.toString() + '\n';
}
return s;
}
////////////////////////////////////////////////////////////////////////////
/**
* @param obj
* @return */
{
return getMethods(obj, true);
}
////////////////////////////////////////////////////////////////////////////
/**
* @param clazz
* @return */
{
return getMethods(clazz, true);
}
////////////////////////////////////////////////////////////////////////////
/**
* @param obj
* @return */
{
}
////////////////////////////////////////////////////////////////////////////
/**
* @param obj
* @return */
{
}
////////////////////////////////////////////////////////////////////////////
/**
* @param a
* @param b
* @return */
{
return false;
{
try
{
return false;
}
catch(IllegalAccessException e)
{
return false;
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////
public static void useShortClassNames()
{
useShortClassNames_ = true;
}
////////////////////////////////////////////////////////////////////////////
public static void useLongClassNames()
{
useShortClassNames_ = false;
}
////////////////////////////////////////////////////////////////////////////
{
try
{
}
catch(ObjectAnalyzerException e)
{
return e.getMessage();
}
}
////////////////////////////////////////////////////////////////////////////
{
throw new ObjectAnalyzerException(fatal + "Object parameter is not really a java.lang.Object");//NOI18N
return cl;
}
////////////////////////////////////////////////////////////////////////////
{
return sc;
}
////////////////////////////////////////////////////////////////////////////
private static FieldInfoVector getFieldInfo(Object obj, boolean doSuperClasses) throws ObjectAnalyzerException
{
if(doSuperClasses == false)
{
return fiv;
}
for(Class theClass = cl; theClass != null && !theClass.equals(Object.class); theClass = safeGetSuperclass(theClass))
return fiv;
}
////////////////////////////////////////////////////////////////////////////
private static void getFieldInfo(Class cl, Object obj, FieldInfoVector fiv) throws ObjectAnalyzerException
{
try
{
}
catch(SecurityException e)
{
throw new ObjectAnalyzerException("got a SecurityException when calling getDeclaredFields() on " + cl.getName());//NOI18N
}
throw new ObjectAnalyzerException("calling getDeclaredFields() on " + cl.getName() + " returned null");//NOI18N
{
try
{
else
}
catch (IllegalAccessException e)
{
}
}
}
////////////////////////////////////////////////////////////////////////////
{
if(setAccessibleMethod == null)
return; // Must be pre JDK 1.2.x
try
{
}
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...
try
{
}
catch(ClassNotFoundException e)
{
Logger.getAnonymousLogger().info("Can't find java.lang.reflect.AccessibleObject -- thus I can't show any private or protected variable values. This must be pre JDK 1.2.x");//NOI18N
return;
}
{
{
setAccessibleMethod = m;
break;
}
}
}
////////////////////////////////////////////////////////////////////////////
private static boolean useShortClassNames_ = true;
static
{
}
////////////////////////////////////////////////////////////////////////////
/**
* @param args */
{
}
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
{
{
super(s);
}
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
class FieldInfo
{
//Class clazz;
{
className = c;
field = f;
value = v;
modifiers = m;
}
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
{
{
v = new Vector();
}
////////////////////////////////////////////////////////////////////////////
/**
* @param o */
v.addElement(o);
}
////////////////////////////////////////////////////////////////////////////
/**
* @return */
{
StringBuffer s = new StringBuffer();
//s.append("classNameLength: " + classNameLength + "fieldNameLength: " + fieldNameLength + "modifiersLength: " + modifiersLength + "\n\n");//NOI18N
for(int i = 0; i < veclen; i++)
{
s.append('\n');
}
return s.toString();
}
////////////////////////////////////////////////////////////////////////////
{
}
////////////////////////////////////////////////////////////////////////////
private void setLongestNames()
{
classNameLength = 5;
fieldNameLength = 5;
modifiersLength = 5;
for(int i = 0; i < veclen; i++)
{
}
classNameLength += 2;
fieldNameLength += 2;
modifiersLength += 2;
}
////////////////////////////////////////////////////////////////////////////
}