net.rim.device.api.i18n
Class Format

java.lang.Object
  extended by net.rim.device.api.i18n.Format
Direct Known Subclasses:
DateFormat, MessageFormat

public abstract class Format
extends Object

Defines fundamental functionality for classes that format locale-sensitive information.

Examples of information that might be locale-sensitive are dates, system messages, and numbers.

Compatible with java.text.Format from Java's standard edition.


Constructor Summary
protected Format()
          Constructs new Format instance.
 
Method Summary
 String format(Object obj)
          Retrieves formatted string representation of object.
abstract  StringBuffer format(Object obj, StringBuffer toAppendTo_o, FieldPosition pos_io)
          Retrieves formatted string represenatation of object in a string buffer.
abstract  int[] getFields()
          Retrieves ordered list of fields.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

Format

protected Format()
Constructs new Format instance.



Method Detail

format

public final String format(Object obj)
Retrieves formatted string representation of object.

Note: This method is not thread safe over each individual instance. No restrictions across instances.

Parameters:
obj - Object to format. This must always be an array.
Returns:
Formatted string representation of object.
Throws:
IllegalArgumentException - if the Format cannot format the given object

format

public abstract StringBuffer format(Object obj,
                                    StringBuffer toAppendTo_o,
                                    FieldPosition pos_io)
Retrieves formatted string represenatation of object in a string buffer.

Subclasses should override this method to format particular kinds of data objects, returning the results in a string buffer.

Parameters:
obj - Object to format.
toAppendTo_o - String buffer to hold the formatted results.
pos_io - If not null, this method should invoke Format.getFields() and set the begin/end for this field during formatting.
Returns:
String buffer containing formatted string representation of object.
Throws:
IllegalArgumentException - if the Format cannot format the given object

getFields

public abstract int[] getFields()
Retrieves ordered list of fields.

This method should return a list of fields, ordered left to right. Fields should only appear in this list if they exist in the format string used for formatting the output, or constraining the input. This information can then be used to determine the order in which the cursor traverses the information in a UI component that permits modification of the value in each format field.

Returns:
List of field identifiers for the fields in a format string.





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.