java.lang.Object
java.text.ParsePosition
ParsePosition是一个简单的类,被Format及其子类用来在解析过程中跟踪当前位置。各种Format类中的parseObject方法需要一个ParsePosition对象作为参数。
设计上,当您使用不同格式解析字符串时,可以使用相同的ParsePosition,因为索引参数记录了当前位置。
- 自版本:
- 1.1
- 参见:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean覆盖equals方法int检索发生错误的索引位置,如果错误索引尚未设置,则返回-1。intgetIndex()检索当前解析位置。inthashCode()返回此ParsePosition的哈希码。voidsetErrorIndex(int ei) 设置发生解析错误的索引位置。voidsetIndex(int index) 设置当前解析位置。toString()返回此ParsePosition的字符串表示形式。
-
Constructor Details
-
ParsePosition
public ParsePosition(int index) 创建一个具有给定初始索引的新ParsePosition。- 参数:
-
index- 初始索引
-
-
Method Details
-
getIndex
public int getIndex()检索当前解析位置。在解析方法的输入中,这是解析将开始的字符的索引;在输出中,这是解析的最后一个字符之后的字符的索引。- 返回:
- 当前解析位置
-
setIndex
public void setIndex(int index) 设置当前解析位置。- 参数:
-
index- 当前解析位置
-
setErrorIndex
public void setErrorIndex(int ei) 设置发生解析错误的索引位置。格式化程序应在从其parseObject方法返回错误代码之前设置此值。如果未设置,则默认值为-1。- 参数:
-
ei- 发生错误的索引位置 - 自版本:
- 1.2
-
getErrorIndex
public int getErrorIndex()检索发生错误的索引位置,如果错误索引尚未设置,则返回-1。- 返回:
- 发生错误的索引位置
- 自版本:
- 1.2
-
equals
覆盖equals方法 -
hashCode
public int hashCode()返回此ParsePosition的哈希码。 -
toString
返回此ParsePosition的字符串表示形式。
-