NumberFormatSymbolspublic class NumberFormatSymbols extends Object implements SerializableResourceThis class represents the set of symbols (such as the decimal separator,
the grouping separator, and so on) needed by NumberFormat to
format numbers. NumberFormatSymbols could be instantiated and
setup by user but recommended is to get it from ResourceManager
repectively DevResourceManager.getNumberFormatSymbols()
already initialized. All fields are left public intentionaly. |
Fields Summary |
---|
public String[] | currenciessupported currencies with codes. example: {"JPY", "Y"} | public String | currencySymbolcurrency symbol. | public String | intlCurrencySymbolinternational currency symbol "USD". | public char | monetarySeparatormonetary separator. | public char | zeroDigitzero digit. | public char | groupingSeparatorgrouping separator ','. | public char | decimalSeparatordecimal separator '.'. | public char | percentpercent sign '%'. | public char | perMillepermill sign. | public char | minusSignminus sign. | public String | infinityinfinity. | public String | NaNNaN string. | public boolean | decimalSeparatorAlwaysShownalways show decimal separator. | public String[] | positivePrefixprefixes for positive numbers for all styles. | public String[] | positiveSuffixsuffixes for positive numbers for all styles. | public String[] | negativePrefixprefixes for negative numbers for all styles. | public String[] | negativeSuffixsuffixes for negative numbers for all styles. | public boolean | groupingUsedis grouping symbol used. | public int | groupingCountcount of digits int the group. | public String[] | prefixesprefix for all styles (always at least used for currency). | public String[] | suffixessuffix for all styles (always used for percentage style). | public int[] | maximumIntegerDigitsmaximum integer digits -1 stands for not specified (use
maximum allowed). | public int[] | minimumIntegerDigitsminimum integer digits at least 1. | public int[] | maximumFractionDigitsmaximum fraction digits -1 stands for not specified (use
maximum allowed) integer has always 0 percentage has ussualy 0. | public int[] | minimumFractionDigitsminimum fraction digits. | public int[] | multipliermultiplier is always 1 but for percentage style is 100. | public String | localelocale of this symbols. |
Constructors Summary |
---|
public NumberFormatSymbols()Creates DecimalFormatSymbols instance uninitialized. All
necessary number symbols and styles must be set before using the
instance. Ussually DecimalFormatSymbols is obtained using
DevResourceManager.getNumberFormatSymbols() .
|
Methods Summary |
---|
public java.lang.Object | clone()The method clones resource.
NumberFormatSymbols newNfs = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
write(baos);
baos.close();
byte[] buffer = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
newNfs = new NumberFormatSymbols();
newNfs.read(bais);
} catch (IOException ioe) {
// cannot clone resource
}
return newNfs;
| public void | read(java.io.InputStream in)Reads NumberFormatSymbol from input stream.
DataInputStream dis = new DataInputStream(in);
currencySymbol = dis.readUTF();
intlCurrencySymbol = dis.readUTF();
monetarySeparator = dis.readChar();
zeroDigit = dis.readChar();
groupingSeparator = dis.readChar();
decimalSeparator = dis.readChar();
percent = dis.readChar();
perMille = dis.readChar();
minusSign = dis.readChar();
infinity = dis.readUTF();
NaN = dis.readUTF();
decimalSeparatorAlwaysShown = dis.readBoolean();
readStrings(positivePrefix, dis);
readStrings(positiveSuffix, dis);
readStrings(negativePrefix, dis);
readStrings(negativeSuffix, dis);
groupingUsed = dis.readBoolean();
groupingCount = dis.readInt();
readStrings(prefixes, dis);
readStrings(suffixes, dis);
readIntArray(maximumIntegerDigits, dis);
readIntArray(minimumIntegerDigits, dis);
readIntArray(maximumFractionDigits, dis);
readIntArray(minimumFractionDigits, dis);
readIntArray(multiplier, dis);
int currenciesLen = dis.readInt();
currencies = new String[currenciesLen][2];
for(int i = 0; i < currenciesLen; i++ ) {
readStrings(currencies[i], dis);
}
| protected void | readIntArray(int[] array, java.io.DataInputStream dis)Helper method reads array of integers.
for (int i = 0; i < array.length; i++) {
array[i] = dis.readInt();
}
| protected void | readStrings(java.lang.String[] array, java.io.DataInputStream dis)Helper method reads array of objects.
for (int i = 0; i < array.length; i++) {
array[i] = dis.readUTF();
}
| public void | write(java.io.OutputStream out)Write NumberFormatSymbols object into output stream.
DataOutputStream dous = new DataOutputStream(out);
dous.writeUTF(currencySymbol);
dous.writeUTF(intlCurrencySymbol);
dous.writeChar(monetarySeparator);
dous.writeChar(zeroDigit);
dous.writeChar(groupingSeparator);
dous.writeChar(decimalSeparator);
dous.writeChar(percent);
dous.writeChar(perMille);
dous.writeChar(minusSign);
dous.writeUTF(infinity);
dous.writeUTF(NaN);
dous.writeBoolean(decimalSeparatorAlwaysShown);
writeStrings(positivePrefix, dous);
writeStrings(positiveSuffix, dous);
writeStrings(negativePrefix, dous);
writeStrings(negativeSuffix, dous);
dous.writeBoolean(groupingUsed);
dous.writeInt(groupingCount);
writeStrings(prefixes, dous);
writeStrings(suffixes, dous);
writeIntArray(maximumIntegerDigits, dous);
writeIntArray(minimumIntegerDigits, dous);
writeIntArray(maximumFractionDigits, dous);
writeIntArray(minimumFractionDigits, dous);
writeIntArray(multiplier, dous);
dous.writeInt(currencies.length);
for (int i = 0; i < currencies.length; i++) {
writeStrings(currencies[i], dous);
}
| protected void | writeIntArray(int[] array, java.io.DataOutputStream dous)Helper method writes integer array.
for (int i = 0; i < array.length; i++) {
dous.writeInt(array[i]);
}
| protected void | writeStrings(java.lang.String[] array, java.io.DataOutputStream dous)Write array of strings.
for (int i = 0; i < array.length; i++) {
dous.writeUTF(array[i]);
}
|
|