/** * Returns the detail message in the given locale and timezone. * @param loc the {@link Locale} * @param timezone the {@link TimeZone} * @return the detail message. * @throws MissingEntryException if the message is not available */ public String getDetail(Locale loc, TimeZone timezone) throws MissingEntryException { return getEntry(DETAIL_ENTRY,loc,timezone); }
/** * Returns the text message in the given locale and timezone. * @param loc the {@link Locale} * @param timezone the {@link TimeZone} * @return the text message. * @throws MissingEntryException if the message is not available */ public String getText(Locale loc, TimeZone timezone) throws MissingEntryException { return getEntry(TEXT_ENTRY,loc,timezone); }
/** * Returns an <code>Object[]</code> containing the message arguments. * @return the message arguments */ public Object[] getArguments() { return arguments.getArguments(); }
/** * * @param extraArgs */ public void setExtraArguments(Object[] extraArgs) { if (extraArgs != null) { this.extraArgs = new FilteredArguments(extraArgs); this.extraArgs.setFilter(filter); } else { this.extraArgs = null; } }
/** * Constructs a new LocalizedException with the specified localized message. * @param message the {@link ErrorBundle} that contains the message for the exception */ public LocalizedException(ErrorBundle message) { super(message.getText(Locale.getDefault())); this.message = message; }
/** * Returns the title message in the given locale and timezone. * @param loc the {@link Locale} * @param timezone the {@link TimeZone} * @return the title message. * @throws MissingEntryException if the message is not available */ public String getTitle(Locale loc,TimeZone timezone) throws MissingEntryException { return getEntry(TITLE_ENTRY,loc,timezone); }
/** * * @param extraArg */ public void setExtraArgument(Object extraArg) { setExtraArguments(new Object[] {extraArg}); }
public String getLocaleString(Locale locale) { return this.getEntry(null, locale, null); }
/** * Sets the {@link Filter} that is used to filter the arguments of this message * @param filter the {@link Filter} to use. <code>null</code> to disable filtering. */ public void setFilter(Filter filter) { arguments.setFilter(filter); if (extraArgs != null) { extraArgs.setFilter(filter); } this.filter = filter; }
/** * Constructs a new LocalizedMessage using <code>resource</code> as the base name for the * RessourceBundle and <code>id</code> as the message bundle id the resource file. * @param resource base name of the resource file * @param id the id of the corresponding bundle in the resource file * @throws NullPointerException if <code>resource</code> or <code>id</code> is <code>null</code> */ public LocalizedMessage(String resource,String id) throws NullPointerException { if (resource == null || id == null) { throw new NullPointerException(); } this.id = id; this.resource = resource; arguments = new FilteredArguments(); }
protected String addExtraArgs(String msg, Locale locale) { if (extraArgs != null) { StringBuffer sb = new StringBuffer(msg); Object[] filteredArgs = extraArgs.getFilteredArgs(locale); for (int i = 0; i < filteredArgs.length; i++) { sb.append(filteredArgs[i]); } msg = sb.toString(); } return msg; }
public Object[] getFilteredArgs(Locale locale) { Object[] result = new Object[unpackedArgs.length]; for (int i = 0; i < unpackedArgs.length; i++) { Object arg; if (filteredArgs[i] != null) { arg = filteredArgs[i]; } else { arg = unpackedArgs[i]; if (isLocaleSpecific[i]) { // get locale arg = ((LocaleString) arg).getLocaleString(locale); arg = filter(argFilterType[i], arg); } else { arg = filter(argFilterType[i], arg); filteredArgs[i] = arg; } } result[i] = arg; } return result; }
/** * Constructs a new LocalizedException with the specified localized message and cause. * @param message the {@link ErrorBundle} that contains the message for the exception * @param throwable the cause */ public LocalizedException(ErrorBundle message, Throwable throwable) { super(message.getText(Locale.getDefault())); this.message = message; this.cause = throwable; }
/** * Returns the summary message in the given locale and timezone. * @param loc the {@link Locale} * @param timezone the {@link TimeZone} * @return the summary message. * @throws MissingEntryException if the message is not available */ public String getSummary(Locale loc, TimeZone timezone) throws MissingEntryException { return getEntry(SUMMARY_ENTRY,loc,timezone); }
/** * * @return */ public Object[] getExtraArgs() { return (extraArgs == null) ? null : extraArgs.getArguments(); }
/** * Returns the text message in the given locale and the defaut timezone. * @param loc the {@link Locale} * @return the text message. * @throws MissingEntryException if the message is not available */ public String getText(Locale loc) throws MissingEntryException { return getEntry(TEXT_ENTRY,loc,TimeZone.getDefault()); }
/** * Returns the title message in the given locale and the default timezone. * @param loc the {@link Locale} * @return the title message. * @throws MissingEntryException if the message is not available */ public String getTitle(Locale loc) throws MissingEntryException { return getEntry(TITLE_ENTRY,loc,TimeZone.getDefault()); }
/** * Returns the summary message in the given locale and the default timezone. * @param loc the {@link Locale} * @return the summary message. * @throws MissingEntryException if the message is not available */ public String getSummary(Locale loc) throws MissingEntryException { return getEntry(SUMMARY_ENTRY,loc,TimeZone.getDefault()); }
public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Resource: \"").append(resource); sb.append("\" Id: \"").append(id).append("\""); sb.append(" Arguments: ").append(arguments.getArguments().length).append(" normal"); if (extraArgs != null && extraArgs.getArguments().length > 0) { sb.append(", ").append(extraArgs.getArguments().length).append(" extra"); } sb.append(" Encoding: ").append(encoding); sb.append(" ClassLoader: ").append(loader); return sb.toString(); }
/** * Returns the detail message in the given locale and the default timezone. * @param loc the {@link Locale} * @return the detail message. * @throws MissingEntryException if the message is not available */ public String getDetail(Locale loc) throws MissingEntryException { return getEntry(DETAIL_ENTRY,loc,TimeZone.getDefault()); }