|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Object | +--org.apache.log4j.config.PropertySetter
General purpose Object property setter. Clients repeatedly invokes
setProperty(name,value) in order to invoke setters
on the Object specified in the constructor. This class relies on the
JavaBeans Introspector to analyze the given Object Class using
reflection.
基本的な目的は、オブジェクトのプロパティのセッタとなることです。
クライアントは、コンストラクタで指定したオブジェクトに対し、セッタを起動するためには、繰り返し setProperty(name,value) を実行します。
このクラスは、指定されたオブジェクト・クラスをリフレクション機能を使って解析するという JavaBeans の Introspector を頼りにしています。
Usage:
使用方法:
PropertySetter ps = new PropertySetter(anObject);
ps.set("name", "Joe");
ps.set("age", "32");
ps.set("isMale", "true");
will cause the invocations anObject.setName("Joe"), anObject.setAge(32),
and setMale(true) if such methods exist with those signatures.
Otherwise an IntrospectionException are thrown.
は、anObject.setName("Joe")やanObject.setAge(32)、setMale(true)のようなシグニチャをもつメソッドがあれば、そのメソッドを起動します。
しかし、そうでなければ、IntrospectionException がスローされます。
| フィールドの概要 | |
protected Object |
obj
|
protected PropertyDescriptor[] |
props
|
| コンストラクタの概要 | |
PropertySetter(Object obj)
Create a new PropertySetter for the specified Object. |
|
| メソッドの概要 | |
void |
activate()
|
protected Object |
convertArg(String val,
Class type)
Convert val a String parameter to an object of a
given type.
|
protected PropertyDescriptor |
getPropertyDescriptor(String name)
|
protected void |
introspect()
Uses JavaBeans Introspector to computer setters of object to be
configured.
|
static void |
setProperties(Object obj,
Properties properties,
String prefix)
Set the properties of an object passed as a parameter in one go. |
void |
setProperties(Properties properties,
String prefix)
Set the properites for the object that match the prefix passed as parameter.
|
void |
setProperty(PropertyDescriptor prop,
String name,
String value)
Set the named property given a PropertyDescriptor.
|
void |
setProperty(String name,
String value)
Set a property on this PropertySetter's Object. |
| クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| フィールドの詳細 |
protected Object obj
protected PropertyDescriptor[] props
| コンストラクタの詳細 |
public PropertySetter(Object obj)
setProperty(java.lang.String, java.lang.String) one or more times.
指定したオブジェクトに対する新規の PropertySetter を作成します。 このコンストラクタで1回または複数回 {link #setProperty} を実行する準備が完了します。
obj - the object for which to set properties
obj プロパティの設定対象のオブジェクト
| メソッドの詳細 |
protected void introspect()
Introspector to computer setters of object to be
configured.
指定されたオブジェクトのセッタメソッドを割り出すために JavaBeans の Introspector を使用します。
public static void setProperties(Object obj,
Properties properties,
String prefix)
properties are parsed relative to a
prefix.
パラメタで渡されたオブジェクトのプロパティを一挙に設定します。
properties は、prefix と比較して解析されます。
obj - The object to configure.
obj 設定対象のオブジェクト
properties - A java.util.Properties containing keys and values.
properties キーと値で構成される java.util.Properties
prefix - Only keys having the specified prefix will be set.
prefix 指定した接頭辞を持つキーだけが設定される
public void setProperties(Properties properties,
String prefix)
prefix passed as parameter.
パラメタとして渡された prefix にマッチするオブジェクトに関するプロパティを設定します。
public void setProperty(String name,
String value)
この PropertySetter オブジェクト上でプロパティを設定します。 もし上手く行けば、このメソッドは、指定したオブジェクト上のセッタ・メソッドを呼び出します。 指定したプロパティ名と値をもつ1つのメソッドが、このメソッドを呼び出した際に指定したセッタの引数の型および値それぞれの部分から決定されます。
If the setter expects a String no conversion is necessary. If it expects an int, then an attempt is made to convert 'value' to an int using new Integer(value). If the setter expects a boolean, the conversion is by new Boolean(value).
もし、セッタが String を求める場合は、型変換の必要はありません。 もし、int が求められる場合は、'value' を new Integer(value) 使って int 型へ変換する試みが必要です。 もし、セッタが論理値を求める場合は、new Boolean(value) による変換が必要です。
name - name of the property
name プロパティ名
value - String value of the property
value プロパティの String 値
public void setProperty(PropertyDescriptor prop,
String name,
String value)
throws PropertySetterException
PropertyDescriptor.
PropertyDescriptor を使って、名前指定したプロパティを設定します。
prop - A PropertyDescriptor describing the characteristics
of the property to set.
prop 設定するプロパティの特徴を記述した PropertyDescriptor
name - The named of the property to set.
name 設定するためのプロパティ名
value - The value of the property.
value プロパティの値
protected Object convertArg(String val,
Class type)
val a String parameter to an object of a
given type.
String パラメタ val を指定した型をもつオブジェクトへ変換します。
protected PropertyDescriptor getPropertyDescriptor(String name)
public void activate()
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||