public static Message getMessage(final Locale language, final MessageReference context) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); return getMessage(language, context.getKey(), contentAsArray); }
public static Message getMessage(final Locale language, final MessageReference context) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); return getMessage(language, context.getKey(), contentAsArray); }
public static Message getMessage(final Locale language, final MessageReference context) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); return getMessage(language, context.getKey(), contentAsArray); }
@Override public String getLocalizedMessage(final MessageReference context, final Throwable exception) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); if (contentAsArray.length == 0 && exception != null) { contentAsArray = new Object[2]; contentAsArray[0] = exception.getStackTrace()[1].getClassName(); contentAsArray[1] = exception.getMessage(); } String value = null; String key = context.getKey(); try { value = getMessage(key); StringBuilder builder = new StringBuilder(); Formatter f = null; if (lanLocale == null) { f = new Formatter(); } else { f = new Formatter(builder, lanLocale); } f.format(value, contentAsArray); f.close(); return builder.toString(); } catch (MissingResourceException e) { return "Missing message for key '" + key + "'!"; } catch (MissingFormatArgumentException e) { return "Missing replacement for place holder in value '" + value + "' for following arguments '" + Arrays.toString(contentAsArray) + "'!"; } }
@Override public String getLocalizedMessage(final MessageReference context, final Throwable exception) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); if (contentAsArray.length == 0 && exception != null) { contentAsArray = new Object[2]; contentAsArray[0] = exception.getStackTrace()[1].getClassName(); contentAsArray[1] = exception.getMessage(); } String value = null; String key = context.getKey(); try { value = getMessage(key); StringBuilder builder = new StringBuilder(); Formatter f = null; if (lanLocale == null) { f = new Formatter(); } else { f = new Formatter(builder, lanLocale); } f.format(value, contentAsArray); f.close(); return builder.toString(); } catch (MissingResourceException e) { return "Missing message for key '" + key + "'!"; } catch (MissingFormatArgumentException e) { return "Missing replacement for place holder in value '" + value + "' for following arguments '" + Arrays.toString(contentAsArray) + "'!"; } }
/** * {@inheritDoc} */ @Override public String getMessage() { if (messageReference == null) { return "No message reference given. Inherit message is = '" + super.getMessage() + "'"; } String message = RuntimeDelegate.extractExceptionMessage(this); if (message == null) { return "Message Reference key = '" + messageReference.getKey() + "' and inherit message = '" + super.getMessage() + "'"; } return message; } }
/** * {@inheritDoc} */ @Override public String getMessage() { if (messageReference == null) { return "No message reference given. Inherit message is = '" + super.getMessage() + "'"; } String message = RuntimeDelegate.extractExceptionMessage(this); if (message == null) { return "Message Reference key = '" + messageReference.getKey() + "' and inherit message = '" + super.getMessage() + "'"; } return message; } }
/** * {@inheritDoc} */ @Override public String getMessage() { if (messageReference == null) { return "No message reference given. Inherit message is = '" + super.getMessage() + "'"; } String message = RuntimeDelegate.extractExceptionMessage(this); if (message == null) { return "Message Reference key = '" + messageReference.getKey() + "' and inherit message = '" + super.getMessage() + "'"; } return message; } }