java.text
Class FieldPosition

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.text.FieldPosition

public class FieldPosition
extends Object sample code for java.lang.Object definition code for java.lang.Object

FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted output. Fields can be identified in two ways:

FieldPosition keeps track of the position of the field within the formatted output with two indices: the index of the first character of the field and the index of the last character of the field.

One version of the format method in the various Format classes requires a FieldPosition object as an argument. You use this format method to perform partial formatting or to get information about the formatted output (such as the position of a field).

If you are interested in the positions of all attributes in the formatted string use the Format method formatToCharacterIterator.

See Also:
Format sample code for java.text.Format definition code for java.text.Format

Constructor Summary
FieldPosition sample code for java.text.FieldPosition.FieldPosition(java.text.Format.Field) definition code for java.text.FieldPosition.FieldPosition(java.text.Format.Field) (Format.Field sample code for java.text.Format.Field definition code for java.text.Format.Field  attribute)
          Creates a FieldPosition object for the given field constant.
FieldPosition sample code for java.text.FieldPosition.FieldPosition(java.text.Format.Field, int) definition code for java.text.FieldPosition.FieldPosition(java.text.Format.Field, int) (Format.Field sample code for java.text.Format.Field definition code for java.text.Format.Field  attribute, int fieldID)
          Creates a FieldPosition object for the given field.
FieldPosition sample code for java.text.FieldPosition.FieldPosition(int) definition code for java.text.FieldPosition.FieldPosition(int) (int field)
          Creates a FieldPosition object for the given field.
 
Method Summary
 boolean equals sample code for java.text.FieldPosition.equals(java.lang.Object) definition code for java.text.FieldPosition.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Overrides equals
 int getBeginIndex sample code for java.text.FieldPosition.getBeginIndex() definition code for java.text.FieldPosition.getBeginIndex() ()
          Retrieves the index of the first character in the requested field.
 int getEndIndex sample code for java.text.FieldPosition.getEndIndex() definition code for java.text.FieldPosition.getEndIndex() ()
          Retrieves the index of the character following the last character in the requested field.
 int getField sample code for java.text.FieldPosition.getField() definition code for java.text.FieldPosition.getField() ()
          Retrieves the field identifier.
 Format.Field sample code for java.text.Format.Field definition code for java.text.Format.Field getFieldAttribute sample code for java.text.FieldPosition.getFieldAttribute() definition code for java.text.FieldPosition.getFieldAttribute() ()
          Returns the field identifier as an attribute constant from one of the Field subclasses.
 int hashCode sample code for java.text.FieldPosition.hashCode() definition code for java.text.FieldPosition.hashCode() ()
          Returns a hash code for this FieldPosition.
 void setBeginIndex sample code for java.text.FieldPosition.setBeginIndex(int) definition code for java.text.FieldPosition.setBeginIndex(int) (int bi)
          Sets the begin index.
 void setEndIndex sample code for java.text.FieldPosition.setEndIndex(int) definition code for java.text.FieldPosition.setEndIndex(int) (int ei)
          Sets the end index.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.text.FieldPosition.toString() definition code for java.text.FieldPosition.toString() ()
          Return a string representation of this FieldPosition.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

FieldPosition sample code for java.text.FieldPosition(int) definition code for java.text.FieldPosition(int)

public FieldPosition(int field)
Creates a FieldPosition object for the given field. Fields are identified by constants, whose names typically end with _FIELD, in the various subclasses of Format.

See Also:
NumberFormat.INTEGER_FIELD sample code for java.text.NumberFormat.INTEGER_FIELD definition code for java.text.NumberFormat.INTEGER_FIELD , NumberFormat.FRACTION_FIELD sample code for java.text.NumberFormat.FRACTION_FIELD definition code for java.text.NumberFormat.FRACTION_FIELD , DateFormat.YEAR_FIELD sample code for java.text.DateFormat.YEAR_FIELD definition code for java.text.DateFormat.YEAR_FIELD , DateFormat.MONTH_FIELD sample code for java.text.DateFormat.MONTH_FIELD definition code for java.text.DateFormat.MONTH_FIELD

FieldPosition sample code for java.text.FieldPosition(java.text.Format.Field) definition code for java.text.FieldPosition(java.text.Format.Field)

public FieldPosition(Format.Field sample code for java.text.Format.Field definition code for java.text.Format.Field  attribute)
Creates a FieldPosition object for the given field constant. Fields are identified by constants defined in the various Format subclasses. This is equivalent to calling new FieldPosition(attribute, -1).

Parameters:
attribute - Format.Field constant identifying a field
Since:
1.4

FieldPosition sample code for java.text.FieldPosition(java.text.Format.Field, int) definition code for java.text.FieldPosition(java.text.Format.Field, int)

public FieldPosition(Format.Field sample code for java.text.Format.Field definition code for java.text.Format.Field  attribute,
                     int fieldID)
Creates a FieldPosition object for the given field. The field is identified by an attribute constant from one of the Field subclasses as well as an integer field ID defined by the Format subclasses. Format subclasses that are aware of Field should give precedence to attribute and ignore fieldID if attribute is not null. However, older Format subclasses may not be aware of Field and rely on fieldID. If the field has no corresponding integer constant, fieldID should be -1.

Parameters:
attribute - Format.Field constant identifying a field
fieldID - integer constantce identifying a field
Since:
1.4
Method Detail

getFieldAttribute sample code for java.text.FieldPosition.getFieldAttribute() definition code for java.text.FieldPosition.getFieldAttribute()

public Format.Field sample code for java.text.Format.Field definition code for java.text.Format.Field  getFieldAttribute()
Returns the field identifier as an attribute constant from one of the Field subclasses. May return null if the field is specified only by an integer field ID.

Returns:
Identifier for the field
Since:
1.4

getField sample code for java.text.FieldPosition.getField() definition code for java.text.FieldPosition.getField()

public int getField()
Retrieves the field identifier.


getBeginIndex sample code for java.text.FieldPosition.getBeginIndex() definition code for java.text.FieldPosition.getBeginIndex()

public int getBeginIndex()
Retrieves the index of the first character in the requested field.


getEndIndex sample code for java.text.FieldPosition.getEndIndex() definition code for java.text.FieldPosition.getEndIndex()

public int getEndIndex()
Retrieves the index of the character following the last character in the requested field.


setBeginIndex sample code for java.text.FieldPosition.setBeginIndex(int) definition code for java.text.FieldPosition.setBeginIndex(int)

public void setBeginIndex(int bi)
Sets the begin index. For use by subclasses of Format.

Since:
1.2

setEndIndex sample code for java.text.FieldPosition.setEndIndex(int) definition code for java.text.FieldPosition.setEndIndex(int)

public void setEndIndex(int ei)
Sets the end index. For use by subclasses of Format.

Since:
1.2

equals sample code for java.text.FieldPosition.equals(java.lang.Object) definition code for java.text.FieldPosition.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Overrides equals

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

hashCode sample code for java.text.FieldPosition.hashCode() definition code for java.text.FieldPosition.hashCode()

public int hashCode()
Returns a hash code for this FieldPosition.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a hash code value for this object
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

toString sample code for java.text.FieldPosition.toString() definition code for java.text.FieldPosition.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Return a string representation of this FieldPosition.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of this object