public class Property extends java.lang.Object implements FieldInterceptor, ConstructorInjector
Modifier and Type | Field and Description |
---|---|
static java.lang.Object |
NO_VALUE
Object used for an unvalued property.
|
static java.lang.String |
UNVALUED
String value returned for property without values.
|
Constructor and Description |
---|
Property(java.lang.String name,
java.lang.String field,
java.lang.String method,
int index,
java.lang.String value,
java.lang.String type,
InstanceManager manager,
Handler handler) |
Property(java.lang.String name,
java.lang.String field,
java.lang.String method,
java.lang.Object value,
InstanceManager manager,
Handler handler)
Creates a property.
|
Property(java.lang.String name,
java.lang.String field,
java.lang.String method,
java.lang.String value,
java.lang.String type,
InstanceManager manager,
Handler handler)
Creates a property.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.Class |
computeType(java.lang.String type,
org.osgi.framework.BundleContext context)
Computes and returns the property type according to the given type name.
|
static java.lang.Object |
create(java.lang.Class type,
java.lang.String strValue)
Creates an object of the given type with the given String value.
|
static java.lang.Object |
createArrayObject(java.lang.Class interntype,
java.lang.String[] values)
Creates an array object containing the type component type from
the String array 'values'.
|
java.lang.Object |
getConstructorParameter(int index)
Gets the object to inject as constructor parameter.
|
java.lang.Class |
getConstructorParameterType(int index)
Gets the type of the constructor parameter to inject.
|
java.lang.Object |
getDefaultValue()
Gets the initial value of the property.
|
java.lang.String |
getField() |
Handler |
getHandler()
Gets the handler managing the property.
|
java.lang.String |
getMethod()
Gets the method name,
null if no method. |
java.lang.String |
getName() |
int |
getParameterIndex()
Gets the parameter index.
|
java.lang.String |
getType() |
java.lang.Object |
getValue() |
boolean |
hasField()
Checks if the property has a field.
|
boolean |
hasMethod()
Checks if the property has a method callback.
|
void |
invoke(java.lang.Object instance)
Invokes the setter method on the given pojo object.
|
static boolean |
isAssignable(java.lang.Class type,
java.lang.Object value)
Checks if the given value is assignable to the given type.
|
java.lang.Object |
onGet(java.lang.Object pojo,
java.lang.String fieldName,
java.lang.Object value)
A field value is required by the object 'pojo'.
|
void |
onSet(java.lang.Object pojo,
java.lang.String fieldName,
java.lang.Object value)
The field 'field' receives a new value.
|
void |
reset()
Clears the invoked flag.
|
void |
setValue(java.lang.Object value)
Sets the value of the property.
|
public static final java.lang.Object NO_VALUE
public static final java.lang.String UNVALUED
public Property(java.lang.String name, java.lang.String field, java.lang.String method, java.lang.String value, java.lang.String type, InstanceManager manager, Handler handler) throws ConfigurationException
name
- the name of the property (optional)field
- the name of the fieldmethod
- the method namevalue
- the initial value of the property (optional)type
- the the type of the propertymanager
- the instance managerhandler
- the handler object which manage this property.ConfigurationException
- if the property value cannot be set.public Property(java.lang.String name, java.lang.String field, java.lang.String method, java.lang.Object value, InstanceManager manager, Handler handler) throws ConfigurationException
name
- the name of the property (optional)field
- the name of the fieldmethod
- the method namevalue
- the initial value of the property (optional)manager
- the instance managerhandler
- the handler object which manage this property.ConfigurationException
- if the property value cannot be set.public Property(java.lang.String name, java.lang.String field, java.lang.String method, int index, java.lang.String value, java.lang.String type, InstanceManager manager, Handler handler) throws ConfigurationException
ConfigurationException
public static java.lang.Class computeType(java.lang.String type, org.osgi.framework.BundleContext context) throws ConfigurationException
type
- the the type namecontext
- the bundle context (used to load classes)ConfigurationException
- if an error occurs when loading the type class for non-primitive types.public java.lang.String getName()
public java.lang.String getField()
public java.lang.String getType()
public java.lang.String getMethod()
null
if no method.public boolean hasMethod()
true
if the property has a method.public int getParameterIndex()
-1
if this property is not injected using constructor
parameter.public boolean hasField()
true
if the property has a field.public java.lang.Object getValue()
public java.lang.Object getDefaultValue()
public void setValue(java.lang.Object value)
value
- the new value.public static boolean isAssignable(java.lang.Class type, java.lang.Object value)
type
- the class of the typevalue
- the object to checktrue
if the object is assignable in the property of type 'type'.public static java.lang.Object create(java.lang.Class type, java.lang.String strValue) throws ConfigurationException
type
- the type of the returned objectstrValue
- the String value.ConfigurationException
- if the object cannot be created.public static java.lang.Object createArrayObject(java.lang.Class interntype, java.lang.String[] values) throws ConfigurationException
interntype
- the internal type of the array.values
- the String arrayConfigurationException
- if the array cannot be created correctlypublic void reset()
public void invoke(java.lang.Object instance)
instance
- the created object (could be null
)public java.lang.Object onGet(java.lang.Object pojo, java.lang.String fieldName, java.lang.Object value)
onGet
in interface FieldInterceptor
pojo
- the POJO objectfieldName
- the fieldvalue
- the last valueFieldInterceptor.onGet(java.lang.Object, java.lang.String, java.lang.Object)
public void onSet(java.lang.Object pojo, java.lang.String fieldName, java.lang.Object value)
onSet
in interface FieldInterceptor
pojo
- the pojofieldName
- the field namevalue
- the new valueFieldInterceptor.onSet(java.lang.Object, java.lang.String, java.lang.Object)
public java.lang.Object getConstructorParameter(int index)
getConstructorParameter
in interface ConstructorInjector
index
- the constructor parameter indexConstructorInjector.getConstructorParameter(int)
public java.lang.Class getConstructorParameterType(int index)
getConstructorParameterType
in interface ConstructorInjector
index
- the parameter indexConstructorInjector.getConstructorParameterType(int)
public Handler getHandler()
Copyright © 2006-2014 The Apache Software Foundation. All Rights Reserved.