JavaTM 2 Platform
Std. Ed. v1.3

java.text
クラス AttributedString

java.lang.Object
  |
  +--java.text.AttributedString

public class AttributedString
extends Object

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

関連項目:
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 のインスタンスを生成します。実装者が持つ可能性のない属性についての情報は、反復子を使ってアクセス可能にする必要はありません。実装者が持つ属性のリストが null の場合、利用可能なすべての属性情報はアクセス可能にしてください。
パラメータ:
attributes - クライアントが関心を持つ属性のリスト
戻り値:
テキストとその属性へのアクセスを提供する反復子

getIterator

public AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[] attributes,
                                               int beginIndex,
                                               int endIndex)
文字列の選択された内容へのアクセスを提供する、AttributedCharacterIterator のインスタンスを生成します。実装者が持つ可能性のない属性についての情報は、反復子を使ってアクセス可能にする必要はありません。実装者が持つ属性のリストが null の場合、利用可能なすべての属性情報はアクセス可能にしてください。
パラメータ:
attributes - クライアントが関心を持つ属性のリスト
beginIndex - 先頭文字のインデックス
endIndex - 最後の文字の次に来る文字のインデックス
戻り値:
テキストとその属性へのアクセスを提供する反復子
例外:
IllegalArgumentException - beginIndex が 0 より小さい場合、endIndex が文字列長より大きい場合、または beginIndex が endIndex よりも大きい場合

JavaTM 2 Platform
Std. Ed. v1.3

バグや機能要求の報告
さらに詳しい API リファレンスおよび開発者ドキュメントについては、 Java 2 SDK SE Developer Documentation を参照してください。このドキュメントには、概念、用語の定義、回避策、 実用的なコード例など、開発者を対象にした詳細な解説が掲載されています。

Java、Java 2D、JDBC は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.