com.sun.jts.trace
Class TraceUtil

java.lang.Object
  extended by com.sun.jts.trace.TraceUtil

public class TraceUtil
extends java.lang.Object

This class is used to set trace properties and print trace statements. The print method does the printing. All the methods are unsynchronized. Since setting of properties doesn't happen simultaneously with print in current usage, this is fine. The tracing should be enabled/disabled by calling Configuration.enableTrace()/disableTrace() prior to any operation on TraceUtil. It uses TraceRecordFormatter for formatting the trace record.

Version:
1.0
Author:
Kannan Srinivasan

Constructor Summary
TraceUtil()
           
 
Method Summary
static int getCurrentTraceLevel()
          Gets the current trace level.
static char getFieldDelimiter()
          Gets the current field delimiter used in formatting trace record.
static java.lang.String getTraceRecordTag()
          Gets the current trace record tag used in formatting of trace record.
static java.io.PrintWriter getTraceWriter()
          Gets the current output writer.
static java.lang.String getXAExceptionInfo(XAException exception, java.util.logging.Logger logger)
          Returns details about Oracle XAException if available.
static void init(java.io.PrintWriter traceWriter)
          Initialises the trace class with given output writer.
static void print(int traceLevel, java.lang.Object tid, java.lang.Object origin, java.lang.String msg)
          This method formats and writes the trace record to current output writer.
static void print(int traceLevel, java.lang.Object origin, java.lang.String msg)
          This method formats and writes the trace record to current output writer.
static void print(int traceLevel, java.io.PrintWriter outWriter, java.lang.Object tid, java.lang.Object origin, java.lang.String msg)
          This method formats and writes the trace record to output writer.
static void setCurrentTraceLevel(int traceLevel)
          Sets the current trace level.
static void setFieldDelimiter(char delimiter)
          Sets the current field delimiter.
static void setTraceRecordTag(java.lang.String traceRecordTag)
          Sets the trace record tag.
static void setTraceWriter(java.io.PrintWriter traceWriter)
          Sets the output writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TraceUtil

public TraceUtil()
Method Detail

init

public static void init(java.io.PrintWriter traceWriter)
Initialises the trace class with given output writer.

Parameters:
traceWriter - an PrintWriter value

setTraceWriter

public static void setTraceWriter(java.io.PrintWriter traceWriter)
Sets the output writer. By default the output writer is set to Stdout.

Parameters:
traceWriter - an PrintWriter value

getTraceWriter

public static java.io.PrintWriter getTraceWriter()
Gets the current output writer.

Returns:
an PrintWriter value

getCurrentTraceLevel

public static int getCurrentTraceLevel()
Gets the current trace level. Returns an integer as per the TraceLevel constants.

Returns:
an int value

setCurrentTraceLevel

public static void setCurrentTraceLevel(int traceLevel)
                                 throws InvalidTraceLevelException
Sets the current trace level. The argument is tested for its validity and trace level is set. Else an exception is raised.

Parameters:
traceLevel - an int value
Throws:
InvalidTraceLevelException - if an error occurs

print

public static void print(int traceLevel,
                         java.io.PrintWriter outWriter,
                         java.lang.Object tid,
                         java.lang.Object origin,
                         java.lang.String msg)
This method formats and writes the trace record to output writer. The method is called with a tracelevel, which is checked with current trace level and if found equal or higher, the print is carried out. This method takes an PrintWriter also, which is used to write the output. This given outputWriter would override the set outputWriter. The origin object is printed using its toString() method.

Parameters:
traceLevel - an int value
outWriter - an PrintWriter value
tid - an Object value
origin - an Object value
msg - a String value

print

public static void print(int traceLevel,
                         java.lang.Object origin,
                         java.lang.String msg)
This method formats and writes the trace record to current output writer. The method is called with a tracelevel, which is checked with current trace level and if found equal or higher, the print is carried out. This method doesn't take a otid and tries to recover it from current obejct asscociated with this thread

Parameters:
traceLevel - an int value
origin - an Object value
msg - a String value

print

public static void print(int traceLevel,
                         java.lang.Object tid,
                         java.lang.Object origin,
                         java.lang.String msg)
This method formats and writes the trace record to current output writer. The method is called with a tracelevel, which is checked with current trace level and if found equal or higher, the print is carried out. This uses the currently set output writer to write the trace output.

Parameters:
traceLevel - an int value
tid - an Object value
origin - an Object value
msg - a String value

getFieldDelimiter

public static char getFieldDelimiter()
Gets the current field delimiter used in formatting trace record. The default is ':'.

Returns:
a char value

setFieldDelimiter

public static void setFieldDelimiter(char delimiter)
Sets the current field delimiter.

Parameters:
delimiter - a char value

getTraceRecordTag

public static java.lang.String getTraceRecordTag()
Gets the current trace record tag used in formatting of trace record. The default is 'iAS_JTS_Trace> '.

Returns:
a String value

setTraceRecordTag

public static void setTraceRecordTag(java.lang.String traceRecordTag)
Sets the trace record tag.

Parameters:
traceRecordTag - a String value

getXAExceptionInfo

public static java.lang.String getXAExceptionInfo(XAException exception,
                                                  java.util.logging.Logger logger)
Returns details about Oracle XAException if available. Returns an default message if it is not Oracle XAException

Parameters:
exception - an XAException to get info from
logger - the Logger to use to report errors extracting the data
Returns:
a String value


Copyright © 2012 GlassFish Community. All Rights Reserved.