FileDocCategorySizeDatePackage
NumberFormatSymbols.javaAPI DocphoneME MR2 API (J2ME)11107Wed May 02 18:00:46 BST 2007com.sun.j2me.global

NumberFormatSymbols

public class NumberFormatSymbols extends Object implements SerializableResource
This 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[]
currencies
supported currencies with codes. example: {"JPY", "Y"}
public String
currencySymbol
currency symbol.
public String
intlCurrencySymbol
international currency symbol "USD".
public char
monetarySeparator
monetary separator.
public char
zeroDigit
zero digit.
public char
groupingSeparator
grouping separator ','.
public char
decimalSeparator
decimal separator '.'.
public char
percent
percent sign '%'.
public char
perMille
permill sign.
public char
minusSign
minus sign.
public String
infinity
infinity.
public String
NaN
NaN string.
public boolean
decimalSeparatorAlwaysShown
always show decimal separator.
public String[]
positivePrefix
prefixes for positive numbers for all styles.
public String[]
positiveSuffix
suffixes for positive numbers for all styles.
public String[]
negativePrefix
prefixes for negative numbers for all styles.
public String[]
negativeSuffix
suffixes for negative numbers for all styles.
public boolean
groupingUsed
is grouping symbol used.
public int
groupingCount
count of digits int the group.
public String[]
prefixes
prefix for all styles (always at least used for currency).
public String[]
suffixes
suffix for all styles (always used for percentage style).
public int[]
maximumIntegerDigits
maximum integer digits -1 stands for not specified (use maximum allowed).
public int[]
minimumIntegerDigits
minimum integer digits at least 1.
public int[]
maximumFractionDigits
maximum fraction digits -1 stands for not specified (use maximum allowed) integer has always 0 percentage has ussualy 0.
public int[]
minimumFractionDigits
minimum fraction digits.
public int[]
multiplier
multiplier is always 1 but for percentage style is 100.
public String
locale
locale 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.Objectclone()
The method clones resource.

return
cloned resource or null if clonning wasn't possible.

        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 voidread(java.io.InputStream in)
Reads NumberFormatSymbol from input stream.

param
in input stream to read from
throws
IOException exception when read failed
throws
ResourceException exception when resource cannot be created



                                                                                               
          
                                                     
        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 voidreadIntArray(int[] array, java.io.DataInputStream dis)
Helper method reads array of integers.

param
array array of integers
param
dis input stream to read from
throws
IOException thrown when reading fails

        for (int i = 0; i < array.length; i++) {
            array[i] = dis.readInt();
        }
    
protected voidreadStrings(java.lang.String[] array, java.io.DataInputStream dis)
Helper method reads array of objects.

param
array array to read strings into
param
dis input stream to read from
throws
IOException when reading fails

        for (int i = 0; i < array.length; i++) {
            array[i] = dis.readUTF();
        }
    
public voidwrite(java.io.OutputStream out)
Write NumberFormatSymbols object into output stream.

param
out output stream
throws
IOException thrown when write failed
throws
ResourceException thrown when problem with resource occured

        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 voidwriteIntArray(int[] array, java.io.DataOutputStream dous)
Helper method writes integer array.

param
array array of integer
param
dous output stream to write to
throws
IOException thrown when writing fails

        for (int i = 0; i < array.length; i++) {
            dous.writeInt(array[i]);
        }
    
protected voidwriteStrings(java.lang.String[] array, java.io.DataOutputStream dous)
Write array of strings.

param
array object array to write
param
dous output stream to write to
throws
IOException thrown if writing fails

        for (int i = 0; i < array.length; i++) {
            dous.writeUTF(array[i]);
        }