public class FieldPosition extends Object
FieldPosition是一个简单的类及其子类的
Format用于识别在格式化输出字段。字段可以有两种方式确定:
_FIELD。常数是在Format各子类定义。Format.Field常数,见例ERA_FIELD和DateFormat朋友。FieldPosition跟踪领域的地位在格式化输出有两个指标:该字段的第一个字符的索引和字段的最后一个字符的索引。
在各种Format类的一个版本的format方法需要一个FieldPosition对象作为实参。你用这个format法进行局部格式或获得关于格式化输出信息(如一个字段的位置)。
如果你有兴趣在位置的格式化字符串中的所有属性的使用方法formatToCharacterIterator Format。
Format
| Constructor and Description |
|---|
FieldPosition(Format.Field attribute)
为给定的场恒定的力场排斥的对象。
|
FieldPosition(Format.Field attribute, int fieldID)
为给定的领域
FieldPosition对象。
|
FieldPosition(int field)
为给定的场力场排斥的对象。
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
重写equals
|
int |
getBeginIndex()
检索所请求字段中的第一个字符的索引。
|
int |
getEndIndex()
检索所请求字段中的最后一个字符后的字符的索引。
|
int |
getField()
检索字段标识符。
|
Format.Field |
getFieldAttribute()
返回作为一个属性之一,
Field类常量标识符字段。
|
int |
hashCode()
返回此力场排斥的哈希代码。
|
void |
setBeginIndex(int bi)
设置开始索引。
|
void |
setEndIndex(int ei)
设置结束索引。
|
String |
toString()
返回字符串表示这个力场排斥。
|
public FieldPosition(int field)
field的字段标识符
NumberFormat.INTEGER_FIELD,
NumberFormat.FRACTION_FIELD,
DateFormat.YEAR_FIELD,
DateFormat.MONTH_FIELD
public FieldPosition(Format.Field attribute)
Format子类定义常数的确定。这相当于调用
new FieldPosition(attribute, -1)。
attribute格式。场常数识别领域
public FieldPosition(Format.Field attribute, int fieldID)
FieldPosition对象。字段是一个恒定的属性从一个
Field亚类鉴定以及由
Format子类定义的ID的整数字段。
Format子类,都知道
Field应优先
attribute如果
attribute不空忽视
fieldID。然而,老
Format子可能不知道
Field依靠
fieldID。如果现场没有相应的整数常数,
fieldID应- 1。
attribute格式。场常数识别领域
fieldID整数常数识别领域
public Format.Field getFieldAttribute()
Field类常量标识符字段。可以返回为空,如果字段是由一个整数字段标识指定。
public int getField()
public int getBeginIndex()
public int getEndIndex()
public void setBeginIndex(int bi)
bi -开始指数
public void setEndIndex(int ei)
ei结束-指数
public boolean equals(Object obj)
equals 方法重写,继承类
Object
obj -参考对象的比较。
true obj参数相同;
false否则。
Object.hashCode(),
HashMap
public int hashCode()
hashCode 方法重写,继承类
Object
Object.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)
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.