Kagetaka

net.hizlab.kagetaka.token
クラス AttributeConverter

java.lang.Object
  拡張net.hizlab.kagetaka.token.AttributeConverter

public class AttributeConverter
extends Object

属性値を、文字列から適切なインスタンスを生成するためのユーティリティです。

バージョン:
$Revision: 1.4 $

メソッドの概要
static int convertToAlign(String value)
          ALIGN 属性を表す文字列から、ALIGN 値を生成します。
static Color convertToColor(String value)
          色を表す文字列から、Color のインスタンスを生成します。
static Color convertToColorSilent(String value)
          色を表す文字列から、Color のインスタンスを生成します。
static Font convertToFont(String value)
          フォント名を表す文字列から、Font のインスタンスを 生成します。
static Integer convertToInteger(String value)
          数値を表す文字列から、Integer のインスタンスを 生成します。
static Value convertToPercent(String value)
          パーセントを含む文字列から、パーセント値を生成します。
static int convertToVAlign(String value)
          VALIGN 属性を表す文字列から、VALIGN 値を生成します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

メソッドの詳細

convertToAlign

public static int convertToAlign(String value)
                          throws IllegalArgumentException
ALIGN 属性を表す文字列から、ALIGN 値を生成します。

パラメータ:
value - ALIGN 属性を表す文字列
戻り値:
ALIGN 属性値
例外:
IllegalArgumentException - 不正な値の場合

convertToColor

public static Color convertToColor(String value)
                            throws IllegalArgumentException
色を表す文字列から、Color のインスタンスを生成します。

文字列のフォーマットは、以下の通りです。

 #f00     (#rgb    - 16 進数)
 #ff0000  (#rrggbb - 16 進数)
 red      (色名)
 
16 進数は 0-9、a-f までの文字で、大文字小文字は区別されません。 rgb の 3 桁の形式は、実際には 6 桁の形式に変換されます。 この変換は、0 を付け加えるのではなく、各桁の値を繰り返すことにより、 6 桁に変換します。例えば「#fb0」という値は、「#ffbb00」に変換されます。

サポートされている色名は、aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow の 16 色で、これらは、HTML 4.0 で定義されている色と同じです。

パラメータ:
value - 色を表す文字列
戻り値:
色のインスタンス
例外:
IllegalArgumentException - 不正な値の場合
関連項目:
HTML 4.01 Specification: 6.5 Colors

convertToColorSilent

public static Color convertToColorSilent(String value)
色を表す文字列から、Color のインスタンスを生成します。

convertToColor(String) との違いは、不正な値を変換しようと した場合に、例外を発生させずに、null を返す点です。

パラメータ:
value - 色を表す文字列
戻り値:
色のインスタンス、不正な値の場合は null
関連項目:
convertToColor(String)

convertToFont

public static Font convertToFont(String value)
                          throws IllegalArgumentException
フォント名を表す文字列から、Font のインスタンスを 生成します。

パラメータ:
value - フォントを表す文字列
戻り値:
フォントのインスタンス
例外:
IllegalArgumentException - 不正な値の場合

convertToInteger

public static Integer convertToInteger(String value)
                                throws IllegalArgumentException
数値を表す文字列から、Integer のインスタンスを 生成します。

パラメータ:
value - 数値を表す文字列
戻り値:
数値
例外:
IllegalArgumentException - 不正な値の場合

convertToPercent

public static Value convertToPercent(String value)
                              throws IllegalArgumentException
パーセントを含む文字列から、パーセント値を生成します。

パラメータ:
value - パーセントを含む文字列
戻り値:
パーセント値
例外:
IllegalArgumentException - 不正な値の場合

convertToVAlign

public static int convertToVAlign(String value)
                           throws IllegalArgumentException
VALIGN 属性を表す文字列から、VALIGN 値を生成します。

パラメータ:
value - VALIGN 属性を表す文字列
戻り値:
VALIGN 属性値
例外:
IllegalArgumentException - 不正な値の場合

Kagetaka

Copyright (c) 2002-2003 The Kagetaka Project 'September 12, 2003'