- java.lang.Object
-
- com.ibm.jvm.format.Util
-
public final class Util extends Object
Provides various utility functions needed by the trace formatter
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
BYTE
protected static BigInteger
HOURS2DAYS
protected static int
INT
protected static int
LONG
protected static BigInteger
MILLION
protected static BigInteger
MILLIS2SECONDS
protected static BigInteger
MINUTES2HOURS
protected static BigInteger
SECONDS2MINUTES
protected static String
SUM_TAB
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static String
constructString(byte[] data, int offset)
Constructs a string from an array of bytes, encoding is as specified in the propertiesprotected static 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 propertiesprotected static 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).protected static String
constructString(byte[] data, int offset, String enc)
Constructs a string from an array of bytes, with the specified encoding (ASCII or EBCDIC?)protected static int
constructTraceID(byte[] data, int offset)
protected static int
constructUnsignedByte(byte[] data, int offset)
protected static long
constructUnsignedInt(byte[] data, int offset)
protected static BigInteger
constructUnsignedLong(byte[] data, int offset)
Construct a BigInteger from an array of bytes.protected static BigInteger
constructUnsignedLong(byte[] data, int offset, int numBytes)
Construct a BigInteger from an array of bytes.protected static String
convertAndCheckEyecatcher(int eyecatcher)
protected static int
convertEndian(int in)
static String
escapeControlCharacters(String string)
Escapes control characters in the given string.static String
escapeControlCharacters(String string, String encoding)
Escapes control characters in the given string.protected static boolean
findComponentAndType(String comp, String type)
determines if a particular component and type is to be formattedprotected static boolean
findThreadID(Long threadID)
retrieve whether of not the given id is in a hashtable.static 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.protected static String
getProperty(String key)
gets an the value property that affecting behavior of the formatterprotected static 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 returnedprotected static void
initStatics()
Initializes static variables.protected static void
padBuffer(StringBuffer sb, int i, char c)
protected static void
padBuffer(StringBuffer sb, int i, char c, boolean leftJustified)
protected static void
putComponent(String comp)
puts a component name into a hashtable telling the formatter that this component is one that should be traced.protected static 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.protected static void
putThreadID(Long threadID)
puts a thread ID into a hashtable telling the formatter that this thread ID is one that should be tracedprotected static void
setBigEndian(boolean endian)
protected static void
setProperty(String key, String val)
sets an property that affects the behavior of the formatter
-
-
-
Field Detail
-
BYTE
protected static final int BYTE
- See Also:
- Constant Field Values
-
INT
protected static final int INT
- See Also:
- Constant Field Values
-
LONG
protected static final int LONG
- See Also:
- Constant Field Values
-
SUM_TAB
protected static final String SUM_TAB
- See Also:
- Constant Field Values
-
MILLIS2SECONDS
protected static final BigInteger MILLIS2SECONDS
-
SECONDS2MINUTES
protected static final BigInteger SECONDS2MINUTES
-
MINUTES2HOURS
protected static final BigInteger MINUTES2HOURS
-
HOURS2DAYS
protected static final BigInteger HOURS2DAYS
-
MILLION
protected static final BigInteger MILLION
-
-
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 jvmtypes
- 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 jvmtypes
- 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 bytesoffset
- 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 bytesoffset
- offset to the first byte to use to create the BigIntegernumBytes
- 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)
-
-