JavaTM 2 Platform
Standard Ed. 5.0

java.text
クラス FieldPosition

java.lang.Object
  上位を拡張 java.text.FieldPosition

public class FieldPosition
extends Object

FieldPositionFormat で使用される単純なクラスであり、またフォーマット出力においてフィールドを識別するサブクラスです。フィールドは 2 つの方法で識別されます。

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 の文字列表現を返します。
 
クラス java.lang.Object から継承されたメソッド
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

FieldPosition

public FieldPosition(int field)
指定されたフィールドのための FieldPosition オブジェクトを生成します。フィールドは、Format のさまざまなサブクラスでの定数で識別されます。定数の名前は通常、_FIELD で終わります。

関連項目:
NumberFormat.INTEGER_FIELD, NumberFormat.FRACTION_FIELD, DateFormat.YEAR_FIELD, DateFormat.MONTH_FIELD

FieldPosition

public FieldPosition(Format.Field attribute)
指定されたフィールド定数のための FieldPosition オブジェクトを生成します。フィールドは、さまざまな Format サブクラスで定義される定数で識別されます。これは、new FieldPosition(attribute, -1) の呼び出しと同等です。

パラメータ:
attribute - フィールドを識別する Format.Field 定数
導入されたバージョン:
1.4

FieldPosition

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 - フィールドを識別する整数型定数
導入されたバージョン:
1.4
メソッドの詳細

getFieldAttribute

public Format.Field getFieldAttribute()
Field のサブクラスの 1 つからの属性定数としてフィールド識別子を返します。フィールドが整数型フィールド ID だけによって指定される場合は、null を返します。

戻り値:
フィールドの識別子
導入されたバージョン:
1.4

getField

public int getField()
フィールド識別子を取得します。


getBeginIndex

public int getBeginIndex()
要求されたフィールドで最初の文字のインデックスを取得します。


getEndIndex

public int getEndIndex()
要求されたフィールドで最後の文字に続く文字のインデックスを取得します。


setBeginIndex

public void setBeginIndex(int bi)
開始インデックスを設定します。Format のサブクラスが使用します。


setEndIndex

public void setEndIndex(int ei)
終了インデックスを設定します。Format のサブクラスが使用します。


equals

public boolean equals(Object obj)
equals をオーバーライドします。

オーバーライド:
クラス Object 内の equals
パラメータ:
obj - 比較対象の参照オブジェクト
戻り値:
obj 引数に指定されたオブジェクトとこのオブジェクトが等しい場合は true、そうでない場合は false
関連項目:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
この FieldPosition のハッシュコードを返します。

オーバーライド:
クラス Object 内の hashCode
戻り値:
このオブジェクトのハッシュコード値
関連項目:
Object.equals(java.lang.Object), Hashtable

toString

public String toString()
この FieldPosition の文字列表現を返します。

オーバーライド:
クラス Object 内の toString
戻り値:
このオブジェクトの文字列表現

JavaTM 2 Platform
Standard Ed. 5.0

バグの報告と機能のリクエスト
さらに詳しい API リファレンスおよび開発者ドキュメントについては、Java 2 SDK SE 開発者用ドキュメントを参照してください。開発者向けの詳細な解説、概念の概要、用語の定義、バグの回避策、およびコード実例が含まれています。

Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。