if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="FieldPosition (Java Platform SE 7 )";
}
//-->
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
Class FieldPosition
- java.lang.Object
-
- java.text.FieldPosition
-
public class FieldPosition
extends Object
FieldPosition
is a simple class used byFormat
and its subclasses to identify fields in formatted output. Fields can
be identified in two ways:
- By an integer constant, whose names typically end with
_FIELD
. The constants are defined in the varioussubclasses of
Format
. - By a
Format.Field
constant, seeERA_FIELD
and its friends in
DateFormat
for an example.
FieldPosition
keeps track of the position of thefield 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 variousFormat
classes requires aFieldPosition
object as an argument. You use this
format
methodto 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
methodformatToCharacterIterator
.-
See Also:
-
Format
- By an integer constant, whose names typically end with
-
Constructor Summary
Constructors Constructor and Description FieldPosition(Format.Field attribute)
Creates a FieldPosition object for the given field constant.FieldPosition(Format.Field attribute,
int fieldID)
Creates aFieldPosition
object for the given field.FieldPosition(int field)
Creates a FieldPosition object for the given field.
Method Summary
Methods Modifier and Type Method and Description boolean
equals(Object obj)
Overrides equalsint
getBeginIndex()
Retrieves the index of the first character in the requested field.int
getEndIndex()
Retrieves the index of the character following the last character in therequested field.
int
getField()
Retrieves the field identifier.Format.Field
getFieldAttribute()
Returns the field identifier as an attribute constantfrom one of the
Field
subclasses.int
hashCode()
Returns a hash code for this FieldPosition.void
setBeginIndex(int bi)
Sets the begin index.void
setEndIndex(int ei)
Sets the end index.String
toString()
Return a string representation of this FieldPosition.
-
Constructor Detail
FieldPosition
public FieldPosition(int field)
Creates a FieldPosition object for the given field. Fields areidentified by constants, whose names typically end with _FIELD,
in the various subclasses of Format.
FieldPosition
public FieldPosition(Format.Field attribute)
Creates a FieldPosition object for the given field constant. Fields areidentified 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
public FieldPosition(Format.Field attribute,
int fieldID)
Creates aFieldPosition
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 IDdefined by the
Format
subclasses.Format
subclasses that are aware of
Field
should give precedenceto
attribute
and ignorefieldID
ifattribute
is not null. However, olderFormat
subclasses may not be aware of
Field
and rely onfieldID
. If the field has no corresponding integerconstant,
fieldID
should be -1.-
Parameters:
-
attribute
- Format.Field constant identifying a field -
fieldID
- integer constantce identifying a field
Since:
- 1.4
-
Method Detail
getFieldAttribute
public Format.Field getFieldAttribute()
Returns the field identifier as an attribute constantfrom one of the
Field
subclasses. May return null ifthe field is specified only by an integer field ID.
-
Returns:
- Identifier for the field Since:
- 1.4
getField
public int getField()
Retrieves the field identifier.
getBeginIndex
public int getBeginIndex()
Retrieves the index of the first character in the requested field.
getEndIndex
public int getEndIndex()
Retrieves the index of the character following the last character in therequested field.
setBeginIndex
public void setBeginIndex(int bi)
Sets the begin index. For use by subclasses of Format.-
Since:
- 1.2
setEndIndex
public void setEndIndex(int ei)
Sets the end index. For use by subclasses of Format.-
Since:
- 1.2
equals
public boolean equals(Object obj)
Overrides equals-
Overrides:
-
equals
in classObject
Parameters:
-
obj
- the reference object with which to compare.
Returns:
-
true
if this object is the same as the objargument;
false
otherwise.
See Also:
-
Object.hashCode()
,
-
hashCode
public int hashCode()
Returns a hash code for this FieldPosition.-
Overrides:
-
hashCode
in classObject
Returns:
- a hash code value for this object See Also:
-
Object.equals(java.lang.Object)
,
-
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.
一键复制
编辑
Web IDE
原始数据
按行查看
历史