wt.tools.xref
Class Util

java.lang.Object
  extended bywt.tools.xref.Util

public class Util
extends Object

This class contains a number of convenience methods used by other classes in this package.


Field Summary
(package private) static FileInputStream d_fis
          This file handle is used by the openClassFile() and closeClassFile() methods.
 
Constructor Summary
Util()
           
 
Method Summary
(package private) static String arrayBrackets(int count)
          This method is used to create a string the specified number of square bracket pairs.
static void classFileSummary(String dotStyleClassSpec)
           This method outputs a simple summary of: 1) methods defined in the class 2) fields referenced in other classes 3) methods called in other classes 4) other classes that this class is dependent on
static String cleanClassSpec(String classSpec)
          This method watches for classSpec's like: [Ljava.lang.Object [B and converts them to a more meaningful form.
static String cleanUpHrefString(String s)
          This method replaces problematic characters in strings that don't get displayed correctly within the browser WITH the appropriate HTML alternative.
(package private) static void closeClassFile()
          This method must be called after you are done processing a class file previously opened with a call to openClassFile()
static void displayClassDependencies(String directoryContainingClass, String className)
           This method displays the list of dependencies for the specified class.
(package private) static void displayStringArray(PrintWriter pw, String title, String[] array, boolean sortArray, int indentAmount)
           This method outputs the contents of an array of String's.
(package private) static void displayStringArray(String title, String[] array, boolean sortArray, int indentAmount)
           This method outputs the contents of an array of String's.
(package private) static void dumpAttributeList(ClassFile cf)
           
(package private) static void dumpAttributeList(String title, String prefix, AttrInfoList ail)
           
(package private) static void dumpConstantPool(ClassFile cf)
           
static String[] enumerationOfStringsToSortedArray(Enumeration e, int enumSize)
          This method creates an array of String's out of the specified Enumeration and then sorts the array.
(package private) static void Log(String msg)
           
(package private) static void LogError(String msg)
           
(package private) static void LogError(Throwable t, String msg)
          This method provides a convenient way of logging an exception that occurs including both the message text for the original throw and the full stack trace.
(package private) static ClassFile openClassFile(String fileName)
           This convenience method opens the specified .class file.
(package private) static String replaceChar(String theString, char ch, String replacementString)
           
static String[] splitClass(String s)
           This method takes a string like: wt.query.QuerySpec and returns: returnArray[0] = wt.query returnArray[1] = QuerySpec
static String[] splitClassMember(String s)
           This method takes a string like: wt.query.QuerySpec.someFunc() and returns: returnArray[0] = wt.query returnArray[1] = QuerySpec returnArray[2] = someFunc()
static String[] splitFullPathFileName(String fileName)
           This method takes a full path filename like: Z:\Windchill\codebase\wt\query\QuerySpec.class and splits it into two pieces: returnArray[0] = Z:\Windchill\codebase\wt\query returnArray[1] = QuerySpec.class
static String stringArrayToString(String[] array)
           
static String toFullPathClassName(String dotStyleClassSpec)
           This method converts a dot-style class specification into a full-path .class filename.
(package private) static String[] vectorOfStringsToSortedArray(Vector v)
          This method creates an array of String's out of the specified Vector and then sorts the array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

d_fis

static FileInputStream d_fis
This file handle is used by the openClassFile() and closeClassFile() methods.

Constructor Detail

Util

public Util()
Method Detail

LogError

static void LogError(String msg)

LogError

static void LogError(Throwable t,
                     String msg)
This method provides a convenient way of logging an exception that occurs including both the message text for the original throw and the full stack trace.


openClassFile

static ClassFile openClassFile(String fileName)
                        throws Exception

This convenience method opens the specified .class file.

SPECIAL NOTE: when you are done processing a class file you've opened with this method, you must call closeclassfile(), otherwise you could overflow the file handle table if you are processing very many class files.

Throws:
Exception

closeClassFile

static void closeClassFile()
This method must be called after you are done processing a class file previously opened with a call to openClassFile()


displayStringArray

static void displayStringArray(String title,
                               String[] array,
                               boolean sortArray,
                               int indentAmount)

This method outputs the contents of an array of String's. The output is preceded with the specified title and the array can be sorted if specified by the caller.

The difference between this method and the other displayStringArray() method is that this method does not require that you pass an instantiated PrintWriter.


displayStringArray

static void displayStringArray(PrintWriter pw,
                               String title,
                               String[] array,
                               boolean sortArray,
                               int indentAmount)

This method outputs the contents of an array of String's. The output is preceded with the specified title and the array can be sorted if specified by the caller.

The difference between this method and the other displayStringArray() method is that this method requires that you pass an instantiated PrintWriter.


toFullPathClassName

public static String toFullPathClassName(String dotStyleClassSpec)

This method converts a dot-style class specification into a full-path .class filename.

This method takes a dot-style class specification like: wt.query.QuerySpec and converts it to the form: Z:\Windchill\codebase\wt\query\QuerySpec.class


splitFullPathFileName

public static String[] splitFullPathFileName(String fileName)
 This method takes a full path filename like:

      Z:\Windchill\codebase\wt\query\QuerySpec.class

 and splits it into two pieces:

      returnArray[0] = Z:\Windchill\codebase\wt\query
      returnArray[1] = QuerySpec.class


classFileSummary

public static void classFileSummary(String dotStyleClassSpec)
 This method outputs a simple summary of:
 1) methods defined in the class
 2) fields referenced in other classes
 3) methods called in other classes
 4) other classes that this class is dependent on


displayClassDependencies

public static void displayClassDependencies(String directoryContainingClass,
                                            String className)
 This method displays the list of dependencies for the specified class.

 directoryContainingClass: "Z:\\windchill\\codebase\\wt\\query\\"
                className: "QuerySpec.class"


splitClass

public static String[] splitClass(String s)
 This method takes a string like: wt.query.QuerySpec
 and returns:
     returnArray[0] = wt.query
     returnArray[1] = QuerySpec


splitClassMember

public static String[] splitClassMember(String s)
 This method takes a string like: wt.query.QuerySpec.someFunc()
 and returns:
     returnArray[0] = wt.query
     returnArray[1] = QuerySpec
     returnArray[2] = someFunc()


dumpAttributeList

static void dumpAttributeList(String title,
                              String prefix,
                              AttrInfoList ail)

dumpAttributeList

static void dumpAttributeList(ClassFile cf)

dumpConstantPool

static void dumpConstantPool(ClassFile cf)

Log

static void Log(String msg)

vectorOfStringsToSortedArray

static String[] vectorOfStringsToSortedArray(Vector v)
This method creates an array of String's out of the specified Vector and then sorts the array. It is assumed that the Vector contains strings. If this is not the case, then a ClassCastException will be thrown.


enumerationOfStringsToSortedArray

public static String[] enumerationOfStringsToSortedArray(Enumeration e,
                                                         int enumSize)
This method creates an array of String's out of the specified Enumeration and then sorts the array. It is assumed that the Enumeration contains strings. If this is not the case, then a ClassCastException will be thrown.


cleanClassSpec

public static String cleanClassSpec(String classSpec)
This method watches for classSpec's like: [Ljava.lang.Object [B and converts them to a more meaningful form. See section 4.3.2 Field Descriptors in the Java Virtual Machine Specification for more information.


arrayBrackets

static String arrayBrackets(int count)
This method is used to create a string the specified number of square bracket pairs.


replaceChar

static String replaceChar(String theString,
                          char ch,
                          String replacementString)

cleanUpHrefString

public static String cleanUpHrefString(String s)
This method replaces problematic characters in strings that don't get displayed correctly within the browser WITH the appropriate HTML alternative.


stringArrayToString

public static String stringArrayToString(String[] array)