Class MessageUtils
- java.lang.Object
-
- org.apache.derby.shared.common.error.MessageUtils
-
public class MessageUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH
Pointer to the application requester for the session being serviced.private static java.util.Locale
EN
static java.lang.String
SQLERRMC_MESSAGE_DELIMITER
private static java.lang.String
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
, When full message text is sent for severe errors.static java.lang.String
SQLERRMC_TOKEN_DELIMITER
Delimiters for SQLERRMC values.
-
Constructor Summary
Constructors Constructor Description MessageUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
buildDataTruncationSqlerrmc(java.sql.DataTruncation dt)
Build the SQLERRMC for ajava.sql.DataTruncation
warning.private java.lang.String
buildPreformattedSqlerrmc(java.sql.SQLException se)
Build preformatted SQLException text for severe exceptions or SQLExceptions that are not Derby exceptions.static java.lang.String
encodeExceptionAsSqlerrmc(java.sql.SQLException se)
static java.lang.String
encodeMessageAndArgumentsAsSqlerrmc(java.lang.String messageId, java.lang.Object[] args)
static java.lang.String
formatMessage(java.util.ResourceBundle bundle, java.lang.String messageId, java.lang.Object[] arguments, boolean lastChance)
static java.lang.Object[]
getArgs(java.lang.String sqlState, java.lang.String sqlerrmc)
static java.util.ResourceBundle
getBundleForLocale(java.util.Locale locale, java.lang.String msgId)
static java.util.ResourceBundle
getBundleWithEnDefault(java.lang.String resource, java.util.Locale locale)
Method to use instead of ResourceBundle.getBundle().static void
getLocalizedMessage(int sqlcode, short errmcLen, java.lang.String sqlerrmc, java.lang.String sqlerrp, int errd0, int errd1, int errd2, int errd3, int errd4, int errd5, java.lang.String warn, java.lang.String sqlState, java.lang.String file, java.lang.String localeStr, java.lang.String[] msg, int[] rc)
Method used by Derby Network Server to get localized messagestatic java.lang.String
getLocalizedMessage(java.util.Locale locale, java.lang.String messageId, java.lang.Object[] args)
Method used by Derby Network Server to get localized messagestatic int
hashString50(java.lang.String key)
Hash function to split messages into 50 files based upon the message identifier or SQLState.protected int
supportedMessageParamLength()
-
-
-
Field Detail
-
EN
private static final java.util.Locale EN
-
SQLERRMC_MESSAGE_DELIMITER
public static final java.lang.String SQLERRMC_MESSAGE_DELIMITER
-
DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH
public static final int DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH
Pointer to the application requester for the session being serviced.- See Also:
- Constant Field Values
-
SQLERRMC_TOKEN_DELIMITER
public static java.lang.String SQLERRMC_TOKEN_DELIMITER
Delimiters for SQLERRMC values. The token delimiter value will be used to parse the MessageId from the SQLERRMC in MessageService.getLocalizedMessage and the MessageId will be used to retrive the localized message. If this delimiter value is changed please make sure to make appropriate changes in MessageService.getLocalizedMessage that gets called from SystemProcedures.SQLCAMESSAGESQLERRMC_TOKEN_DELIMITER
separates message argument tokens
-
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
private static java.lang.String SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
, When full message text is sent for severe errors. This value separates the messages.
-
-
Method Detail
-
supportedMessageParamLength
protected int supportedMessageParamLength()
-
getArgs
public static java.lang.Object[] getArgs(java.lang.String sqlState, java.lang.String sqlerrmc)
-
encodeMessageAndArgumentsAsSqlerrmc
public static java.lang.String encodeMessageAndArgumentsAsSqlerrmc(java.lang.String messageId, java.lang.Object[] args)
-
encodeExceptionAsSqlerrmc
public static java.lang.String encodeExceptionAsSqlerrmc(java.sql.SQLException se)
-
buildDataTruncationSqlerrmc
private java.lang.String buildDataTruncationSqlerrmc(java.sql.DataTruncation dt)
Build the SQLERRMC for ajava.sql.DataTruncation
warning. Serialize all the fields of theDataTruncation
instance in the order in which they appear in the parameter list of the constructor.- Parameters:
dt
- theDataTruncation
instance to serialize- Returns:
- the SQLERRMC string with all fields of the warning
-
buildPreformattedSqlerrmc
private java.lang.String buildPreformattedSqlerrmc(java.sql.SQLException se)
Build preformatted SQLException text for severe exceptions or SQLExceptions that are not Derby exceptions. Just send the message text localized to the server locale.- Parameters:
se
- SQLException for which to build SQLERRMC- Returns:
- preformated message text with messages separted by SQLERRMC_PREFORMATED_MESSAGE_DELIMITER
-
hashString50
public static int hashString50(java.lang.String key)
Hash function to split messages into 50 files based upon the message identifier or SQLState. We don't use String.hashCode() as it varies between releases and doesn't provide an even distribution across the 50 files.
-
getBundleWithEnDefault
public static java.util.ResourceBundle getBundleWithEnDefault(java.lang.String resource, java.util.Locale locale)
Method to use instead of ResourceBundle.getBundle(). This method acts like ResourceBundle. getBundle() but if the resource is not available in the requested locale, default locale or base class the one for en_US is returned.
-
getBundleForLocale
public static java.util.ResourceBundle getBundleForLocale(java.util.Locale locale, java.lang.String msgId)
-
formatMessage
public static java.lang.String formatMessage(java.util.ResourceBundle bundle, java.lang.String messageId, java.lang.Object[] arguments, boolean lastChance)
-
getLocalizedMessage
public static void getLocalizedMessage(int sqlcode, short errmcLen, java.lang.String sqlerrmc, java.lang.String sqlerrp, int errd0, int errd1, int errd2, int errd3, int errd4, int errd5, java.lang.String warn, java.lang.String sqlState, java.lang.String file, java.lang.String localeStr, java.lang.String[] msg, int[] rc)
Method used by Derby Network Server to get localized message- Parameters:
sqlcode
- sqlcode, not used.errmcLen
- sqlerrmc lengthsqlerrmc
- sql error message tokens, variable part of error message (ie., arguments) plus messageId, separated by separator.sqlerrp
- not usederrd0
- not usedwarn
- not usedsqlState
- 5-char sql statefile
- not usedlocaleStr
- client locale in stringmsg
- OUTPUT parameter, localized error messagerc
- OUTPUT parameter, return code -- 0 for success
-
getLocalizedMessage
public static java.lang.String getLocalizedMessage(java.util.Locale locale, java.lang.String messageId, java.lang.Object[] args)
Method used by Derby Network Server to get localized message- Parameters:
locale
- localemessageId
- message idargs
- message arguments
-
-