Class Util


  • public final class Util
    extends Object
    Provides various utility functions needed by the trace formatter
    • Method Detail

      • initStatics

        protected static final void initStatics()
        Initializes static variables.

        This is called each time the TraceFormatter is started, from the initStatics() method in TraceFormat.java

      • putThreadID

        protected static final void putThreadID​(Long threadID)
        puts a thread ID into a hashtable telling the formatter that this thread ID is one that should be traced
        Parameters:
        threadID - a string representation of a hexidecimal thread id
      • findThreadID

        protected static final boolean findThreadID​(Long threadID)
        retrieve whether of not the given id is in a hashtable. if the table is null that means that no ids were added, since the default behavior is all id this returns true
        Parameters:
        threadID - a string representation of a hexidecimal thread id
        Returns:
        a boolean that is true if the id was added to the table or if the table is null
      • putComponent

        protected static final void putComponent​(String comp)
        puts a component name into a hashtable telling the formatter that this component is one that should be traced. In this case all types of entries are formatted for this component
        Parameters:
        comp - a string representation of a component in the jvm
      • putComponent

        protected static final void putComponent​(String comp,
                                                 Vector types)
        puts a component name into a hashtable telling the formatter that this component is one that should be traced. In this case only the types of entries specified in types are formatted for this component
        Parameters:
        comp - a string representation of a component in the jvm
        types - a vector of string for the type of trace entries to format (ie, Entry, Exit, Exception, etc)
      • findComponentAndType

        protected static final boolean findComponentAndType​(String comp,
                                                            String type)
        determines if a particular component and type is to be formatted
        Parameters:
        comp - a string representation of a component in the jvm
        types - a string for the type of trace entry to format (ie, Entry, Exit, Exception, etc)
        Returns:
        a boolean that is true if this component and type was added to the table or if the table is null
      • constructUnsignedLong

        protected static final BigInteger constructUnsignedLong​(byte[] data,
                                                                int offset)
        Construct a BigInteger from an array of bytes. BigIntegers are used to get around problems caused by the lack of unsigned primitive type.
        Parameters:
        data - an array of bytes
        offset - offset to the first byte to use to create the BigInteger
        Returns:
        a positive BigInteger constructed from the byte array
      • constructUnsignedLong

        protected static final BigInteger constructUnsignedLong​(byte[] data,
                                                                int offset,
                                                                int numBytes)
        Construct a BigInteger from an array of bytes. BigIntegers are used to get around problems caused by the lack of unsigned primitive type.
        Parameters:
        data - an array of bytes
        offset - offset to the first byte to use to create the BigInteger
        numBytes - the length of this BigInteger in bytes
        Returns:
        a positive BigInteger constructed from the byte array
      • constructTraceID

        protected static final int constructTraceID​(byte[] data,
                                                    int offset)
      • constructUnsignedInt

        protected static final long constructUnsignedInt​(byte[] data,
                                                         int offset)
      • constructUnsignedByte

        protected static final int constructUnsignedByte​(byte[] data,
                                                         int offset)
      • constructString

        protected static final String constructString​(byte[] data,
                                                      int offset)
        Constructs a string from an array of bytes, encoding is as specified in the properties
      • constructString

        protected static final String constructString​(byte[] data,
                                                      int offset,
                                                      String enc)
        Constructs a string from an array of bytes, with the specified encoding (ASCII or EBCDIC?)
      • constructString

        protected static final String constructString​(byte[] data,
                                                      int offset,
                                                      int count)
        Constructs a string from an array of bytes with a count, encoding is as specified in the properties
      • escapeControlCharacters

        public static final String escapeControlCharacters​(String string)
        Escapes control characters in the given string.
        Parameters:
        string -
      • escapeControlCharacters

        public static final String escapeControlCharacters​(String string,
                                                           String encoding)
        Escapes control characters in the given string.
        Parameters:
        string -
        encoding -
      • constructString

        protected static final String constructString​(byte[] data,
                                                      int offset,
                                                      int count,
                                                      String enc)
        Constructs a string from an array of bytes with an offset and count, with the specified encoding (ASCII or EBCDIC).
      • setProperty

        protected static final void setProperty​(String key,
                                                String val)
        sets an property that affects the behavior of the formatter
        Parameters:
        key -
        val -
      • getProperty

        protected static final String getProperty​(String key)
        gets an the value property that affecting behavior of the formatter
        Parameters:
        key -
        Returns:
        a string
      • getProperty

        protected static final String getProperty​(String key,
                                                  String defaultValue)
        gets an the value property that affecting behavior of the formatter, if no such property is set the default value is returned
        Parameters:
        key -
        defaultValue -
        Returns:
        a string
      • padBuffer

        protected static final void padBuffer​(StringBuffer sb,
                                              int i,
                                              char c)
      • padBuffer

        protected static final void padBuffer​(StringBuffer sb,
                                              int i,
                                              char c,
                                              boolean leftJustified)
      • formatAsHexString

        public static final String formatAsHexString​(long number)
        Formats a number as a hex string, prefixing the "0x" radix specifier so that it can be unambiguously interpreted as a hex string.
        Parameters:
        number - the number to format
      • convertEndian

        protected static final int convertEndian​(int in)
      • convertAndCheckEyecatcher

        protected static final String convertAndCheckEyecatcher​(int eyecatcher)
      • setBigEndian

        protected static final void setBigEndian​(boolean endian)