Class MessageUtils
java.lang.Object
org.apache.derby.shared.common.error.MessageUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Pointer to the application requester for the session being serviced.private static final Locale
static final String
private static String
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
, When full message text is sent for severe errors.static String
Delimiters for SQLERRMC values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
Build the SQLERRMC for ajava.sql.DataTruncation
warning.private String
Build preformatted SQLException text for severe exceptions or SQLExceptions that are not Derby exceptions.static String
static String
encodeMessageAndArgumentsAsSqlerrmc
(String messageId, Object[] args) static String
formatMessage
(ResourceBundle bundle, String messageId, Object[] arguments, boolean lastChance) static Object[]
static ResourceBundle
getBundleForLocale
(Locale locale, String msgId) static ResourceBundle
getBundleWithEnDefault
(String resource, Locale locale) Method to use instead of ResourceBundle.getBundle().static void
getLocalizedMessage
(int sqlcode, short errmcLen, String sqlerrmc, String sqlerrp, int errd0, int errd1, int errd2, int errd3, int errd4, int errd5, String warn, String sqlState, String file, String localeStr, String[] msg, int[] rc) Method used by Derby Network Server to get localized messagestatic String
getLocalizedMessage
(Locale locale, String messageId, Object[] args) Method used by Derby Network Server to get localized messagestatic int
hashString50
(String key) Hash function to split messages into 50 files based upon the message identifier or SQLState.protected int
-
Field Details
-
EN
-
SQLERRMC_MESSAGE_DELIMITER
-
DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH
public static final int DB2_JCC_MAX_EXCEPTION_PARAM_LENGTHPointer to the application requester for the session being serviced.- See Also:
-
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
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
, When full message text is sent for severe errors. This value separates the messages.
-
-
Constructor Details
-
MessageUtils
public MessageUtils()
-
-
Method Details
-
supportedMessageParamLength
protected int supportedMessageParamLength() -
getArgs
-
encodeMessageAndArgumentsAsSqlerrmc
-
encodeExceptionAsSqlerrmc
-
buildDataTruncationSqlerrmc
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
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
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
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
-
formatMessage
public static String formatMessage(ResourceBundle bundle, String messageId, Object[] arguments, boolean lastChance) -
getLocalizedMessage
public static void getLocalizedMessage(int sqlcode, short errmcLen, String sqlerrmc, String sqlerrp, int errd0, int errd1, int errd2, int errd3, int errd4, int errd5, String warn, String sqlState, String file, String localeStr, 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
Method used by Derby Network Server to get localized message- Parameters:
locale
- localemessageId
- message idargs
- message arguments
-