public class FieldPosition extends Object
FieldPositionクラスは、フォーマットされた出力のフィールドを識別するためにFormatとそのサブクラスが使用する単純なクラスです。 フィールドは2つの方法で識別されます。 
 _FIELDで終わります。 定数はFormatのさまざまなサブクラスで定義されます。 
  Format.Field定数。使用例は、DateFormatのERA_FIELDなどを参照してください。
 
 FieldPositionは、フォーマットされた出力の中で、フィールドの最初の文字のインデックスとフィールドの最後の文字のインデックスの2つを使用してフィールドの位置を追跡します。
 
 さまざまなFormatクラスにおけるformatメソッドの1つのバージョンは、引数として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のサブクラスの1つからの属性定数としてフィールド識別子を返します。 | 
| int | hashCode() | このFieldPositionのハッシュ・コードを返します。 | 
| void | setBeginIndex(int bi) | 開始インデックスを設定します。 | 
| void | setEndIndex(int ei) | 終了インデックスを設定します。 | 
| String | toString() | このFieldPositionの文字列表現を返します。 | 
public FieldPosition(int field)
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サブクラスの1つからの属性定数や、Formatサブクラスで定義される整数型フィールドIDによって識別されます。 Fieldを認識するFormatサブクラスは、attributeがnullでない場合にattributeを優先し、fieldIDを無視します。 ただし、古いFormatサブクラスではFieldを認識せず、fieldIDに依存する場合があります。 フィールドが対応する整数型定数を持たない場合は、fieldIDは -1になります。 attribute - フィールドを識別するFormat.Field定数fieldID - フィールドを識別する整数型定数public Format.Field getFieldAttribute()
Fieldのサブクラスの1つからの属性定数としてフィールド識別子を返します。 フィールドが整数型フィールドIDだけによって指定される場合は、nullを返します。 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、クラスObjectobj - 比較対象の参照オブジェクト。true、それ以外の場合はfalse。Object.hashCode()、HashMappublic int hashCode()
hashCode、クラスObjectObject.equals(java.lang.Object), System.identityHashCode(java.lang.Object) バグまたは機能を送信 
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。 
 Copyright © 1993, 2025, Oracle and/or its affiliates.  All rights reserved.  Use is subject to license terms.  Documentation Redistribution Policyも参照してください。