|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjava.text.FieldPosition
public class FieldPosition
FieldPosition 是 Format 及其子類別用於在格式輸出中標識欄位的簡單類別。欄位可以通過兩種方式標識:
_FIELD 結尾的整型常數。這些常數在 Format 的不同子類別中定義。
Format.Field 常數,有關例子,請參閱 DateFormat 中的 ERA_FIELD 及其同類別。
FieldPosition 保持對格式輸出中欄位位置的兩個索引進行追蹤:欄位的第一個字元的索引和欄位的最後一個字元的索引。
不同的 Format 類別中的 format 方法需要一個 FieldPosition 物件作為參數。使用此 format 方法執行部分格式化或者以獲取格式化輸出的資訊(比如欄位位置)。
如果對格式化字元串中所有屬性的位置感興趣,請使用 Format 的方法 formatToCharacterIterator。
Format| 建構子摘要 | |
|---|---|
FieldPosition(Format.Field attribute)
為給定的欄位常數創建一個 FieldPosition 物件。 |
|
FieldPosition(Format.Field attribute,
int fieldID)
為給定的欄位創建一個 FieldPosition 物件。 |
|
FieldPosition(int field)
為給定欄位創建一個 FieldPosition 物件。 |
|
| 方法摘要 | |
|---|---|
boolean |
equals(Object obj)
覆寫 equals |
int |
getBeginIndex()
獲取請求欄位中第一個字元的索引。 |
int |
getEndIndex()
獲取緊跟請求欄位中最後一個字元的字元索引。 |
int |
getField()
獲取欄位的標識符。 |
Format.Field |
getFieldAttribute()
以來自 Field 子類別之一的屬性常數返回該欄位的標識符。 |
int |
hashCode()
返回此 FieldPosition 的雜湊碼。 |
void |
setBeginIndex(int bi)
設置起始索引。 |
void |
setEndIndex(int ei)
Sets the end index.由 Format 的子類別使用。 |
String |
toString()
返回此 FieldPosition 的字元串表示形式。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| 建構子詳細資訊 |
|---|
public FieldPosition(int field)
NumberFormat.INTEGER_FIELD,
NumberFormat.FRACTION_FIELD,
DateFormat.YEAR_FIELD,
DateFormat.MONTH_FIELDpublic FieldPosition(Format.Field attribute)
Format 子類別中定義的常數來標識。這等效於調用 new FieldPosition(attribute, -1)。
attribute - 標識一個欄位的 Format.Field 常數
public FieldPosition(Format.Field attribute,
int fieldID)
FieldPosition 物件。欄位由來自 Field 的子類別之一的屬性常數以及一個由 Format 的子類別定義的整型欄位 ID 標識。當 attribute 不為 null 時,需要使用 Field 的 Format 子類別應當優先考慮 attribute 而忽略 fieldID。不過,舊的 Format 子類別可能不知道 Field 而依靠 fieldID。如果該欄位沒有相應的整型常數,則 fieldID 應為 -1。
attribute - 標識一個欄位的 Format.Field 常數fieldID - 標識一個欄位的整型常數| 方法詳細資訊 |
|---|
public Format.Field getFieldAttribute()
Field 子類別之一的屬性常數返回該欄位的標識符。如果該欄位僅由一個整型欄位 ID 指定時,可能返回 null。
public int getField()
public int getBeginIndex()
public int getEndIndex()
public void setBeginIndex(int bi)
public void setEndIndex(int ei)
public boolean equals(Object obj)
Object 中的 equalsobj - 要與之比較的參考物件。
true;否則返回 false。Object.hashCode(),
Hashtablepublic int hashCode()
Object 中的 hashCodeObject.equals(java.lang.Object),
Hashtablepublic String toString()
Object 中的 toString
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。