java.lang.Object
org.firebirdsql.gds.MessageTemplate
Message template for Firebird and Jaybird parameterized error messages.
- Since:
- 6
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
appendErrorInfoSuffix
(StringBuilder messageBuffer) Appends the SQLstate and error code tomessageBuffer
.abstract void
appendMessage
(StringBuilder messageBuffer, List<? extends @Nullable Object> parameters) Appends the message, formatted usingparameters
, tomessageBuffer
.abstract int
static MessageTemplate
of
(int errorCode) Returns a message template for the specified error code.abstract @Nullable String
sqlState()
final String
Renders the message, formatted usingparameters
.abstract MessageTemplate
withDefaultSqlState
(String defaultSqlState) Returns a copy of this template withsqlState
set todefaultSqlState
if the SQLstate of this template isnull
, otherwise returns this template.abstract MessageTemplate
withSqlState
(String sqlState) Returns a copy of this template withsqlState
set, or this template if it already hassqlState
as its SQLstate value.
-
Method Details
-
of
Returns a message template for the specified error code.- Parameters:
errorCode
- error code- Returns:
- message template; if there is no error defined for
errorCode
, a message template is returned with a "not found" message and SQLstatenull
.
-
errorCode
public abstract int errorCode()- Returns:
- error code of this message
-
sqlState
- Returns:
- SQLstate (can be
null
)
-
withDefaultSqlState
Returns a copy of this template withsqlState
set todefaultSqlState
if the SQLstate of this template isnull
, otherwise returns this template.- Parameters:
defaultSqlState
- default SQLstate to apply if this template hassqlState == null
- Returns:
- this template if
sqlState
is non-null
, otherwise a copy with thesqlState
set todefaultSqlState
- Throws:
NullPointerException
- ifdefaultSqlState
isnull
andsqlState
of this instance is alsonull
IllegalArgumentException
- ifdefaultSqlState
is not 5 characters long
-
withSqlState
Returns a copy of this template withsqlState
set, or this template if it already hassqlState
as its SQLstate value.- Parameters:
sqlState
- new SQLstate value (notnull
)- Returns:
- this template if it already has
sqlState
as its value, otherwise a copy withsqlState
set - Throws:
NullPointerException
- ifsqlState
isnull
IllegalArgumentException
- ifsqlState
is not 5 characters long
-
toMessage
Renders the message, formatted usingparameters
.- Parameters:
parameters
- parameters- Returns:
- formatted message
- See Also:
-
appendMessage
public abstract void appendMessage(StringBuilder messageBuffer, List<? extends @Nullable Object> parameters) Appends the message, formatted usingparameters
, tomessageBuffer
.Parameters that are missing or
null
are rendered as(null)
. Excess parameters are concatenated to the end of the message, unless theerrorCode
isISCConstants.isc_formatted_exception
.- Parameters:
messageBuffer
- string builder to append toparameters
- parameters to use for formatting (nevernull
, may be empty)- See Also:
-
appendErrorInfoSuffix
Appends the SQLstate and error code tomessageBuffer
.- Parameters:
messageBuffer
- string builder to append to- See Also:
-