Package com.sun.jts.trace
Class TraceUtil
- java.lang.Object
-
- com.sun.jts.trace.TraceUtil
-
public class TraceUtil extends 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 callingConfiguration.enableTrace()/disableTrace()prior to any operation on TraceUtil. It uses TraceRecordFormatter for formatting the trace record.- Version:
- 1.0
- Author:
- Kannan Srinivasan
-
-
Constructor Summary
Constructors Constructor Description TraceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intgetCurrentTraceLevel()Gets the current trace level.static chargetFieldDelimiter()Gets the current field delimiter used in formatting trace record.static StringgetTraceRecordTag()Gets the current trace record tag used in formatting of trace record.static PrintWritergetTraceWriter()Gets the current output writer.static StringgetXAExceptionInfo(XAException exception, Logger logger)Returns details about Oracle XAException if available.static voidinit(PrintWriter traceWriter)Initialises the trace class with given output writer.static voidprint(int traceLevel, PrintWriter outWriter, Object tid, Object origin, String msg)This method formats and writes the trace record to output writer.static voidprint(int traceLevel, Object tid, Object origin, String msg)This method formats and writes the trace record to current output writer.static voidprint(int traceLevel, Object origin, String msg)This method formats and writes the trace record to current output writer.static voidsetCurrentTraceLevel(int traceLevel)Sets the current trace level.static voidsetFieldDelimiter(char delimiter)Sets the current field delimiter.static voidsetTraceRecordTag(String traceRecordTag)Sets the trace record tag.static voidsetTraceWriter(PrintWriter traceWriter)Sets the output writer.
-
-
-
Method Detail
-
init
public static void init(PrintWriter traceWriter)
Initialises the trace class with given output writer.- Parameters:
traceWriter- anPrintWritervalue
-
setTraceWriter
public static void setTraceWriter(PrintWriter traceWriter)
Sets the output writer. By default the output writer is set to Stdout.- Parameters:
traceWriter- anPrintWritervalue
-
getTraceWriter
public static PrintWriter getTraceWriter()
Gets the current output writer.- Returns:
- an
PrintWritervalue
-
getCurrentTraceLevel
public static int getCurrentTraceLevel()
Gets the current trace level. Returns an integer as per the TraceLevel constants.- Returns:
- an
intvalue
-
setCurrentTraceLevel
public static void setCurrentTraceLevel(int traceLevel) throws InvalidTraceLevelExceptionSets the current trace level. The argument is tested for its validity and trace level is set. Else an exception is raised.- Parameters:
traceLevel- anintvalue- Throws:
InvalidTraceLevelException- if an error occurs
-
print
public static void print(int traceLevel, PrintWriter outWriter, Object tid, Object origin, 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- anintvalueoutWriter- anPrintWritervaluetid- anObjectvalueorigin- anObjectvaluemsg- aStringvalue
-
print
public static void print(int traceLevel, Object origin, 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- anintvalueorigin- anObjectvaluemsg- aStringvalue
-
print
public static void print(int traceLevel, Object tid, Object origin, 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- anintvaluetid- anObjectvalueorigin- anObjectvaluemsg- aStringvalue
-
getFieldDelimiter
public static char getFieldDelimiter()
Gets the current field delimiter used in formatting trace record. The default is ':'.- Returns:
- a
charvalue
-
setFieldDelimiter
public static void setFieldDelimiter(char delimiter)
Sets the current field delimiter.- Parameters:
delimiter- acharvalue
-
getTraceRecordTag
public static String getTraceRecordTag()
Gets the current trace record tag used in formatting of trace record. The default is 'iAS_JTS_Trace> '.- Returns:
- a
Stringvalue
-
setTraceRecordTag
public static void setTraceRecordTag(String traceRecordTag)
Sets the trace record tag.- Parameters:
traceRecordTag- aStringvalue
-
getXAExceptionInfo
public static String getXAExceptionInfo(XAException exception, Logger logger)
Returns details about Oracle XAException if available. Returns an default message if it is not Oracle XAException- Parameters:
exception- anXAExceptionto get info fromlogger- theLoggerto use to report errors extracting the data- Returns:
- a
Stringvalue
-
-