FieldPosition is a simple class used by Format
and its subclasses to identify fields in formatted output. Fields can
be identified in two ways:
_FIELD. The constants are defined in the various
subclasses of Format.
Format.Field constant, see ERA_FIELD
and its friends in DateFormat for an example.
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.
java.text.Format
| Modifier and Type | Class and Description |
|---|---|
| private class | FieldPosition.
An implementation of FieldDelegate that will adjust the begin/end of the FieldPosition if the arguments match the field of the FieldPosition. |
| Modifier and Type | Field and Description |
|---|---|
| private Format. | attribute
Desired field this FieldPosition is for. |
| pack-priv int | beginIndex
Output: Start offset of field in text. |
| pack-priv int | endIndex
Output: End offset of field in text. |
| pack-priv int | field
Input: Desired field to determine start and end offsets for. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | FieldPosition(Format.
Format.Field constant identifying a field attributeCreates a FieldPosition object for the given field constant. |
| public | FieldPosition(Format.
Format.Field constant identifying a field attribute,integer constant identifying a field fieldID)Creates a |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public int | Returns: the begin indexRetrieves the index of the first character in the requested field. |
| public int | Returns: the end indexRetrieves the index of the character following the last character in the requested field. |
| public int | |
| public Format. | Returns: Identifier for the fieldReturns the field identifier as an attribute constant
from one of the |
| pack-priv Format. | getFieldDelegate()
Returns a |
| public int | Returns: a hash code for this FieldPositionOverrides java. Returns a hash code for this FieldPosition. |
| private boolean | matchesField(Format.
Return true if the receiver wants a |
| private boolean | matchesField(Format.
Return true if the receiver wants a |
| public void | |
| public void | |
| public String | Returns: a string representation of this objectOverrides java. Return a string representation of this FieldPosition. |
| attribute | back to summary |
|---|---|
| private Format. Desired field this FieldPosition is for. | |
| beginIndex | back to summary |
|---|---|
| pack-priv int beginIndex Output: Start offset of field in text. If the field does not occur in the text, 0 is returned. | |
| endIndex | back to summary |
|---|---|
| pack-priv int endIndex Output: End offset of field in text. If the field does not occur in the text, 0 is returned. | |
| field | back to summary |
|---|---|
| pack-priv int field Input: Desired field to determine start and end offsets for. The meaning depends on the subclass of Format. | |
| FieldPosition | back to summary |
|---|---|
| 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.
| |
| FieldPosition | back to summary |
|---|---|
| public FieldPosition(Format. Creates a FieldPosition object for the given field constant. Fields are
identified by constants defined in the various | |
| FieldPosition | back to summary |
|---|---|
| public FieldPosition(Format. Creates a | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Overrides equals
| |
| getBeginIndex | back to summary |
|---|---|
| public int getBeginIndex() Retrieves the index of the first character in the requested field.
| |
| getEndIndex | back to summary |
|---|---|
| public int getEndIndex() Retrieves the index of the character following the last character in the requested field.
| |
| getField | back to summary |
|---|---|
| public int getField() Retrieves the field identifier.
| |
| getFieldAttribute | back to summary |
|---|---|
| public Format. Returns the field identifier as an attribute constant
from one of the | |
| getFieldDelegate | back to summary |
|---|---|
| pack-priv Format. Returns a | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hash code for this FieldPosition.
| |
| matchesField | back to summary |
|---|---|
| private boolean matchesField(Format. Return true if the receiver wants a | |
| matchesField | back to summary |
|---|---|
| private boolean matchesField(Format. Return true if the receiver wants a | |
| setBeginIndex | back to summary |
|---|---|
| public void setBeginIndex(int bi) Sets the begin index. For use by subclasses of Format.
| |
| setEndIndex | back to summary |
|---|---|
| public void setEndIndex(int ei) Sets the end index. For use by subclasses of Format.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Return a string representation of this FieldPosition.
| |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | encounteredField
Indicates whether the field has been encountered before. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void |
| encounteredField | back to summary |
|---|---|
| private boolean encounteredField Indicates whether the field has been encountered before. If this
is true, and | |
| Delegate | back to summary |
|---|---|
| private Delegate() | |
| formatted | back to summary |
|---|---|
| public void formatted(Format. Implements java. Doc from java. Notified when a particular region of the String is formatted. This
method will be invoked if there is no corresponding integer field id
matching | |
| formatted | back to summary |
|---|---|
| public void formatted(int fieldID, Format. Implements java. Doc from java. Notified when a particular region of the String is formatted. | |