1adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/* 2adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Copyright (C) 2008 The Android Open Source Project 3adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 4adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 5adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * you may not use this file except in compliance with the License. 6adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * You may obtain a copy of the License at 7adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 8adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 9adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 10adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software 11adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 12adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * See the License for the specific language governing permissions and 14adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * limitations under the License. 15adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 16adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 17c27a366a89e470690e99374b15270e7b9169ade1Elliott Hughespackage libcore.icu; 18adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 19adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.math.BigDecimal; 20adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.math.BigInteger; 2142db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughesimport java.math.RoundingMode; 22adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.text.AttributedCharacterIterator; 23adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.text.AttributedString; 24f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughesimport java.text.DecimalFormatSymbols; 25adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.text.FieldPosition; 26adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.text.Format; 27adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.text.NumberFormat; 28adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.text.ParsePosition; 29adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.util.Currency; 30adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 3134a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughespublic final class NativeDecimalFormat implements Cloneable { 321efbe3391e92e6188918122a600623090561364fElliott Hughes /** 335d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes * Constants corresponding to the native type UNumberFormatSymbol, for setSymbol. 341efbe3391e92e6188918122a600623090561364fElliott Hughes */ 35f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_DECIMAL_SEPARATOR_SYMBOL = 0; 36f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_GROUPING_SEPARATOR_SYMBOL = 1; 37f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_PATTERN_SEPARATOR_SYMBOL = 2; 38f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_PERCENT_SYMBOL = 3; 39f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_ZERO_DIGIT_SYMBOL = 4; 40f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_DIGIT_SYMBOL = 5; 41f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_MINUS_SIGN_SYMBOL = 6; 42f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_PLUS_SIGN_SYMBOL = 7; 43f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_CURRENCY_SYMBOL = 8; 44f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_INTL_CURRENCY_SYMBOL = 9; 45f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_MONETARY_SEPARATOR_SYMBOL = 10; 46f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_EXPONENTIAL_SYMBOL = 11; 47f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_PERMILL_SYMBOL = 12; 48f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_PAD_ESCAPE_SYMBOL = 13; 49f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_INFINITY_SYMBOL = 14; 50f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_NAN_SYMBOL = 15; 51f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16; 52f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17; 53f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes private static final int UNUM_FORMAT_SYMBOL_COUNT = 18; 54820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes 551efbe3391e92e6188918122a600623090561364fElliott Hughes /** 561efbe3391e92e6188918122a600623090561364fElliott Hughes * Constants corresponding to the native type UNumberFormatAttribute, for 571efbe3391e92e6188918122a600623090561364fElliott Hughes * getAttribute/setAttribute. 581efbe3391e92e6188918122a600623090561364fElliott Hughes */ 591efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_PARSE_INT_ONLY = 0; 601efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_GROUPING_USED = 1; 611efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_DECIMAL_ALWAYS_SHOWN = 2; 621efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_MAX_INTEGER_DIGITS = 3; 631efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_MIN_INTEGER_DIGITS = 4; 641efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_INTEGER_DIGITS = 5; 651efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_MAX_FRACTION_DIGITS = 6; 661efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_MIN_FRACTION_DIGITS = 7; 671efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_FRACTION_DIGITS = 8; 681efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_MULTIPLIER = 9; 691efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_GROUPING_SIZE = 10; 701efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_ROUNDING_MODE = 11; 711efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_ROUNDING_INCREMENT = 12; 721efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_FORMAT_WIDTH = 13; 731efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_PADDING_POSITION = 14; 741efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_SECONDARY_GROUPING_SIZE = 15; 751efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_SIGNIFICANT_DIGITS_USED = 16; 761efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_MIN_SIGNIFICANT_DIGITS = 17; 771efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_MAX_SIGNIFICANT_DIGITS = 18; 781efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_LENIENT_PARSE = 19; 79820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes 801efbe3391e92e6188918122a600623090561364fElliott Hughes /** 811efbe3391e92e6188918122a600623090561364fElliott Hughes * Constants corresponding to the native type UNumberFormatTextAttribute, for 821efbe3391e92e6188918122a600623090561364fElliott Hughes * getTextAttribute/setTextAttribute. 831efbe3391e92e6188918122a600623090561364fElliott Hughes */ 841efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_POSITIVE_PREFIX = 0; 851efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_POSITIVE_SUFFIX = 1; 861efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_NEGATIVE_PREFIX = 2; 871efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_NEGATIVE_SUFFIX = 3; 881efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_PADDING_CHARACTER = 4; 891efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_CURRENCY_CODE = 5; 901efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_DEFAULT_RULESET = 6; 911efbe3391e92e6188918122a600623090561364fElliott Hughes private static final int UNUM_PUBLIC_RULESETS = 7; 92f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes 931efbe3391e92e6188918122a600623090561364fElliott Hughes /** 9474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes * A table for translating between NumberFormat.Field instances 9574473971cc9d960376295fbcc430320c9ed62991Elliott Hughes * and icu4c UNUM_x_FIELD constants. 9674473971cc9d960376295fbcc430320c9ed62991Elliott Hughes */ 9774473971cc9d960376295fbcc430320c9ed62991Elliott Hughes private static final Format.Field[] ICU4C_FIELD_IDS = { 9874473971cc9d960376295fbcc430320c9ed62991Elliott Hughes // The old java field values were 0 for integer and 1 for fraction. 9974473971cc9d960376295fbcc430320c9ed62991Elliott Hughes // The new java field attributes are all objects. ICU assigns the values 10074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes // starting from 0 in the following order; note that integer and 10174473971cc9d960376295fbcc430320c9ed62991Elliott Hughes // fraction positions match the old field values. 10274473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.INTEGER, // 0 UNUM_INTEGER_FIELD 10374473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.FRACTION, // 1 UNUM_FRACTION_FIELD 10474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.DECIMAL_SEPARATOR, // 2 UNUM_DECIMAL_SEPARATOR_FIELD 10574473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.EXPONENT_SYMBOL, // 3 UNUM_EXPONENT_SYMBOL_FIELD 10674473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.EXPONENT_SIGN, // 4 UNUM_EXPONENT_SIGN_FIELD 10774473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.EXPONENT, // 5 UNUM_EXPONENT_FIELD 10874473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.GROUPING_SEPARATOR, // 6 UNUM_GROUPING_SEPARATOR_FIELD 10974473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.CURRENCY, // 7 UNUM_CURRENCY_FIELD 11074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.PERCENT, // 8 UNUM_PERCENT_FIELD 11174473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.PERMILLE, // 9 UNUM_PERMILL_FIELD 11274473971cc9d960376295fbcc430320c9ed62991Elliott Hughes NumberFormat.Field.SIGN, // 10 UNUM_SIGN_FIELD 11374473971cc9d960376295fbcc430320c9ed62991Elliott Hughes }; 11474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes 11574473971cc9d960376295fbcc430320c9ed62991Elliott Hughes private static int translateFieldId(FieldPosition fp) { 11674473971cc9d960376295fbcc430320c9ed62991Elliott Hughes int id = fp.getField(); 11774473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (id < -1 || id > 1) { 11874473971cc9d960376295fbcc430320c9ed62991Elliott Hughes id = -1; 11974473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 12074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (id == -1) { 12174473971cc9d960376295fbcc430320c9ed62991Elliott Hughes Format.Field attr = fp.getFieldAttribute(); 12274473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (attr != null) { 12374473971cc9d960376295fbcc430320c9ed62991Elliott Hughes for (int i = 0; i < ICU4C_FIELD_IDS.length; ++i) { 12474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (ICU4C_FIELD_IDS[i].equals(attr)) { 12574473971cc9d960376295fbcc430320c9ed62991Elliott Hughes id = i; 12674473971cc9d960376295fbcc430320c9ed62991Elliott Hughes break; 12774473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 12874473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 12974473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 13074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 13174473971cc9d960376295fbcc430320c9ed62991Elliott Hughes return id; 13274473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 13374473971cc9d960376295fbcc430320c9ed62991Elliott Hughes 13474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes /** 1351efbe3391e92e6188918122a600623090561364fElliott Hughes * The address of the ICU DecimalFormat* on the native heap. 1361efbe3391e92e6188918122a600623090561364fElliott Hughes */ 13760b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private long address; 138f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes 1391efbe3391e92e6188918122a600623090561364fElliott Hughes /** 1401efbe3391e92e6188918122a600623090561364fElliott Hughes * The last pattern we gave to ICU, so we can make repeated applications cheap. 1411efbe3391e92e6188918122a600623090561364fElliott Hughes * This helps in cases like String.format("%.2f,%.2f\n", x, y) where the DecimalFormat is 1421efbe3391e92e6188918122a600623090561364fElliott Hughes * reused. 143820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes */ 1441efbe3391e92e6188918122a600623090561364fElliott Hughes private String lastPattern; 1451efbe3391e92e6188918122a600623090561364fElliott Hughes 146820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes // TODO: store all these in DecimalFormat instead! 147adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project private boolean negPrefNull; 148adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project private boolean negSuffNull; 149adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project private boolean posPrefNull; 150adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project private boolean posSuffNull; 151adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 152947eeb80f985827209c9500851e288504d58ec2eclaireho private transient boolean parseBigDecimal; 153947eeb80f985827209c9500851e288504d58ec2eclaireho 1545d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes public NativeDecimalFormat(String pattern, DecimalFormatSymbols dfs) { 1555d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes try { 156866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes this.address = open(pattern, dfs.getCurrencySymbol(), 15734eb0408ff03c10b8f5842d328457aeeabac17a7Elliott Hughes dfs.getDecimalSeparator(), dfs.getDigit(), dfs.getExponentSeparator(), 15834eb0408ff03c10b8f5842d328457aeeabac17a7Elliott Hughes dfs.getGroupingSeparator(), dfs.getInfinity(), 1594f3bca749bdc8be8abf7555b315f308a2c8c14a7Narayan Kamath dfs.getInternationalCurrencySymbol(), dfs.getMinusSignString(), 1605d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes dfs.getMonetaryDecimalSeparator(), dfs.getNaN(), dfs.getPatternSeparator(), 161a68116c0d8ff9cd517d6b765bf2b8930ed9a3e12Elliott Hughes dfs.getPercentString(), dfs.getPerMill(), dfs.getZeroDigit()); 1625d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes this.lastPattern = pattern; 1635d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes } catch (NullPointerException npe) { 1645d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes throw npe; 1655d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes } catch (RuntimeException re) { 1665d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes throw new IllegalArgumentException("syntax error: " + re.getMessage() + ": " + pattern); 1675d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes } 168adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 169adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 1703e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes // Used so java.util.Formatter doesn't need to allocate DecimalFormatSymbols instances. 1713e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes public NativeDecimalFormat(String pattern, LocaleData data) { 172866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes this.address = open(pattern, data.currencySymbol, 173e2377cdd707b830d07a5708216834f7ac76ee3e1Elliott Hughes data.decimalSeparator, '#', data.exponentSeparator, data.groupingSeparator, 1743e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes data.infinity, data.internationalCurrencySymbol, data.minusSign, 1753e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes data.monetarySeparator, data.NaN, data.patternSeparator, 1763e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes data.percent, data.perMill, data.zeroDigit); 1773e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes this.lastPattern = pattern; 1783e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes } 1793e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes 1803e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes public synchronized void close() { 181866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes if (address != 0) { 182866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes close(address); 183866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes address = 0; 1843e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes } 185adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 186adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 18734a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes @Override protected void finalize() throws Throwable { 18834a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes try { 18934a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes close(); 19034a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes } finally { 19134a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes super.finalize(); 19234a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes } 19334a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes } 19434a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes 19534a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes @Override public Object clone() { 19634a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes try { 19734a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes NativeDecimalFormat clone = (NativeDecimalFormat) super.clone(); 19834a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes clone.address = cloneImpl(address); 19934a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes clone.lastPattern = lastPattern; 20034a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes clone.negPrefNull = negPrefNull; 20134a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes clone.negSuffNull = negSuffNull; 20234a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes clone.posPrefNull = posPrefNull; 20334a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes clone.posSuffNull = posSuffNull; 20434a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes return clone; 20534a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes } catch (CloneNotSupportedException unexpected) { 20634a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes throw new AssertionError(unexpected); 20734a3a0501220dd62b88ddb4a355bad46b15c25a2Elliott Hughes } 208f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes } 209f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes 210f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes /** 211f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes * Note: this doesn't check that the underlying native DecimalFormat objects' configured 212f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes * native DecimalFormatSymbols objects are equal. It is assumed that the 213820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes * caller (DecimalFormat) will check the DecimalFormatSymbols objects 214f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes * instead, for performance. 215f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * 216f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes * This is also unreasonably expensive, calling down to JNI multiple times. 217f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * 218820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes * TODO: remove this and just have DecimalFormat.equals do the right thing itself. 219f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes */ 220f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes @Override 221adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public boolean equals(Object object) { 222adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (object == this) { 223adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return true; 224adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 225820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes if (!(object instanceof NativeDecimalFormat)) { 226adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return false; 227adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 228820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes NativeDecimalFormat obj = (NativeDecimalFormat) object; 229866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes if (obj.address == this.address) { 230adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return true; 231adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 232f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes return obj.toPattern().equals(this.toPattern()) && 233f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.isDecimalSeparatorAlwaysShown() == this.isDecimalSeparatorAlwaysShown() && 234f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getGroupingSize() == this.getGroupingSize() && 235f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getMultiplier() == this.getMultiplier() && 236f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getNegativePrefix().equals(this.getNegativePrefix()) && 237f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getNegativeSuffix().equals(this.getNegativeSuffix()) && 238f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getPositivePrefix().equals(this.getPositivePrefix()) && 239f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getPositiveSuffix().equals(this.getPositiveSuffix()) && 240f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getMaximumIntegerDigits() == this.getMaximumIntegerDigits() && 241f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getMaximumFractionDigits() == this.getMaximumFractionDigits() && 242f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getMinimumIntegerDigits() == this.getMinimumIntegerDigits() && 243f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes obj.getMinimumFractionDigits() == this.getMinimumFractionDigits() && 2445d593ea1361bd7c5ef3353b66d63ac64e95d9d41Elliott Hughes obj.isGroupingUsed() == this.isGroupingUsed(); 245f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes } 246adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 24774473971cc9d960376295fbcc430320c9ed62991Elliott Hughes public String toString() { 24874473971cc9d960376295fbcc430320c9ed62991Elliott Hughes return getClass().getName() + "[\"" + toPattern() + "\"" + 24974473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",isDecimalSeparatorAlwaysShown=" + isDecimalSeparatorAlwaysShown() + 25074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",groupingSize=" + getGroupingSize() + 25174473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",multiplier=" + getMultiplier() + 25274473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",negativePrefix=" + getNegativePrefix() + 25374473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",negativeSuffix=" + getNegativeSuffix() + 25474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",positivePrefix=" + getPositivePrefix() + 25574473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",positiveSuffix=" + getPositiveSuffix() + 25674473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",maxIntegerDigits=" + getMaximumIntegerDigits() + 25774473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",maxFractionDigits=" + getMaximumFractionDigits() + 25874473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",minIntegerDigits=" + getMinimumIntegerDigits() + 25974473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",minFractionDigits=" + getMinimumFractionDigits() + 26074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes ",grouping=" + isGroupingUsed() + 26174473971cc9d960376295fbcc430320c9ed62991Elliott Hughes "]"; 26274473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 26374473971cc9d960376295fbcc430320c9ed62991Elliott Hughes 264f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes /** 265d5344fec27edfcf7acf9f703c9d7dff14a832943Elliott Hughes * Copies the DecimalFormatSymbols settings into our native peer in bulk. 266f2d5062b67e57ef00ee81fec67480f0d58d66b50Elliott Hughes */ 267820dd9b89746b3e3005bd5d23176cde1a69048b7Elliott Hughes public void setDecimalFormatSymbols(final DecimalFormatSymbols dfs) { 268866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setDecimalFormatSymbols(this.address, dfs.getCurrencySymbol(), dfs.getDecimalSeparator(), 26934eb0408ff03c10b8f5842d328457aeeabac17a7Elliott Hughes dfs.getDigit(), dfs.getExponentSeparator(), dfs.getGroupingSeparator(), 2704f3bca749bdc8be8abf7555b315f308a2c8c14a7Narayan Kamath dfs.getInfinity(), dfs.getInternationalCurrencySymbol(), dfs.getMinusSignString(), 271d5344fec27edfcf7acf9f703c9d7dff14a832943Elliott Hughes dfs.getMonetaryDecimalSeparator(), dfs.getNaN(), dfs.getPatternSeparator(), 272a68116c0d8ff9cd517d6b765bf2b8930ed9a3e12Elliott Hughes dfs.getPercentString(), dfs.getPerMill(), dfs.getZeroDigit()); 273adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 274adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 275fa9acfd6b78ca206da039e7646dfb5780097a436Elliott Hughes public void setDecimalFormatSymbols(final LocaleData localeData) { 276866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setDecimalFormatSymbols(this.address, localeData.currencySymbol, localeData.decimalSeparator, 277e2377cdd707b830d07a5708216834f7ac76ee3e1Elliott Hughes '#', localeData.exponentSeparator, localeData.groupingSeparator, 27834eb0408ff03c10b8f5842d328457aeeabac17a7Elliott Hughes localeData.infinity, localeData.internationalCurrencySymbol, localeData.minusSign, 279fa9acfd6b78ca206da039e7646dfb5780097a436Elliott Hughes localeData.monetarySeparator, localeData.NaN, localeData.patternSeparator, 280fa9acfd6b78ca206da039e7646dfb5780097a436Elliott Hughes localeData.percent, localeData.perMill, localeData.zeroDigit); 281fa9acfd6b78ca206da039e7646dfb5780097a436Elliott Hughes } 282fa9acfd6b78ca206da039e7646dfb5780097a436Elliott Hughes 28346cb23aaaba1b0553d02d32713abad97bd4b0428Elliott Hughes public char[] formatBigDecimal(BigDecimal value, FieldPosition field) { 284947eeb80f985827209c9500851e288504d58ec2eclaireho FieldPositionIterator fpi = FieldPositionIterator.forFieldPosition(field); 285866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes char[] result = formatDigitList(this.address, value.toString(), fpi); 28674473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (fpi != null && field != null) { 28774473971cc9d960376295fbcc430320c9ed62991Elliott Hughes updateFieldPosition(field, fpi); 2883e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes } 2893e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes return result; 290d7e81f7408fb84307d7792b7e3ab8c5a510b294bElliott Hughes } 291f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes 29246cb23aaaba1b0553d02d32713abad97bd4b0428Elliott Hughes public char[] formatBigInteger(BigInteger value, FieldPosition field) { 293947eeb80f985827209c9500851e288504d58ec2eclaireho FieldPositionIterator fpi = FieldPositionIterator.forFieldPosition(field); 294866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes char[] result = formatDigitList(this.address, value.toString(10), fpi); 29574473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (fpi != null && field != null) { 29674473971cc9d960376295fbcc430320c9ed62991Elliott Hughes updateFieldPosition(field, fpi); 2973e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes } 2983e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes return result; 299d7e81f7408fb84307d7792b7e3ab8c5a510b294bElliott Hughes } 3008c7e05b66900808a96fc26903ac389a6c66b1674Elliott Hughes 30146cb23aaaba1b0553d02d32713abad97bd4b0428Elliott Hughes public char[] formatLong(long value, FieldPosition field) { 302947eeb80f985827209c9500851e288504d58ec2eclaireho FieldPositionIterator fpi = FieldPositionIterator.forFieldPosition(field); 303866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes char[] result = formatLong(this.address, value, fpi); 30474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (fpi != null && field != null) { 30574473971cc9d960376295fbcc430320c9ed62991Elliott Hughes updateFieldPosition(field, fpi); 3063e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes } 3073e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes return result; 308adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 309adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 31046cb23aaaba1b0553d02d32713abad97bd4b0428Elliott Hughes public char[] formatDouble(double value, FieldPosition field) { 311947eeb80f985827209c9500851e288504d58ec2eclaireho FieldPositionIterator fpi = FieldPositionIterator.forFieldPosition(field); 312866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes char[] result = formatDouble(this.address, value, fpi); 31374473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (fpi != null && field != null) { 31474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes updateFieldPosition(field, fpi); 3153e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes } 3163e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes return result; 317adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 318adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 31974473971cc9d960376295fbcc430320c9ed62991Elliott Hughes private static void updateFieldPosition(FieldPosition fp, FieldPositionIterator fpi) { 32074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes int field = translateFieldId(fp); 32174473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (field != -1) { 32274473971cc9d960376295fbcc430320c9ed62991Elliott Hughes while (fpi.next()) { 32374473971cc9d960376295fbcc430320c9ed62991Elliott Hughes if (fpi.fieldId() == field) { 32474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes fp.setBeginIndex(fpi.start()); 32574473971cc9d960376295fbcc430320c9ed62991Elliott Hughes fp.setEndIndex(fpi.limit()); 32674473971cc9d960376295fbcc430320c9ed62991Elliott Hughes return; 32774473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 32874473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 32974473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 33074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes } 33174473971cc9d960376295fbcc430320c9ed62991Elliott Hughes 332adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void applyLocalizedPattern(String pattern) { 333866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes applyPattern(this.address, true, pattern); 3341efbe3391e92e6188918122a600623090561364fElliott Hughes lastPattern = null; 335adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 336adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 337adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void applyPattern(String pattern) { 3381efbe3391e92e6188918122a600623090561364fElliott Hughes if (lastPattern != null && pattern.equals(lastPattern)) { 3391efbe3391e92e6188918122a600623090561364fElliott Hughes return; 3401efbe3391e92e6188918122a600623090561364fElliott Hughes } 341866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes applyPattern(this.address, false, pattern); 3421efbe3391e92e6188918122a600623090561364fElliott Hughes lastPattern = pattern; 343adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 344adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 345adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public AttributedCharacterIterator formatToCharacterIterator(Object object) { 346cff1616012dc0d56c2da9af2b9b1183e76c7e044Elliott Hughes if (object == null) { 347cff1616012dc0d56c2da9af2b9b1183e76c7e044Elliott Hughes throw new NullPointerException("object == null"); 348cff1616012dc0d56c2da9af2b9b1183e76c7e044Elliott Hughes } 349adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (!(object instanceof Number)) { 350cff1616012dc0d56c2da9af2b9b1183e76c7e044Elliott Hughes throw new IllegalArgumentException("object not a Number: " + object.getClass()); 351adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 352adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project Number number = (Number) object; 353947eeb80f985827209c9500851e288504d58ec2eclaireho FieldPositionIterator fpIter = new FieldPositionIterator(); 35446cb23aaaba1b0553d02d32713abad97bd4b0428Elliott Hughes String text; 35546cb23aaaba1b0553d02d32713abad97bd4b0428Elliott Hughes if (number instanceof BigInteger || number instanceof BigDecimal) { 356866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes text = new String(formatDigitList(this.address, number.toString(), fpIter)); 357b56d4f145a425910db1f6201edc593b61127ca83Elliott Hughes } else if (number instanceof Double || number instanceof Float) { 358adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project double dv = number.doubleValue(); 359866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes text = new String(formatDouble(this.address, dv, fpIter)); 360b56d4f145a425910db1f6201edc593b61127ca83Elliott Hughes } else { 361adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project long lv = number.longValue(); 362866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes text = new String(formatLong(this.address, lv, fpIter)); 363adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 364adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 365b56d4f145a425910db1f6201edc593b61127ca83Elliott Hughes AttributedString as = new AttributedString(text); 366adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 367947eeb80f985827209c9500851e288504d58ec2eclaireho while (fpIter.next()) { 368947eeb80f985827209c9500851e288504d58ec2eclaireho Format.Field field = fpIter.field(); 369947eeb80f985827209c9500851e288504d58ec2eclaireho as.addAttribute(field, field, fpIter.start(), fpIter.limit()); 370adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 371adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 372adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project // return the CharacterIterator from AttributedString 373adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return as.getIterator(); 374adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 375adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 376adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project private int makeScalePositive(int scale, StringBuilder val) { 377adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (scale < 0) { 378adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project scale = -scale; 379adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project for (int i = scale; i > 0; i--) { 380adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project val.append('0'); 381adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 382adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project scale = 0; 383adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 384adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return scale; 385adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 386adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 387adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public String toLocalizedPattern() { 388866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return toPatternImpl(this.address, true); 389adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 390adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 391adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public String toPattern() { 392866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return toPatternImpl(this.address, false); 393adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 394adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 395adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public Number parse(String string, ParsePosition position) { 396866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return parse(address, string, position, parseBigDecimal); 397adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 398adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 399adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project // start getter and setter 400adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 401adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public int getMaximumFractionDigits() { 402866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_MAX_FRACTION_DIGITS); 403adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 404adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 405adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public int getMaximumIntegerDigits() { 406866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_MAX_INTEGER_DIGITS); 407adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 408adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 409adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public int getMinimumFractionDigits() { 410866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_MIN_FRACTION_DIGITS); 411adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 412adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 413adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public int getMinimumIntegerDigits() { 414866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_MIN_INTEGER_DIGITS); 415adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 416adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 417adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public int getGroupingSize() { 418605a54c3fb24e9d4e0ee76f52ca5bbc387a0b544Elliott Hughes // Work around http://bugs.icu-project.org/trac/ticket/10864 in icu4c 53. 419605a54c3fb24e9d4e0ee76f52ca5bbc387a0b544Elliott Hughes if (!isGroupingUsed()) { 420605a54c3fb24e9d4e0ee76f52ca5bbc387a0b544Elliott Hughes return 0; 421605a54c3fb24e9d4e0ee76f52ca5bbc387a0b544Elliott Hughes } 422866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_GROUPING_SIZE); 423adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 424adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 425adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public int getMultiplier() { 426866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_MULTIPLIER); 427adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 428adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 429adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public String getNegativePrefix() { 430adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (negPrefNull) { 431adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return null; 432adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 433866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getTextAttribute(this.address, UNUM_NEGATIVE_PREFIX); 434adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 435adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 436adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public String getNegativeSuffix() { 437adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (negSuffNull) { 438adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return null; 439adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 440866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getTextAttribute(this.address, UNUM_NEGATIVE_SUFFIX); 441adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 442adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 443adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public String getPositivePrefix() { 444adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (posPrefNull) { 445adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return null; 446adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 447866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getTextAttribute(this.address, UNUM_POSITIVE_PREFIX); 448adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 449adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 450adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public String getPositiveSuffix() { 451adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (posSuffNull) { 452adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project return null; 453adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 454866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getTextAttribute(this.address, UNUM_POSITIVE_SUFFIX); 455adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 456adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 457adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public boolean isDecimalSeparatorAlwaysShown() { 458866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_DECIMAL_ALWAYS_SHOWN) != 0; 459adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 460adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 461947eeb80f985827209c9500851e288504d58ec2eclaireho public boolean isParseBigDecimal() { 462947eeb80f985827209c9500851e288504d58ec2eclaireho return parseBigDecimal; 463947eeb80f985827209c9500851e288504d58ec2eclaireho } 464947eeb80f985827209c9500851e288504d58ec2eclaireho 465adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public boolean isParseIntegerOnly() { 466866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_PARSE_INT_ONLY) != 0; 467adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 468adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 469adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public boolean isGroupingUsed() { 470866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes return getAttribute(this.address, UNUM_GROUPING_USED) != 0; 471adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 472adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 473adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setDecimalSeparatorAlwaysShown(boolean value) { 474adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project int i = value ? -1 : 0; 475866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_DECIMAL_ALWAYS_SHOWN, i); 476adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 477adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 4788d07b07a3ed315c2e1c469d3769cf1df3f49e58bNeil Fuller public void setCurrency(String currencySymbol, String currencyCode) { 4798d07b07a3ed315c2e1c469d3769cf1df3f49e58bNeil Fuller setSymbol(this.address, UNUM_CURRENCY_SYMBOL, currencySymbol); 4808d07b07a3ed315c2e1c469d3769cf1df3f49e58bNeil Fuller setSymbol(this.address, UNUM_INTL_CURRENCY_SYMBOL, currencyCode); 481adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 482adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 483adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setGroupingSize(int value) { 484866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_GROUPING_SIZE, value); 485adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 486adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 487adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setGroupingUsed(boolean value) { 488adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project int i = value ? -1 : 0; 489866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_GROUPING_USED, i); 490adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 491adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 492adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setMaximumFractionDigits(int value) { 493866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_MAX_FRACTION_DIGITS, value); 494adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 495adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 496adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setMaximumIntegerDigits(int value) { 497866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_MAX_INTEGER_DIGITS, value); 498adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 499adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 500adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setMinimumFractionDigits(int value) { 501866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_MIN_FRACTION_DIGITS, value); 502adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 503adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 504adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setMinimumIntegerDigits(int value) { 505866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_MIN_INTEGER_DIGITS, value); 506adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 507adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 508adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setMultiplier(int value) { 509866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_MULTIPLIER, value); 510adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 511adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 512adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setNegativePrefix(String value) { 513adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project negPrefNull = value == null; 514adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (!negPrefNull) { 515866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setTextAttribute(this.address, UNUM_NEGATIVE_PREFIX, value); 516adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 517adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 518adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 519adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setNegativeSuffix(String value) { 520adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project negSuffNull = value == null; 521adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (!negSuffNull) { 522866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setTextAttribute(this.address, UNUM_NEGATIVE_SUFFIX, value); 523adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 524adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 525adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 526adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setPositivePrefix(String value) { 527adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project posPrefNull = value == null; 528adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (!posPrefNull) { 529866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setTextAttribute(this.address, UNUM_POSITIVE_PREFIX, value); 530adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 531adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 532adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 533adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setPositiveSuffix(String value) { 534adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project posSuffNull = value == null; 535adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project if (!posSuffNull) { 536866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setTextAttribute(this.address, UNUM_POSITIVE_SUFFIX, value); 537adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 538adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 539adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 540947eeb80f985827209c9500851e288504d58ec2eclaireho public void setParseBigDecimal(boolean value) { 541947eeb80f985827209c9500851e288504d58ec2eclaireho parseBigDecimal = value; 542947eeb80f985827209c9500851e288504d58ec2eclaireho } 543947eeb80f985827209c9500851e288504d58ec2eclaireho 544adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void setParseIntegerOnly(boolean value) { 545adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project int i = value ? -1 : 0; 546866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setAttribute(this.address, UNUM_PARSE_INT_ONLY, i); 547adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 548adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 54960b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static void applyPattern(long addr, boolean localized, String pattern) { 5501efbe3391e92e6188918122a600623090561364fElliott Hughes try { 5511efbe3391e92e6188918122a600623090561364fElliott Hughes applyPatternImpl(addr, localized, pattern); 5521efbe3391e92e6188918122a600623090561364fElliott Hughes } catch (NullPointerException npe) { 5531efbe3391e92e6188918122a600623090561364fElliott Hughes throw npe; 5541efbe3391e92e6188918122a600623090561364fElliott Hughes } catch (RuntimeException re) { 5551efbe3391e92e6188918122a600623090561364fElliott Hughes throw new IllegalArgumentException("syntax error: " + re.getMessage() + ": " + pattern); 5561efbe3391e92e6188918122a600623090561364fElliott Hughes } 5571efbe3391e92e6188918122a600623090561364fElliott Hughes } 5581efbe3391e92e6188918122a600623090561364fElliott Hughes 55942db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes public void setRoundingMode(RoundingMode roundingMode, double roundingIncrement) { 56042db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes final int nativeRoundingMode; 56142db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes switch (roundingMode) { 56242db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes case CEILING: nativeRoundingMode = 0; break; 56342db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes case FLOOR: nativeRoundingMode = 1; break; 56442db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes case DOWN: nativeRoundingMode = 2; break; 56542db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes case UP: nativeRoundingMode = 3; break; 56642db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes case HALF_EVEN: nativeRoundingMode = 4; break; 56742db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes case HALF_DOWN: nativeRoundingMode = 5; break; 56842db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes case HALF_UP: nativeRoundingMode = 6; break; 569c96651d01dc87a20aa718d60feaff6611451852eNeil Fuller case UNNECESSARY: nativeRoundingMode = 7; break; 57042db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes default: throw new AssertionError(); 57142db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes } 572866e7ae17a3da81a02b0b144e0c9c2b3196d293aElliott Hughes setRoundingMode(address, nativeRoundingMode, roundingIncrement); 57342db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes } 57442db7d138547e3bba75cf6ed02b6a319e30004aeElliott Hughes 575947eeb80f985827209c9500851e288504d58ec2eclaireho // Utility to get information about field positions from native (ICU) code. 576947eeb80f985827209c9500851e288504d58ec2eclaireho private static class FieldPositionIterator { 577947eeb80f985827209c9500851e288504d58ec2eclaireho private int[] data; 578947eeb80f985827209c9500851e288504d58ec2eclaireho private int pos = -3; // so first call to next() leaves pos at 0 579947eeb80f985827209c9500851e288504d58ec2eclaireho 580947eeb80f985827209c9500851e288504d58ec2eclaireho private FieldPositionIterator() { 581947eeb80f985827209c9500851e288504d58ec2eclaireho } 582947eeb80f985827209c9500851e288504d58ec2eclaireho 5833e6f49bbb915b880afe104ec784c66bda55da450Elliott Hughes public static FieldPositionIterator forFieldPosition(FieldPosition fp) { 58474473971cc9d960376295fbcc430320c9ed62991Elliott Hughes return (fp != null) ? new FieldPositionIterator() : null; 585947eeb80f985827209c9500851e288504d58ec2eclaireho } 586947eeb80f985827209c9500851e288504d58ec2eclaireho 587947eeb80f985827209c9500851e288504d58ec2eclaireho public boolean next() { 5888f9976752b2a6e834994ca5790025bc46a3ef340Elliott Hughes if (data == null) { 5898f9976752b2a6e834994ca5790025bc46a3ef340Elliott Hughes return false; 590947eeb80f985827209c9500851e288504d58ec2eclaireho } 591947eeb80f985827209c9500851e288504d58ec2eclaireho pos += 3; 592947eeb80f985827209c9500851e288504d58ec2eclaireho return pos < data.length; 593947eeb80f985827209c9500851e288504d58ec2eclaireho } 594947eeb80f985827209c9500851e288504d58ec2eclaireho 595947eeb80f985827209c9500851e288504d58ec2eclaireho public int fieldId() { 596947eeb80f985827209c9500851e288504d58ec2eclaireho return data[pos]; 597947eeb80f985827209c9500851e288504d58ec2eclaireho } 598947eeb80f985827209c9500851e288504d58ec2eclaireho 599947eeb80f985827209c9500851e288504d58ec2eclaireho public Format.Field field() { 60074473971cc9d960376295fbcc430320c9ed62991Elliott Hughes return ICU4C_FIELD_IDS[data[pos]]; 601947eeb80f985827209c9500851e288504d58ec2eclaireho } 602947eeb80f985827209c9500851e288504d58ec2eclaireho 603947eeb80f985827209c9500851e288504d58ec2eclaireho public int start() { 604947eeb80f985827209c9500851e288504d58ec2eclaireho return data[pos + 1]; 605947eeb80f985827209c9500851e288504d58ec2eclaireho } 606947eeb80f985827209c9500851e288504d58ec2eclaireho 607947eeb80f985827209c9500851e288504d58ec2eclaireho public int limit() { 608947eeb80f985827209c9500851e288504d58ec2eclaireho return data[pos + 2]; 609947eeb80f985827209c9500851e288504d58ec2eclaireho } 610947eeb80f985827209c9500851e288504d58ec2eclaireho 611947eeb80f985827209c9500851e288504d58ec2eclaireho // called by native 612947eeb80f985827209c9500851e288504d58ec2eclaireho private void setData(int[] data) { 613947eeb80f985827209c9500851e288504d58ec2eclaireho this.data = data; 614947eeb80f985827209c9500851e288504d58ec2eclaireho this.pos = -3; 615947eeb80f985827209c9500851e288504d58ec2eclaireho } 616947eeb80f985827209c9500851e288504d58ec2eclaireho } 617947eeb80f985827209c9500851e288504d58ec2eclaireho 61860b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native void applyPatternImpl(long addr, boolean localized, String pattern); 6191e5d730e58d94c3bfa14b7dde5ab3981fe5a170bElliott Hughes private static native long cloneImpl(long addr); 62060b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native void close(long addr); 62160b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native char[] formatLong(long addr, long value, FieldPositionIterator iter); 62260b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native char[] formatDouble(long addr, double value, FieldPositionIterator iter); 62360b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native char[] formatDigitList(long addr, String value, FieldPositionIterator iter); 62460b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native int getAttribute(long addr, int symbol); 62560b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native String getTextAttribute(long addr, int symbol); 62660b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native long open(String pattern, String currencySymbol, 62734eb0408ff03c10b8f5842d328457aeeabac17a7Elliott Hughes char decimalSeparator, char digit, String exponentSeparator, char groupingSeparator, 6284f3bca749bdc8be8abf7555b315f308a2c8c14a7Narayan Kamath String infinity, String internationalCurrencySymbol, String minusSign, 629a68116c0d8ff9cd517d6b765bf2b8930ed9a3e12Elliott Hughes char monetaryDecimalSeparator, String nan, char patternSeparator, String percent, 63034eb0408ff03c10b8f5842d328457aeeabac17a7Elliott Hughes char perMill, char zeroDigit); 63160b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native Number parse(long addr, String string, ParsePosition position, boolean parseBigDecimal); 63260b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native void setDecimalFormatSymbols(long addr, String currencySymbol, 63334eb0408ff03c10b8f5842d328457aeeabac17a7Elliott Hughes char decimalSeparator, char digit, String exponentSeparator, char groupingSeparator, 6344f3bca749bdc8be8abf7555b315f308a2c8c14a7Narayan Kamath String infinity, String internationalCurrencySymbol, String minusSign, 635a68116c0d8ff9cd517d6b765bf2b8930ed9a3e12Elliott Hughes char monetaryDecimalSeparator, String nan, char patternSeparator, String percent, 63634eb0408ff03c10b8f5842d328457aeeabac17a7Elliott Hughes char perMill, char zeroDigit); 63760b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native void setSymbol(long addr, int symbol, String str); 63860b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native void setAttribute(long addr, int symbol, int i); 63960b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native void setRoundingMode(long addr, int roundingMode, double roundingIncrement); 64060b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native void setTextAttribute(long addr, int symbol, String str); 64160b997f1a60b754cfa15f7b6ea7f1c3dadfaf43eJoel Dice private static native String toPatternImpl(long addr, boolean localized); 642adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project} 643