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
public abstract class TraceObject extends java.lang.Object
The base class for objects that can print trace information about themselves.
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
ARRAY
The trace type id for array objects.protected static int
BLOB
The trace type id for blobs.protected static int
CALLABLE_STATEMENT
The trace type id for callable statements.protected static int
CLOB
The trace type id for clobs.protected static int
CONNECTION
The trace type id for connections.protected static int
DATA_SOURCE
The trace type id for data sources.protected static int
DATABASE_META_DATA
The trace type id for database meta data objects.private int
id
private static java.util.concurrent.atomic.AtomicIntegerArray
ID
private static int
LAST
protected static int
PARAMETER_META_DATA
The trace type id for parameter meta data objects.private static java.lang.String[]
PREFIX
protected static int
PREPARED_STATEMENT
The trace type id for prepared statements.protected static int
RESULT_SET
The trace type id for result sets.protected static int
RESULT_SET_META_DATA
The trace type id for result set meta data objects.protected static int
SAVEPOINT
The trace type id for savepoint objects.private static java.sql.SQLException
SQL_OOME
protected static int
SQLXML
The trace type id for SQLXML objects.protected static int
STATEMENT
The trace type id for statements.protected Trace
trace
The trace module used by this object.private int
traceType
protected static int
XA_DATA_SOURCE
The trace type id for XA data sources.protected static int
XID
The trace type id for transaction ids.
-
Constructor Summary
Constructors Constructor Description TraceObject()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
debugCode(java.lang.String text)
Write trace information in the form objectName.text.protected void
debugCodeAssign(java.lang.String className, int newType, int newId, java.lang.String value)
Write trace information as an assignment in the form className prefixId = objectName.value.protected void
debugCodeCall(java.lang.String methodName)
Write trace information as a method call in the form objectName.methodName().protected void
debugCodeCall(java.lang.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 void
debugCodeCall(java.lang.String methodName, java.lang.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
getTraceId()
INTERNALjava.lang.String
getTraceObjectName()
INTERNALprotected boolean
isDebugEnabled()
Check if the debug trace level is enabled.protected boolean
isInfoEnabled()
Check if info trace level is enabled.protected java.sql.SQLException
logAndConvert(java.lang.Throwable ex)
Log an exception and convert it to a SQL exception if required.protected static java.lang.String
quote(java.lang.String s)
Format a string as a Java string literal.protected static java.lang.String
quoteArray(java.lang.String[] s)
Format a string array to the Java source code that represents this object.protected static java.lang.String
quoteBigDecimal(java.math.BigDecimal x)
Format a big decimal to the Java source code that represents this object.protected static java.lang.String
quoteBytes(byte[] x)
Format a byte array to the Java source code that represents this object.protected static java.lang.String
quoteDate(java.sql.Date x)
Format a date to the Java source code that represents this object.protected static java.lang.String
quoteIntArray(int[] s)
Format an int array to the Java source code that represents this object.protected static java.lang.String
quoteMap(java.util.Map<java.lang.String,java.lang.Class<?>> map)
Format a map to the Java source code that represents this object.protected static java.lang.String
quoteTime(java.sql.Time x)
Format a time to the Java source code that represents this object.protected static java.lang.String
quoteTimestamp(java.sql.Timestamp x)
Format a timestamp to the Java source code that represents this object.protected void
setTrace(Trace trace, int type, int id)
Set the options to use when writing trace message.protected java.sql.SQLException
unsupported(java.lang.String message)
Get a SQL exception meaning this feature is not supported.
-
-
-
Field Detail
-
CALLABLE_STATEMENT
protected static final int CALLABLE_STATEMENT
The trace type id for callable statements.- See Also:
- Constant Field Values
-
CONNECTION
protected static final int CONNECTION
The trace type id for connections.- See Also:
- Constant Field Values
-
DATABASE_META_DATA
protected static final int DATABASE_META_DATA
The trace type id for database meta data objects.- See Also:
- Constant Field Values
-
PREPARED_STATEMENT
protected static final int PREPARED_STATEMENT
The trace type id for prepared statements.- See Also:
- Constant Field Values
-
RESULT_SET
protected static final int RESULT_SET
The trace type id for result sets.- See Also:
- Constant Field Values
-
RESULT_SET_META_DATA
protected static final int RESULT_SET_META_DATA
The trace type id for result set meta data objects.- See Also:
- Constant Field Values
-
SAVEPOINT
protected static final int SAVEPOINT
The trace type id for savepoint objects.- See Also:
- Constant Field Values
-
STATEMENT
protected static final int STATEMENT
The trace type id for statements.- See Also:
- Constant Field Values
-
BLOB
protected static final int BLOB
The trace type id for blobs.- See Also:
- Constant Field Values
-
CLOB
protected static final int CLOB
The trace type id for clobs.- See Also:
- Constant Field Values
-
PARAMETER_META_DATA
protected static final int PARAMETER_META_DATA
The trace type id for parameter meta data objects.- See Also:
- Constant Field Values
-
DATA_SOURCE
protected static final int DATA_SOURCE
The trace type id for data sources.- See Also:
- Constant Field Values
-
XA_DATA_SOURCE
protected static final int XA_DATA_SOURCE
The trace type id for XA data sources.- See Also:
- Constant Field Values
-
XID
protected static final int XID
The trace type id for transaction ids.- See Also:
- Constant Field Values
-
ARRAY
protected static final int ARRAY
The trace type id for array objects.- See Also:
- Constant Field Values
-
SQLXML
protected static final int SQLXML
The trace type id for SQLXML objects.- See Also:
- Constant Field Values
-
LAST
private static final int LAST
- See Also:
- Constant Field Values
-
ID
private static final java.util.concurrent.atomic.AtomicIntegerArray ID
-
PREFIX
private static final java.lang.String[] PREFIX
-
SQL_OOME
private static final java.sql.SQLException SQL_OOME
-
trace
protected Trace trace
The trace module used by this object.
-
traceType
private int traceType
-
id
private int id
-
-
Method Detail
-
setTrace
protected void setTrace(Trace trace, int type, int id)
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
public java.lang.String 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
protected final void debugCodeAssign(java.lang.String className, int newType, int newId, java.lang.String value)
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
protected final void debugCodeCall(java.lang.String methodName)
Write trace information as a method call in the form objectName.methodName().- Parameters:
methodName
- the method name
-
debugCodeCall
protected final void debugCodeCall(java.lang.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.- Parameters:
methodName
- the method nameparam
- one single long parameter
-
debugCodeCall
protected final void debugCodeCall(java.lang.String methodName, java.lang.String param)
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
protected final void debugCode(java.lang.String text)
Write trace information in the form objectName.text.- Parameters:
text
- the trace text
-
quote
protected static java.lang.String quote(java.lang.String s)
Format a string as a Java string literal.- Parameters:
s
- the string to convert- Returns:
- the Java string literal
-
quoteTime
protected static java.lang.String quoteTime(java.sql.Time x)
Format a time to the Java source code that represents this object.- Parameters:
x
- the time to convert- Returns:
- the Java source code
-
quoteTimestamp
protected static java.lang.String quoteTimestamp(java.sql.Timestamp x)
Format a timestamp to the Java source code that represents this object.- Parameters:
x
- the timestamp to convert- Returns:
- the Java source code
-
quoteDate
protected static java.lang.String quoteDate(java.sql.Date x)
Format a date to the Java source code that represents this object.- Parameters:
x
- the date to convert- Returns:
- the Java source code
-
quoteBigDecimal
protected static java.lang.String quoteBigDecimal(java.math.BigDecimal x)
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
protected static java.lang.String quoteBytes(byte[] x)
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
protected static java.lang.String quoteArray(java.lang.String[] s)
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
protected static java.lang.String quoteIntArray(int[] s)
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
protected static java.lang.String quoteMap(java.util.Map<java.lang.String,java.lang.Class<?>> map)
Format a map to the Java source code that represents this object.- Parameters:
map
- the map to convert- Returns:
- the Java source code
-
logAndConvert
protected java.sql.SQLException logAndConvert(java.lang.Throwable ex)
Log an exception and convert it to a SQL exception if required.- Parameters:
ex
- the exception- Returns:
- the SQL exception object
-
unsupported
protected java.sql.SQLException unsupported(java.lang.String message)
Get a SQL exception meaning this feature is not supported.- Parameters:
message
- the message- Returns:
- the SQL exception
-
-