Package org.h2.message
Class TraceObject
java.lang.Object
org.h2.message.TraceObject
- Direct Known Subclasses:
JdbcArray
,JdbcConnection
,JdbcDatabaseMetaData
,JdbcDataSource
,JdbcLob
,JdbcParameterMetaData
,JdbcResultSet
,JdbcResultSetMetaData
,JdbcSavepoint
,JdbcStatement
,JdbcXAConnection
,JdbcXid
,ValueToObjectConverter
,ValueToObjectConverter2
The base class for objects that can print trace information about themselves.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The trace type id for array objects.protected static final int
The trace type id for blobs.protected static final int
The trace type id for callable statements.protected static final int
The trace type id for clobs.protected static final int
The trace type id for connections.protected static final int
The trace type id for data sources.protected static final int
The trace type id for database meta data objects.private int
private static final AtomicIntegerArray
private static final int
protected static final int
The trace type id for parameter meta data objects.private static final String[]
protected static final int
The trace type id for prepared statements.protected static final int
The trace type id for result sets.protected static final int
The trace type id for result set meta data objects.protected static final int
The trace type id for savepoint objects.private static final SQLException
protected static final int
The trace type id for SQLXML objects.protected static final int
The trace type id for statements.protected Trace
The trace module used by this object.private int
protected static final int
The trace type id for XA data sources.protected static final int
The trace type id for transaction ids. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Write trace information in the form objectName.text.protected final void
debugCodeAssign
(String className, int newType, int newId, String value) Write trace information as an assignment in the form className prefixId = objectName.value.protected final void
debugCodeCall
(String methodName) Write trace information as a method call in the form objectName.methodName().protected final void
debugCodeCall
(String methodName, long param) Write trace information as a method call in the form objectName.methodName(param) where the parameter is formatted as a long value.protected final void
debugCodeCall
(String methodName, String param) Write trace information as a method call in the form objectName.methodName(param) where the parameter is formatted as a Java string.protected static int
getNextId
(int type) Get the next trace object id for this object type.int
INTERNALINTERNALprotected final boolean
Check if the debug trace level is enabled.protected final boolean
Check if info trace level is enabled.protected SQLException
Log an exception and convert it to a SQL exception if required.protected static String
Format a string as a Java string literal.protected static String
quoteArray
(String[] s) Format a string array to the Java source code that represents this object.protected static String
Format a big decimal to the Java source code that represents this object.protected static String
quoteBytes
(byte[] x) Format a byte array to the Java source code that represents this object.protected static String
Format a date to the Java source code that represents this object.protected static String
quoteIntArray
(int[] s) Format an int array to the Java source code that represents this object.protected static String
Format a map to the Java source code that represents this object.protected static String
Format a time to the Java source code that represents this object.protected static String
Format a timestamp to the Java source code that represents this object.protected void
Set the options to use when writing trace message.protected SQLException
unsupported
(String message) Get a SQL exception meaning this feature is not supported.
-
Field Details
-
CALLABLE_STATEMENT
protected static final int CALLABLE_STATEMENTThe trace type id for callable statements.- See Also:
-
CONNECTION
protected static final int CONNECTIONThe trace type id for connections.- See Also:
-
DATABASE_META_DATA
protected static final int DATABASE_META_DATAThe trace type id for database meta data objects.- See Also:
-
PREPARED_STATEMENT
protected static final int PREPARED_STATEMENTThe trace type id for prepared statements.- See Also:
-
RESULT_SET
protected static final int RESULT_SETThe trace type id for result sets.- See Also:
-
RESULT_SET_META_DATA
protected static final int RESULT_SET_META_DATAThe trace type id for result set meta data objects.- See Also:
-
SAVEPOINT
protected static final int SAVEPOINTThe trace type id for savepoint objects.- See Also:
-
STATEMENT
protected static final int STATEMENTThe trace type id for statements.- See Also:
-
BLOB
protected static final int BLOBThe trace type id for blobs.- See Also:
-
CLOB
protected static final int CLOBThe trace type id for clobs.- See Also:
-
PARAMETER_META_DATA
protected static final int PARAMETER_META_DATAThe trace type id for parameter meta data objects.- See Also:
-
DATA_SOURCE
protected static final int DATA_SOURCEThe trace type id for data sources.- See Also:
-
XA_DATA_SOURCE
protected static final int XA_DATA_SOURCEThe trace type id for XA data sources.- See Also:
-
XID
protected static final int XIDThe trace type id for transaction ids.- See Also:
-
ARRAY
protected static final int ARRAYThe trace type id for array objects.- See Also:
-
SQLXML
protected static final int SQLXMLThe trace type id for SQLXML objects.- See Also:
-
LAST
private static final int LAST- See Also:
-
ID
-
PREFIX
-
SQL_OOME
-
trace
The trace module used by this object. -
traceType
private int traceType -
id
private int id
-
-
Constructor Details
-
TraceObject
public TraceObject()
-
-
Method Details
-
setTrace
Set the options to use when writing trace message.- Parameters:
trace
- the trace objecttype
- the trace object typeid
- the trace object id
-
getTraceId
public int getTraceId()INTERNAL- Returns:
- id
-
getTraceObjectName
INTERNAL- Returns:
- object name
-
getNextId
protected static int getNextId(int type) Get the next trace object id for this object type.- Parameters:
type
- the object type- Returns:
- the new trace object id
-
isDebugEnabled
protected final boolean isDebugEnabled()Check if the debug trace level is enabled.- Returns:
- true if it is
-
isInfoEnabled
protected final boolean isInfoEnabled()Check if info trace level is enabled.- Returns:
- true if it is
-
debugCodeAssign
Write trace information as an assignment in the form className prefixId = objectName.value.- Parameters:
className
- the class name of the resultnewType
- the prefix typenewId
- the trace object id of the created objectvalue
- the value to assign this new object to
-
debugCodeCall
Write trace information as a method call in the form objectName.methodName().- Parameters:
methodName
- the method name
-
debugCodeCall
Write trace information as a method call in the form objectName.methodName(param) where the parameter is formatted as a long value.- Parameters:
methodName
- the method nameparam
- one single long parameter
-
debugCodeCall
Write trace information as a method call in the form objectName.methodName(param) where the parameter is formatted as a Java string.- Parameters:
methodName
- the method nameparam
- one single string parameter
-
debugCode
Write trace information in the form objectName.text.- Parameters:
text
- the trace text
-
quote
Format a string as a Java string literal.- Parameters:
s
- the string to convert- Returns:
- the Java string literal
-
quoteTime
Format a time to the Java source code that represents this object.- Parameters:
x
- the time to convert- Returns:
- the Java source code
-
quoteTimestamp
Format a timestamp to the Java source code that represents this object.- Parameters:
x
- the timestamp to convert- Returns:
- the Java source code
-
quoteDate
Format a date to the Java source code that represents this object.- Parameters:
x
- the date to convert- Returns:
- the Java source code
-
quoteBigDecimal
Format a big decimal to the Java source code that represents this object.- Parameters:
x
- the big decimal to convert- Returns:
- the Java source code
-
quoteBytes
Format a byte array to the Java source code that represents this object.- Parameters:
x
- the byte array to convert- Returns:
- the Java source code
-
quoteArray
Format a string array to the Java source code that represents this object.- Parameters:
s
- the string array to convert- Returns:
- the Java source code
-
quoteIntArray
Format an int array to the Java source code that represents this object.- Parameters:
s
- the int array to convert- Returns:
- the Java source code
-
quoteMap
Format a map to the Java source code that represents this object.- Parameters:
map
- the map to convert- Returns:
- the Java source code
-
logAndConvert
Log an exception and convert it to a SQL exception if required.- Parameters:
ex
- the exception- Returns:
- the SQL exception object
-
unsupported
Get a SQL exception meaning this feature is not supported.- Parameters:
message
- the message- Returns:
- the SQL exception
-