private String addPositiveSign(String unsignedNumeral) { String positivePrefix = ""; String positiveSuffix = ""; if (!decimalFormat.getPositivePrefix().isEmpty()) { positivePrefix = "\\Q" + decimalFormat.getPositivePrefix() + "\\E"; } if (!decimalFormat.getPositiveSuffix().isEmpty()) { positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix() + "\\E"; } return positivePrefix + unsignedNumeral + positiveSuffix; }
private boolean removeLocaleSign(StringBuilder tokenBuilder) { String positivePrefix = decimalFormat.getPositivePrefix(); String positiveSuffix = decimalFormat.getPositiveSuffix(); String negativePrefix = decimalFormat.getNegativePrefix(); String negativeSuffix = decimalFormat.getNegativeSuffix();
/** * Returns the positive suffix. * * <p>Example: 123% * * @return the suffix * @stable ICU 2.0 */ public String getPositiveSuffix() { return ((java.text.DecimalFormat)numberFormat).getPositiveSuffix(); }
/** * Returns the positive suffix. * * <p>Example: 123% * * @return the suffix * @stable ICU 2.0 */ public String getPositiveSuffix() { return ((java.text.DecimalFormat)numberFormat).getPositiveSuffix(); }
private String addPositiveSign(String unsignedNumeral) { String positivePrefix = ""; String positiveSuffix = ""; if (!decimalFormat.getPositivePrefix().isEmpty()) { positivePrefix = "\\Q" + decimalFormat.getPositivePrefix() + "\\E"; } if (!decimalFormat.getPositiveSuffix().isEmpty()) { positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix() + "\\E"; } return positivePrefix + unsignedNumeral + positiveSuffix; }
private String addPositiveSign(String unsignedNumeral) { String positivePrefix = ""; String positiveSuffix = ""; if (!decimalFormat.getPositivePrefix().isEmpty()) { positivePrefix = "\\Q" + decimalFormat.getPositivePrefix() + "\\E"; } if (!decimalFormat.getPositiveSuffix().isEmpty()) { positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix() + "\\E"; } return positivePrefix + unsignedNumeral + positiveSuffix; }
private String addPositiveSign(String unsignedNumeral) { String positivePrefix = ""; String positiveSuffix = ""; if (!decimalFormat.getPositivePrefix().isEmpty()) { positivePrefix = "\\Q" + decimalFormat.getPositivePrefix() + "\\E"; } if (!decimalFormat.getPositiveSuffix().isEmpty()) { positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix() + "\\E"; } return positivePrefix + unsignedNumeral + positiveSuffix; }
private String addPositiveSign(String unsignedNumeral) { String positivePrefix = ""; String positiveSuffix = ""; if (!decimalFormat.getPositivePrefix().isEmpty()) { positivePrefix = "\\Q" + decimalFormat.getPositivePrefix() + "\\E"; } if (!decimalFormat.getPositiveSuffix().isEmpty()) { positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix() + "\\E"; } return positivePrefix + unsignedNumeral + positiveSuffix; }
private String addPositiveSign(String unsignedNumeral) { String positivePrefix = ""; String positiveSuffix = ""; if (!decimalFormat.getPositivePrefix().isEmpty()) { positivePrefix = "\\Q" + decimalFormat.getPositivePrefix() + "\\E"; } if (!decimalFormat.getPositiveSuffix().isEmpty()) { positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix() + "\\E"; } return positivePrefix + unsignedNumeral + positiveSuffix; }
private String addPositiveSign(String unsignedNumeral) { String positivePrefix = ""; String positiveSuffix = ""; if (!decimalFormat.getPositivePrefix().isEmpty()) { positivePrefix = "\\Q" + decimalFormat.getPositivePrefix() + "\\E"; } if (!decimalFormat.getPositiveSuffix().isEmpty()) { positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix() + "\\E"; } return positivePrefix + unsignedNumeral + positiveSuffix; }
private String addPositiveSign(String unsignedNumeral) { String positivePrefix = ""; String positiveSuffix = ""; if (!decimalFormat.getPositivePrefix().isEmpty()) { positivePrefix = "\\Q" + decimalFormat.getPositivePrefix() + "\\E"; } if (!decimalFormat.getPositiveSuffix().isEmpty()) { positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix() + "\\E"; } return positivePrefix + unsignedNumeral + positiveSuffix; }
private boolean removeLocaleSign(StringBuilder tokenBuilder) { String positivePrefix = decimalFormat.getPositivePrefix(); String positiveSuffix = decimalFormat.getPositiveSuffix(); String negativePrefix = decimalFormat.getNegativePrefix(); String negativeSuffix = decimalFormat.getNegativeSuffix();
private boolean removeLocaleSign(StringBuilder tokenBuilder) { String positivePrefix = decimalFormat.getPositivePrefix(); String positiveSuffix = decimalFormat.getPositiveSuffix(); String negativePrefix = decimalFormat.getNegativePrefix(); String negativeSuffix = decimalFormat.getNegativeSuffix();
private boolean removeLocaleSign(StringBuilder tokenBuilder) { String positivePrefix = decimalFormat.getPositivePrefix(); String positiveSuffix = decimalFormat.getPositiveSuffix(); String negativePrefix = decimalFormat.getNegativePrefix(); String negativeSuffix = decimalFormat.getNegativeSuffix();
@Override public boolean isPercent() { NumberFormat percentNF = BEANS.get(NumberFormatProvider.class).getPercentInstance(NlsLocale.get()); if (percentNF instanceof DecimalFormat) { DecimalFormat percentDF = (DecimalFormat) percentNF; DecimalFormat internalDF = getFormatInternal(); return internalDF.getPositiveSuffix().equals(percentDF.getPositiveSuffix()) && internalDF.getNegativeSuffix().equals(percentDF.getNegativeSuffix()); } else { throw new NumberFormatException(); } }
@Override public boolean isPercent() { DecimalFormat percentDF = BEANS.get(NumberFormatProvider.class).getPercentInstance(NlsLocale.get()); DecimalFormat internalDF = getFormatInternal(); return internalDF.getPositiveSuffix().equals(percentDF.getPositiveSuffix()) && internalDF.getNegativeSuffix().equals(percentDF.getNegativeSuffix()); }
private String ensureSuffix(String text) { String positiveSuffix = getFormatInternal().getPositiveSuffix(); String negativeSuffix = getFormatInternal().getNegativeSuffix(); if (positiveSuffix.equals(negativeSuffix)) { String trimmedSuffix = StringUtility.trim(positiveSuffix); if (text.endsWith(trimmedSuffix)) { text = StringUtility.trim(text.substring(0, text.length() - trimmedSuffix.length())); } text = StringUtility.concatenateTokens(text, positiveSuffix); } return text; }
@Override protected NumberSymbols createObject(Locale locale, NumberType numberType, Object... params) throws Exception { DecimalFormat df = null; switch (numberType) { case INTEGER: df = (DecimalFormat) DecimalFormat.getIntegerInstance(locale); break; case PERCENT: df = (DecimalFormat) DecimalFormat.getPercentInstance(locale); break; case DECIMAL: default: df = (DecimalFormat) DecimalFormat.getNumberInstance(locale); break; } DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); return new NumberSymbols(numberType, df.getNegativePrefix(), df.getNegativeSuffix(), df.getPositivePrefix(), df.getPositiveSuffix(), df.getGroupingSize(), dfs.getGroupingSeparator(), dfs.getDecimalSeparator()); } };
@Override public void setPercent(boolean b) { DecimalFormat percentDF = BEANS.get(NumberFormatProvider.class).getPercentInstance(NlsLocale.get()); DecimalFormat format = getFormat(); if (b) { format.setPositiveSuffix(percentDF.getPositiveSuffix()); format.setNegativeSuffix(percentDF.getNegativeSuffix()); } else { if (isPercent()) { format.setPositiveSuffix(""); format.setNegativeSuffix(""); } } setFormat(format); }
@Override public void setPercent(boolean b) { try { DecimalFormat percentDF = BEANS.get(NumberFormatProvider.class).getPercentInstance(NlsLocale.get()); DecimalFormat format = getFormat(); if (b) { format.setPositiveSuffix(percentDF.getPositiveSuffix()); format.setNegativeSuffix(percentDF.getNegativeSuffix()); } else { if (isPercent()) { format.setPositiveSuffix(""); format.setNegativeSuffix(""); } } setFormat(format); } finally { setFieldChanging(false); } }