super.setFormats(origFormats);
super.setFormats(origFormats);
/** * {@inheritDoc} */ @Override public void setFormats(Format[] newFormats) { super.setFormats(newFormats); }
/** * {@inheritDoc} */ @Override public void setFormats(Format[] newFormats) { super.setFormats(newFormats); }
/** * Sets the formats to use for the format elements in the * previously set pattern string. * The order of formats in <code>newFormats</code> corresponds to * the order of format elements in the pattern string. * <p> * If more formats are provided than needed by the pattern string, * the remaining ones are ignored. If fewer formats are provided * than needed, then only the first <code>newFormats.length</code> * formats are replaced. * <p> * Since the order of format elements in a pattern string often * changes during localization, it is generally better to use the * {@link #setFormatsByArgumentIndex setFormatsByArgumentIndex} * method, which assumes an order of formats corresponding to the * order of elements in the <code>arguments</code> array passed to * the <code>format</code> methods or the result array returned by * the <code>parse</code> methods. * * @param newFormats the new formats to use * @exception NullPointerException if <code>newFormats</code> is null * @stable ICU 3.0 */ public void setFormats(Format[] newFormats) { messageFormat.setFormats(newFormats); savedPattern = null; }
/** * Sets the formats to use for the format elements in the * previously set pattern string. * The order of formats in <code>newFormats</code> corresponds to * the order of format elements in the pattern string. * <p> * If more formats are provided than needed by the pattern string, * the remaining ones are ignored. If fewer formats are provided * than needed, then only the first <code>newFormats.length</code> * formats are replaced. * <p> * Since the order of format elements in a pattern string often * changes during localization, it is generally better to use the * {@link #setFormatsByArgumentIndex setFormatsByArgumentIndex} * method, which assumes an order of formats corresponding to the * order of elements in the <code>arguments</code> array passed to * the <code>format</code> methods or the result array returned by * the <code>parse</code> methods. * * @param newFormats the new formats to use * @exception NullPointerException if <code>newFormats</code> is null * @stable ICU 3.0 */ public void setFormats(Format[] newFormats) { messageFormat.setFormats(newFormats); savedPattern = null; }
private String describeAtSecond(final int second) { final String pattern = resourceBundle.getString("pattern_at_second"); final MessageFormat messageFormat = new MessageFormat(pattern, Locale.UK); final Format[] formats = {NumberFormat.getInstance()}; messageFormat.setFormats(formats); final Object[] messageArguments = { second }; final String result = messageFormat.format(messageArguments); return result; }
/** * Uitility for createing the searchable dialog message format. * * @return reuseable message format. */ public MessageFormat setupSearchResultMessageForm() { MessageFormat messageForm = new MessageFormat(messageBundle.getString( "viewer.utilityPane.search.result.msg")); double[] pageLimits = {0, 1, 2}; String[] resultsStrings = { messageBundle.getString( "viewer.utilityPane.search.result.moreFile.msg"), messageBundle.getString( "viewer.utilityPane.search.result.oneFile.msg"), messageBundle.getString( "viewer.utilityPane.search.result.moreFile.msg") }; ChoiceFormat resultsChoiceForm = new ChoiceFormat(pageLimits, resultsStrings); Format[] formats = {null, resultsChoiceForm}; messageForm.setFormats(formats); return messageForm; }
/** * Uitility for createing the searching message format. * * @return reuseable message format. */ public MessageFormat setupSearchingMessageForm() { // Build Internationalized plural phrase. MessageFormat messageForm = new MessageFormat(messageBundle.getString( "viewer.utilityPane.search.searching1.msg")); double[] fileLimits = {0, 1, 2}; String[] fileStrings = { messageBundle.getString( "viewer.utilityPane.search.searching1.moreFile.msg"), messageBundle.getString( "viewer.utilityPane.search.searching1.oneFile.msg"), messageBundle.getString( "viewer.utilityPane.search.searching1.moreFile.msg"), }; ChoiceFormat choiceForm = new ChoiceFormat(fileLimits, fileStrings); Format[] formats = {null, choiceForm, null}; messageForm.setFormats(formats); return messageForm; }
private String describeEverySecond(final int second) { final double[] secondsLimit = {1, 2}; final String[] secondsStrings = { resourceBundle.getString("oneSecond"), resourceBundle.getString("multipleSeconds") }; final double[] everyLimit = {1,2}; final String[] everyStrings = { resourceBundle.getString("every_one"), resourceBundle.getString("every_multi") }; final ChoiceFormat secondsChoiceFormat = new ChoiceFormat(secondsLimit, secondsStrings); final ChoiceFormat everyChoiceFormat = new ChoiceFormat(everyLimit, everyStrings); final String pattern = resourceBundle.getString("pattern_every_seconds"); final MessageFormat messageFormat = new MessageFormat(pattern, Locale.UK); final Format[] formats = { everyChoiceFormat, secondsChoiceFormat, NumberFormat.getInstance() }; messageFormat.setFormats(formats); final Object[] messageArguments = {second, second, second }; final String result = messageFormat.format(messageArguments); return result; }
public MessageFormat setupSearchCompletionMessageForm() { MessageFormat messageForm = new MessageFormat(messageBundle.getString( "viewer.utilityPane.search.progress.msg")); double[] pageLimits = {0, 1, 2}; String[] pageStrings = { messageBundle.getString( "viewer.utilityPane.search.progress.morePage.msg"), messageBundle.getString( "viewer.utilityPane.search.progress.onePage.msg"), messageBundle.getString( "viewer.utilityPane.search.progress.morePage.msg"), }; ChoiceFormat pageChoiceForm = new ChoiceFormat(pageLimits, pageStrings); String[] resultsStrings = { messageBundle.getString( "viewer.utilityPane.search.progress.moreMatch.msg"), messageBundle.getString( "viewer.utilityPane.search.progress.oneMatch.msg"), messageBundle.getString( "viewer.utilityPane.search.progress.moreMatch.msg"), }; ChoiceFormat resultsChoiceForm = new ChoiceFormat(pageLimits, resultsStrings); Format[] formats = {null, pageChoiceForm, resultsChoiceForm}; messageForm.setFormats(formats); return messageForm; }
@Override public Object run() { String osName = System.getProperty("os.name").toLowerCase(); if(!(osName.startsWith("windows") || osName.startsWith("mac") || osName.startsWith("linux"))) { I18nManager intl_mgr = I18nManager.getManager(); String msg_pattern = intl_mgr.getString(MISSING_OS_PROP); Locale lcl = intl_mgr.getFoundLocale(); Object[] msg_args = { osName }; Format[] fmts = { null }; MessageFormat msg_fmt = new MessageFormat(msg_pattern, lcl); String msg = msg_fmt.format(msg_args); msg_fmt.setFormats(fmts); errorReporter.warningReport(msg, null); } return null; } }
private void print(Chunk changed, String type) { m_result.append(CSS_DIFF_UNCHANGED); String[] choiceString = { m_rb.getString("diff.traditional.oneline"), m_rb.getString("diff.traditional.lines") }; double[] choiceLimits = { 1, 2 }; MessageFormat fmt = new MessageFormat(""); fmt.setLocale( Preferences.getLocale(m_context) ); ChoiceFormat cfmt = new ChoiceFormat( choiceLimits, choiceString ); fmt.applyPattern( type ); Format[] formats = { NumberFormat.getInstance(), cfmt, NumberFormat.getInstance() }; fmt.setFormats( formats ); Object[] params = { changed.first() + 1, changed.size(), changed.size() }; m_result.append( fmt.format(params) ); m_result.append(CSS_DIFF_CLOSE); } }
super.setFormats(origFormats);
super.setFormats(origFormats);
private void wrapNestedFormatters(java.text.MessageFormat mfmt) { // Update nested formatters created by Java MessageFormat // with ICU versions, so FieldPosition / AttributedText will // use ICU formatter's definition, such as com.ibm.icu.text.NumberFormat.INTEGER_FIELD // Replacing nested formatter may change the pattern string // originally used. For example, "{0,integer} files" is replaced // with "{0} files". We preserve the original pattern. savedPattern = mfmt.toPattern(); Format[] subfmts = mfmt.getFormats(); for (int i = 0; i < subfmts.length; i++) { if (subfmts[i] instanceof java.text.DateFormat) { subfmts[i] = new DateFormat((java.text.DateFormat)subfmts[i]); } else if (subfmts[i] instanceof java.text.NumberFormat) { subfmts[i] = new NumberFormat((java.text.NumberFormat)subfmts[i]); } } mfmt.setFormats(subfmts); }
private void wrapNestedFormatters(java.text.MessageFormat mfmt) { // Update nested formatters created by Java MessageFormat // with ICU versions, so FieldPosition / AttributedText will // use ICU formatter's definition, such as com.ibm.icu.text.NumberFormat.INTEGER_FIELD // Replacing nested formatter may change the pattern string // originally used. For example, "{0,integer} files" is replaced // with "{0} files". We preserve the original pattern. savedPattern = mfmt.toPattern(); Format[] subfmts = mfmt.getFormats(); for (int i = 0; i < subfmts.length; i++) { if (subfmts[i] instanceof java.text.DateFormat) { subfmts[i] = new DateFormat((java.text.DateFormat)subfmts[i]); } else if (subfmts[i] instanceof java.text.NumberFormat) { subfmts[i] = new NumberFormat((java.text.NumberFormat)subfmts[i]); } } mfmt.setFormats(subfmts); }
msg_fmt.setFormats(fmts);
super.setFormats(origFormats);
super.setFormats(origFormats);