java.lang.Object
org.firebirdsql.gds.MessageTemplate
Message template for Firebird and Jaybird parameterized error messages.
- Since:
- 6
-
Method Summary
Modifier and TypeMethodDescriptionfinal voidappendErrorInfoSuffix(StringBuilder messageBuffer) Appends the SQLstate and error code tomessageBuffer.abstract voidappendMessage(StringBuilder messageBuffer, List<? extends @Nullable Object> parameters) Appends the message, formatted usingparameters, tomessageBuffer.abstract intstatic MessageTemplateof(int errorCode) Returns a message template for the specified error code.abstract @Nullable StringsqlState()final StringRenders the message, formatted usingparameters.abstract MessageTemplatewithDefaultSqlState(String defaultSqlState) Returns a copy of this template withsqlStateset todefaultSqlStateif the SQLstate of this template isnull, otherwise returns this template.abstract MessageTemplatewithSqlState(String sqlState) Returns a copy of this template withsqlStateset, or this template if it already hassqlStateas 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 withsqlStateset todefaultSqlStateif 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
sqlStateis non-null, otherwise a copy with thesqlStateset todefaultSqlState - Throws:
NullPointerException- ifdefaultSqlStateisnullandsqlStateof this instance is alsonullIllegalArgumentException- ifdefaultSqlStateis not 5 characters long
-
withSqlState
Returns a copy of this template withsqlStateset, or this template if it already hassqlStateas its SQLstate value.- Parameters:
sqlState- new SQLstate value (notnull)- Returns:
- this template if it already has
sqlStateas its value, otherwise a copy withsqlStateset - Throws:
NullPointerException- ifsqlStateisnullIllegalArgumentException- ifsqlStateis 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
nullare rendered as(null). Excess parameters are concatenated to the end of the message, unless theerrorCodeisISCConstants.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:
-