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 int
getCurrentTraceLevel()
Gets the current trace level.static char
getFieldDelimiter()
Gets the current field delimiter used in formatting trace record.static String
getTraceRecordTag()
Gets the current trace record tag used in formatting of trace record.static PrintWriter
getTraceWriter()
Gets the current output writer.static String
getXAExceptionInfo(XAException exception, Logger logger)
Returns details about Oracle XAException if available.static void
init(PrintWriter traceWriter)
Initialises the trace class with given output writer.static void
print(int traceLevel, PrintWriter outWriter, Object tid, Object origin, String msg)
This method formats and writes the trace record to output writer.static void
print(int traceLevel, Object tid, Object origin, String msg)
This method formats and writes the trace record to current output writer.static void
print(int traceLevel, Object origin, String msg)
This method formats and writes the trace record to current 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(String traceRecordTag)
Sets the trace record tag.static void
setTraceWriter(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
- anPrintWriter
value
-
setTraceWriter
public static void setTraceWriter(PrintWriter traceWriter)
Sets the output writer. By default the output writer is set to Stdout.- Parameters:
traceWriter
- anPrintWriter
value
-
getTraceWriter
public static 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
- anint
value- 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
- anint
valueoutWriter
- anPrintWriter
valuetid
- anObject
valueorigin
- anObject
valuemsg
- aString
value
-
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
- anint
valueorigin
- anObject
valuemsg
- aString
value
-
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
- anint
valuetid
- anObject
valueorigin
- anObject
valuemsg
- aString
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
- achar
value
-
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
String
value
-
setTraceRecordTag
public static void setTraceRecordTag(String traceRecordTag)
Sets the trace record tag.- Parameters:
traceRecordTag
- aString
value
-
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
- anXAException
to get info fromlogger
- theLogger
to use to report errors extracting the data- Returns:
- a
String
value
-
-