Foundation 1.1.2

java.text
クラス AttributedString

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

public class AttributedString
extends Object

テキストとそのテキストに関連する属性情報を保持します。テキストを読み取るユーザーが、AttributedCharacterIterator インタフェース経由で属性付きテキストにアクセスする必要がある場合、このクラスを実際のデータストレージとして使用できます。

導入されたバージョン:
1.2
関連項目:
AttributedCharacterIterator, Annotation

コンストラクタの概要
AttributedString(AttributedCharacterIterator text)
          指定された AttributedCharacterIterator が表現する属性付きテキストを持つ、AttributedString インスタンスを構築します。
AttributedString(AttributedCharacterIterator text, int beginIndex, int endIndex)
          指定された AttributedCharacterIterator が表現する属性付きテキストの部分範囲を持つ AttributedString インスタンスを構築します。
AttributedString(AttributedCharacterIterator text, int beginIndex, int endIndex, AttributedCharacterIterator.Attribute[] attributes)
          指定された AttributedCharacterIterator が表現する属性付きテキストの部分範囲を持つ AttributedString インスタンスを構築します。
AttributedString(String text)
          指定されたテキストを持つ AttributedString インスタンスを構築します。
AttributedString(String text, Map attributes)
          指定されたテキストと属性を持つ AttributedString インスタンスを構築します。
 
メソッドの概要
 void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value)
          属性を文字列全体に追加します。
 void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value, int beginIndex, int endIndex)
          属性を文字列の部分範囲に追加します。
 void addAttributes(Map attributes, int beginIndex, int endIndex)
          一連の属性を文字列の部分範囲に追加します。
 AttributedCharacterIterator getIterator()
          この文字列の内容全体にアクセスできる AttributedCharacterIterator インスタンスを作成します。
 AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[] attributes)
          この文字列の選択された内容にアクセスできる AttributedCharacterIterator インスタンスを作成します。
 AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[] attributes, int beginIndex, int endIndex)
          この文字列の選択された内容にアクセスできる AttributedCharacterIterator インスタンスを作成します。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

AttributedString

public AttributedString(String text)
指定されたテキストを持つ AttributedString インスタンスを構築します。

パラメータ:
text - この属性付き文字列のテキスト

AttributedString

public AttributedString(String text,
                        Map attributes)
指定されたテキストと属性を持つ AttributedString インスタンスを構築します。

パラメータ:
text - この属性付き文字列のテキスト
attributes - 文字列全体に適用する属性
例外:
IllegalArgumentException - テキスト長が 0 で、かつ属性パラメータが空の Map でない場合 (長さ 0 の範囲には属性を適用できない)

AttributedString

public AttributedString(AttributedCharacterIterator text)
指定された AttributedCharacterIterator が表現する属性付きテキストを持つ、AttributedString インスタンスを構築します。

パラメータ:
text - この属性付き文字列のテキスト

AttributedString

public AttributedString(AttributedCharacterIterator text,
                        int beginIndex,
                        int endIndex)
指定された AttributedCharacterIterator が表現する属性付きテキストの部分範囲を持つ AttributedString インスタンスを構築します。指定された範囲が空のテキストを生成する場合、すべての属性が破棄されます。元の属性範囲の部分範囲に対しては、Annotation オブジェクトによってラップされた属性はすべて破棄されます。

パラメータ:
text - この属性付き文字列のテキスト
beginIndex - 範囲の先頭文字のインデックス
endIndex - 範囲の末尾文字の次の文字のインデックス
例外:
IllegalArgumentException - beginIndex と endIndex で指定された部分範囲がテキストの範囲外にある場合
関連項目:
Annotation

AttributedString

public AttributedString(AttributedCharacterIterator text,
                        int beginIndex,
                        int endIndex,
                        AttributedCharacterIterator.Attribute[] attributes)
指定された AttributedCharacterIterator が表現する属性付きテキストの部分範囲を持つ AttributedString インスタンスを構築します。指定された属性に一致する属性だけがインスタンスに組み込まれます。指定された範囲が空のテキストを生成する場合、すべての属性が破棄されます。元の属性範囲の部分範囲に対しては、Annotation オブジェクトによってラップされた属性はすべて破棄されます。

パラメータ:
text - この属性付き文字列のテキスト
beginIndex - 範囲の先頭文字のインデックス
endIndex - 範囲の末尾文字の次の文字のインデックス
attributes - テキストから抽出する属性を指定する。null が指定された場合、利用可能なすべての属性が使用される
例外:
IllegalArgumentException - beginIndex と endIndex で指定された部分範囲がテキストの範囲外にある場合
関連項目:
Annotation
メソッドの詳細

addAttribute

public void addAttribute(AttributedCharacterIterator.Attribute attribute,
                         Object value)
属性を文字列全体に追加します。

パラメータ:
attribute - 属性キー
value - 属性の値。 null も指定可能
例外:
IllegalArgumentException - AttributedString の長さが 0 の場合 (長さ 0 の範囲には属性を適用できない)

addAttribute

public void addAttribute(AttributedCharacterIterator.Attribute attribute,
                         Object value,
                         int beginIndex,
                         int endIndex)
属性を文字列の部分範囲に追加します。

パラメータ:
attribute - 属性キー
value - 属性の値。null の場合あり
beginIndex - 範囲の先頭文字のインデックス
endIndex - 範囲の末尾文字の次の文字のインデックス
例外:
IllegalArgumentException - beginIndex が 0 より小さい場合、endIndex が文字列長より大きい場合、あるいは beginIndex と endIndex で定義される文字列の部分範囲が空になる場合

addAttributes

public void addAttributes(Map attributes,
                          int beginIndex,
                          int endIndex)
一連の属性を文字列の部分範囲に追加します。

パラメータ:
attributes - 文字列に追加する属性
beginIndex - 範囲の先頭文字のインデックス
endIndex - 範囲の末尾文字の次の文字のインデックス
例外:
IllegalArgumentException - beginIndex が 0 より小さい場合、endIndex が文字列長より大きい場合、あるいは beginIndex と endIndex で定義される文字列の部分範囲が空で、属性パラメータは空の Map でない場合

getIterator

public AttributedCharacterIterator getIterator()
この文字列の内容全体にアクセスできる AttributedCharacterIterator インスタンスを作成します。

戻り値:
テキストとその属性にアクセスできる反復子

getIterator

public AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[] attributes)
この文字列の選択された内容にアクセスできる AttributedCharacterIterator インスタンスを作成します。attributes に含まれていない属性の情報を実装者が保持する場合、それらの情報をこの反復子経由でアクセス可能にする必要はありません。リストが null の場合、利用可能なすべての属性の情報にアクセスできる必要があります。

パラメータ:
attributes - クライアントが興味を持っている属性のリスト
戻り値:
テキストおよびテキストの属性にアクセスできる反復子

getIterator

public AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[] attributes,
                                               int beginIndex,
                                               int endIndex)
この文字列の選択された内容にアクセスできる AttributedCharacterIterator インスタンスを作成します。attributes に含まれていない属性の情報を実装者が保持する場合、それらの情報をこの反復子経由でアクセス可能にする必要はありません。リストが null の場合、利用可能なすべての属性の情報にアクセスできる必要があります。

パラメータ:
attributes - クライアントが興味を持っている属性のリスト
beginIndex - 最初の文字のインデックス
endIndex - 最後の文字のあとに続く文字のインデックス
戻り値:
テキストおよびテキストの属性にアクセスできる反復子
例外:
IllegalArgumentException - beginIndex が 0 より小さい場合、endIndex が文字列長より大きい場合、あるいは beginIndex が endIndex より大きい場合

Foundation 1.1.2

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

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