FieldPosition


FieldPosition java.text

Java 1.1

FieldPosition objects are optionally passed to the format( ) methods of the Format class and its subclasses to return information about the start and end positions of a specific part or "field" of the formatted string. This kind of information is often useful for aligning formatted strings in columnsfor example, aligning the decimal points in a column of numbers .

The field of interest is specified when the FieldPosition( ) constructor is called. The NumberFormat and DateFormat classes define integer various constants (which end with the string _FIELD ) that can be used here. In Java 1.4 and later you can also construct a FieldPosition by specifying the Format.Field object that identifies the field. (For constant Field instances, see DateFormat.Field , MessageFormat.Field and NumberFormat.Field .)

After a FieldPosition has been created and passed to a format( ) method, use getBeginIndex( ) and getEndIndex( ) methods of this class to obtain the starting and ending character positions of the desired field of the formatted string.

 public class  FieldPosition  {  // Public Constructors   1.4  public  FieldPosition  (Format.Field  attribute  );        public  FieldPosition  (int  field  );  1.4  public  FieldPosition  (Format.Field  attribute  , int  fieldID  );  // Public Instance Methods  public int  getBeginIndex  ( );        public int  getEndIndex  ( );        public int  getField  ( );  1.4  public Format.Field  getFieldAttribute  ( );  1.2  public void  setBeginIndex  (int  bi  );  1.2  public void  setEndIndex  (int  ei  );  // Public Methods Overriding Object   1.2  public boolean  equals  (Object  obj  );  1.2  public int  hashCode  ( );  1.2  public String  toString  ( );   } 

Passed To

ChoiceFormat.format( ) , DateFormat.format( ) , DecimalFormat.format( ) , Format.format( ) , MessageFormat.format( ) , NumberFormat.format( ) , SimpleDateFormat.format( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net