FileDocCategorySizeDatePackage
RuleBasedNumberFormat.javaAPI DocAndroid 1.5 API8216Wed May 06 22:41:04 BST 2009com.ibm.icu4jni.text

RuleBasedNumberFormat

public class RuleBasedNumberFormat extends NumberFormat

Fields Summary
private int
addr
Constructors Summary
Methods Summary
public voidclose()
close a RuleBasedNumberFormat

        if(this.addr != 0) {
            closeRBNFImpl(this.addr);
            this.addr = 0;
        }
    
private static native voidcloseRBNFImpl(int addr)

protected voidfinalize()

        close();
    
public java.lang.StringBufferformat(long value, java.lang.StringBuffer buffer, java.text.FieldPosition field)


        if(buffer == null) {
            throw new NullPointerException();
        }
        
        String fieldType = null;
        
        if(field != null) {
            fieldType = getFieldType(field.getFieldAttribute());
        }
        
        String result = formatRBNFImpl(this.addr, value, field, 
                fieldType, null);
        
        buffer.append(result.toCharArray(), 0, result.length());
        
        return buffer;
    
public java.lang.StringBufferformat(double value, java.lang.StringBuffer buffer, java.text.FieldPosition field)


        if(buffer == null) {
            throw new NullPointerException();
        }
        
        String fieldType = null;
        
        if(field != null) {
            fieldType = getFieldType(field.getFieldAttribute());
        }
        
        String result = formatRBNFImpl(this.addr, value, field, 
                fieldType, null);
        
        buffer.append(result.toCharArray(), 0, result.length());
        
        return buffer;
    
private static native java.lang.StringformatRBNFImpl(int addr, long value, java.text.FieldPosition field, java.lang.String fieldType, java.lang.StringBuffer buffer)

private static native java.lang.StringformatRBNFImpl(int addr, double value, java.text.FieldPosition field, java.lang.String fieldType, java.lang.StringBuffer buffer)

private static java.lang.StringgetFieldType(java.text.Format$Field field)

        if(field == null) {
            return null;
        }
        if(field.equals(NumberFormat.Field.SIGN)) {
            return "sign";
        }
        if(field.equals(NumberFormat.Field.INTEGER)) {
            return "integer";
        }
        if(field.equals(NumberFormat.Field.FRACTION)) {
            return "fraction";
        }
        if(field.equals(NumberFormat.Field.EXPONENT)) {
            return "exponent";
        }
        if(field.equals(NumberFormat.Field.EXPONENT_SIGN)) {
            return "exponent_sign";
        }
        if(field.equals(NumberFormat.Field.EXPONENT_SYMBOL)) {
            return "exponent_symbol";
        }
        if(field.equals(NumberFormat.Field.CURRENCY)) {
            return "currency";
        }
        if(field.equals(NumberFormat.Field.GROUPING_SEPARATOR)) {
            return "grouping_separator";
        }
        if(field.equals(NumberFormat.Field.DECIMAL_SEPARATOR)) {
            return "decimal_separator";
        }
        if(field.equals(NumberFormat.Field.PERCENT)) {
            return "percent";
        }
        if(field.equals(NumberFormat.Field.PERMILLE)) {
            return "permille";
        }
        return null;
    
public voidopen(com.ibm.icu4jni.text.RuleBasedNumberFormat$RBNFType type)
Open a new rule based number format of selected type for the default location

param
type the type of rule based number format


                                  
        
        this.addr = openRBNFImpl(type.getType(),
                Locale.getDefault().toString());
    
public voidopen(com.ibm.icu4jni.text.RuleBasedNumberFormat$RBNFType type, java.util.Locale locale)
Open a new rule based number format of selected type for the given location

param
type the type of rule based number format
param
locale the locale to use for this rule based number format

        String loc = locale.toString();
        if (loc == null) {
            throw new NullPointerException();
        }
        this.addr = openRBNFImpl(type.getType(), loc);
    
public voidopen(java.lang.String rule)
Open a new rule based number format for the default location. The rule passed to the method has to be of the form described in the ibm icu documentation for RuleBasedNumberFormat.

param
rule the rule for the rule based number format

        if (rule == null) {
            throw new NullPointerException();
        }
        this.addr = openRBNFImpl(rule, Locale.getDefault().toString());
    
public voidopen(java.lang.String rule, java.util.Locale locale)
Open a new rule based number format for the given location. The rule passed to the method has to be of the form described in the ibm icu documentation for RuleBasedNumberFormat.

param
rule the rule for the rule based number format
param
locale the locale to use for this rule based number format

        String loc = locale.toString();
        if (loc == null || rule == null) {
            throw new NullPointerException();
        }
        this.addr = openRBNFImpl(rule, locale.toString());
    
private static native intopenRBNFImpl(int type, java.lang.String loc)

private static native intopenRBNFImpl(java.lang.String rule, java.lang.String loc)

public java.lang.Numberparse(java.lang.String string, java.text.ParsePosition position)

        if (string == null || position == null) {
            throw new NullPointerException();
        }
        return parseRBNFImpl(this.addr, string, position, false);
    
public java.lang.NumberparseLenient(java.lang.String string, java.text.ParsePosition position)
This method has the same functionality as {@link #parse(String, ParsePosition)} But it uses lenient parsing. This means it also accepts strings that differ from the correct writing (e.g. case or umlaut differences).

param
string the string to parse
param
position the ParsePosition, updated on return with the index following the parsed text, or on error the index is unchanged and the error index is set to the index where the error occurred
return
the Number resulting from the parse, or null if there is an error

        if (string == null || position == null) {
            throw new NullPointerException();
        }
        return parseRBNFImpl(this.addr, string, position, true);
    
static native java.lang.NumberparseRBNFImpl(int addr, java.lang.String string, java.text.ParsePosition position, boolean lenient)