Top Description Fields Constructors Methods
ch.qos.logback.core.joran.util

public Class PropertySetter

extends ContextAwareBase
Class Inheritance
Imports
ch.qos.logback.core.Context, ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry, ch.qos.logback.core.joran.util.beans.BeanDescription, .BeanDescriptionCache, ch.qos.logback.core.spi.ContextAwareBase, ch.qos.logback.core.util.AggregationType, .PropertySetterException, .StringUtil, java.lang.reflect.Method

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 reflection to analyze the given Object Class.

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 PropertySetterException is thrown.
Authors
Anders Kristensen, Ceki Gulcu

Field Summary

Modifier and TypeField and Description
protected final AggregationAssessor
protected final BeanDescription
protected final Object
protected final Class<?>
Inherited from ch.qos.logback.core.spi.ContextAwareBase:
context

Constructor Summary

AccessConstructor and Description
public
PropertySetter(BeanDescriptionCache beanDescriptionCache, Object
the object for which to set properties
obj
)

Create a new PropertySetter for the specified Object.

Method Summary

Modifier and TypeMethod and Description
public void
addBasicProperty(String name, String strValue)

public void
addComplexProperty(String name, Object complexProperty)

public AggregationType
public Class<?>
public Object
public Class<?>
pack-priv void
private boolean
isSanityCheckSuccessful(String name, Method method, Class<?>[] params, Object complexProperty)

public void
setComplexProperty(String name, Object complexProperty)

public void
public void
setProperty(String
name of the property
name
,
String
String value of the property
value
)

Set a property on this PropertySetter's Object.

private void
setProperty(Method
A Method describing the characteristics of the property to set.
setter
,
String
The value of the property.
value
)

Set the named property using a setter.

Inherited from ch.qos.logback.core.spi.ContextAwareBase:
addErroraddErroraddInfoaddInfoaddStatusaddWarnaddWarngetContextgetDeclaredOrigingetStatusManager

Field Detail

aggregationAssessorback to summary
protected final AggregationAssessor aggregationAssessor
beanDescriptionback to summary
protected final BeanDescription beanDescription
objback to summary
protected final Object obj
objClassback to summary
protected final Class<?> objClass

Constructor Detail

PropertySetterback to summary
public PropertySetter(BeanDescriptionCache beanDescriptionCache, Object obj)

Create a new PropertySetter for the specified Object. This is done in preparation for invoking setProperty one or more times.

Parameters
obj:Object

the object for which to set properties

Method Detail

addBasicPropertyback to summary
public void addBasicProperty(String name, String strValue)
addComplexPropertyback to summary
public void addComplexProperty(String name, Object complexProperty)
computeAggregationTypeback to summary
public AggregationType computeAggregationType(String name)
getClassNameViaImplicitRulesback to summary
public Class<?> getClassNameViaImplicitRules(String name, AggregationType aggregationType, DefaultNestedComponentRegistry registry)
getObjback to summary
public Object getObj()
getObjClassback to summary
public Class<?> getObjClass()
invokeMethodWithSingleParameterOnThisObjectback to summary
pack-priv void invokeMethodWithSingleParameterOnThisObject(Method method, Object parameter)
isSanityCheckSuccessfulback to summary
private boolean isSanityCheckSuccessful(String name, Method method, Class<?>[] params, Object complexProperty)
setComplexPropertyback to summary
public void setComplexProperty(String name, Object complexProperty)
setContextback to summary
public void setContext(Context context)

Overrides ch.qos.logback.core.spi.ContextAwareBase.setContext.

Implements ch.qos.logback.core.spi.ContextAware.setContext.

Annotations
@Override
setPropertyback to summary
public void setProperty(String name, String value)

Set a property on this PropertySetter's Object. If successful, this method will invoke a setter method on the underlying Object. The setter is the one for the specified property name and the value is determined partly from the setter argument type and partly from the value specified in the call to this method.

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).

Parameters
name:String

name of the property

value:String

String value of the property

setPropertyback to summary
private void setProperty(Method setter, String value) throws PropertySetterException

Set the named property using a setter.

Parameters
setter:Method

A Method describing the characteristics of the property to set.

value:String

The value of the property.