corelib.runtime.reflexion
Class Property

java.lang.Object
  extended by corelib.runtime.reflexion.Property

public class Property
extends java.lang.Object

This class extends the possibility of the Java reflection framework, in simplifying the property management. The getter and setter methods are searched recursively into all inherited super classes.

Since:
0.2.0
Author:
Dominique Liard

Constructor Summary
Property(java.lang.Class<?> classMetaData, java.lang.String propertyName)
          Class constructor
 
Method Summary
 java.lang.Object get(java.lang.Object instance)
          Returns the property value for the specified instance.
 java.lang.String getPropertyName()
          Returns the name of the considered property.
 java.lang.reflect.Method getReadMethod()
          Returns the getter method metadata's.
 java.lang.reflect.Method getWriteMethod()
          Returns the getter method metadata's.
 boolean isAccessible()
          Returns if this property is considered as accessible.
 void set(java.lang.Object instance, java.lang.Object value)
          Changes the property value for the specified instance.
 void setAccessible(boolean state)
          Sets this property as accessible.
 java.lang.String toString()
          Computes the representation string of this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Property

public Property(java.lang.Class<?> classMetaData,
                java.lang.String propertyName)
Class constructor

Parameters:
classMetaData - The metaclass of the type that contains getter and setter methods.
propertyName - The name of the considered property.
Method Detail

getPropertyName

public java.lang.String getPropertyName()
Returns the name of the considered property.

Returns:
The name of the property.

isAccessible

public boolean isAccessible()
Returns if this property is considered as accessible.

Returns:
true is this property is accessible, false otherwise.

setAccessible

public void setAccessible(boolean state)
Sets this property as accessible.

Parameters:
state - The accessible state.

getReadMethod

public java.lang.reflect.Method getReadMethod()
                                       throws java.lang.NoSuchMethodException
Returns the getter method metadata's.

Returns:
The getter method metadata's.
Throws:
java.lang.NoSuchMethodException - Thrown if no getter method was found.

getWriteMethod

public java.lang.reflect.Method getWriteMethod()
                                        throws java.lang.NoSuchMethodException
Returns the getter method metadata's.

Returns:
The getter method metadata's.
Throws:
java.lang.NoSuchMethodException - Thrown if no setter method was found.

get

public java.lang.Object get(java.lang.Object instance)
                     throws java.lang.IllegalAccessException,
                            java.lang.reflect.InvocationTargetException,
                            java.lang.NoSuchMethodException
Returns the property value for the specified instance.

Parameters:
instance - The instance used for retreive the property value.
Returns:
The property value.
Throws:
java.lang.IllegalAccessException - Thrown if the property getter is not accessible.
java.lang.reflect.InvocationTargetException - Thrown if an error appears during the property invocation.
java.lang.NoSuchMethodException - Thrown if the getter method does not exists.

set

public void set(java.lang.Object instance,
                java.lang.Object value)
         throws java.lang.IllegalAccessException,
                java.lang.reflect.InvocationTargetException,
                java.lang.NoSuchMethodException
Changes the property value for the specified instance.

Parameters:
instance - The instance used for change the property value.
value - The new value of the property.
Throws:
java.lang.IllegalAccessException - Thrown if the property setter is not accessible.
java.lang.reflect.InvocationTargetException - Thrown if an error appears during the property invocation.
java.lang.NoSuchMethodException - Thrown if the setter method does not exists.

toString

public java.lang.String toString()
Computes the representation string of this instance.

Overrides:
toString in class java.lang.Object
Returns:
The representation string.
Since:
0.4.6


CAUTION: Ellipse is proposed to you in BETA version to allow evaluation of this framework. Infini Software is released from any responsibility for the use of Ellipse Framework.

Copyright 2012 Infini Software - All Rights Reserved.