org.jtheque.core.managers.properties
Class PropertiesManager

java.lang.Object
  extended by org.jtheque.core.managers.properties.PropertiesManager
All Implemented Interfaces:
ActivableManager, IManager, IPropertiesManager

public final class PropertiesManager
extends java.lang.Object
implements IPropertiesManager

A properties manager implementation.

Author:
Baptiste Wicht

Constructor Summary
PropertiesManager()
           
 
Method Summary
 void close()
          Close the manager.
<T> T
createMemento(T bean)
          Create a memento for the bean.
 java.util.List<Property> getProperties(java.lang.Object bean)
          Return all the properties of a bean.
 java.lang.Object getProperty(java.lang.Object bean, Property property)
          Return the value of a property.
 java.lang.Object getProperty(java.lang.Object bean, java.lang.String property)
          Return the value of a property.
 int hashCode(java.lang.Object bean)
          Generate a hashcode for the bean.
 void init()
          Init the manager.
 boolean isEnabled()
          Indicate if the manager is enabled or not.
 void preInit()
          Pre-init the manager.
 void restoreMemento(java.lang.Object bean, java.lang.Object memento)
          Restore the state of the memento.
 void setEnabled(boolean enabled)
          Enable or disable the manager.
 java.lang.String toString(java.lang.Object bean)
          Generate a toString() String based on all the properties of the bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesManager

public PropertiesManager()
Method Detail

preInit

public void preInit()
Description copied from interface: IManager
Pre-init the manager. This operation is called before modules preplug.

Specified by:
preInit in interface IManager

init

public void init()
          throws ManagerException
Description copied from interface: IManager
Init the manager. This operation is called after modules preplug but before module plug.

Specified by:
init in interface IManager
Throws:
ManagerException - If an error occurs during the init process.

close

public void close()
           throws ManagerException
Description copied from interface: IManager
Close the manager.

Specified by:
close in interface IManager
Throws:
ManagerException - If an error occurs during the close process.

isEnabled

public boolean isEnabled()
Description copied from interface: ActivableManager
Indicate if the manager is enabled or not.

Specified by:
isEnabled in interface ActivableManager
Returns:
true if the manager is enabled else false.

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: ActivableManager
Enable or disable the manager.

Specified by:
setEnabled in interface ActivableManager
Parameters:
enabled - true if we want enable the manager else false.

getProperties

public java.util.List<Property> getProperties(java.lang.Object bean)
                                       throws PropertyException
Description copied from interface: IPropertiesManager
Return all the properties of a bean. For better performance, the results are internally cached.

Specified by:
getProperties in interface IPropertiesManager
Parameters:
bean - The bean to extract the properties from.
Returns:
A List containing all the properties of the bean.
Throws:
PropertyException - If an errors occurs during the recuperation of the properties.

getProperty

public java.lang.Object getProperty(java.lang.Object bean,
                                    Property property)
Description copied from interface: IPropertiesManager
Return the value of a property.

Specified by:
getProperty in interface IPropertiesManager
Parameters:
bean - The bean to get the property value from.
property - The property.
Returns:
the value of the property.

getProperty

public java.lang.Object getProperty(java.lang.Object bean,
                                    java.lang.String property)
Description copied from interface: IPropertiesManager
Return the value of a property.

Specified by:
getProperty in interface IPropertiesManager
Parameters:
bean - The bean to get the property value from.
property - The property.
Returns:
the value of the property.

createMemento

public <T> T createMemento(T bean)
Description copied from interface: IPropertiesManager
Create a memento for the bean. A memento is a clone of all the properties of the bean.

Specified by:
createMemento in interface IPropertiesManager
Type Parameters:
T - The class of the bean.
Parameters:
bean - The bean to create the memento from.
Returns:
The memento.

restoreMemento

public void restoreMemento(java.lang.Object bean,
                           java.lang.Object memento)
Description copied from interface: IPropertiesManager
Restore the state of the memento. It seems to copy all the properties values from the memento to the bean.

Specified by:
restoreMemento in interface IPropertiesManager
Parameters:
bean - The bean.
memento - The memento.

toString

public java.lang.String toString(java.lang.Object bean)
Description copied from interface: IPropertiesManager
Generate a toString() String based on all the properties of the bean.

Specified by:
toString in interface IPropertiesManager
Parameters:
bean - The bean.
Returns:
A String representation of all the properties of the bean.

hashCode

public int hashCode(java.lang.Object bean)
Description copied from interface: IPropertiesManager
Generate a hashcode for the bean.

Specified by:
hashCode in interface IPropertiesManager
Parameters:
bean - The bean.
Returns:
A hash code based on all the properties of the bean.


Copyright © 2009 JTheque. All Rights Reserved.