ch.tatool.core.data
Class GenericProperty<T>

java.lang.Object
  extended by ch.tatool.core.data.GenericProperty<T>
Type Parameters:
T - the type of the property value
All Implemented Interfaces:
Property<T>
Direct Known Subclasses:
DateProperty, DoubleProperty, IntegerProperty, LongProperty, ObjectProperty, StringProperty

public abstract class GenericProperty<T>
extends Object
implements Property<T>

Generic property data object. You can use this class to define your own property objects without having to write too much.

Author:
Michael Ruflin

Constructor Summary
GenericProperty(String propertyName, Class<T> propertyType)
          Creates a new property object.
 
Method Summary
 void clearValue(DataContainer dataContainer, PropertyHolder holder)
           
 void clearValue(DataContainer dataContainer, String nodeId)
           
 void clearValue(PropertyHolder holder)
           
 boolean copyValue(DataContainer dataContainer, Node fromNode, Node toNode, T defaultValue)
          Copy a property from one to another nodeId.
 boolean copyValue(DataContainer dataContainer, String fromId, String toId, T defaultValue)
           
 T ensureValue(DataContainer dataContainer, PropertyHolder holder)
          Ensure a value, using whatever default should be used for this property.
 T ensureValue(DataContainer dataContainer, PropertyHolder holder, T defaultValue)
           
 T ensureValue(DataContainer dataContainer, String nodeId)
          Ensures a value, using the default value defined by this property.
 T ensureValue(DataContainer dataContainer, String nodeId, T defaultValue)
          Ensure a value is set.
 String getPropertyName()
           
 Class<?> getPropertyType()
           
 String getStringValue(DataContainer dataContainer, PropertyHolder holder)
           
 String getStringValue(DataContainer dataContainer, PropertyHolder holder, String defaultValue)
           
 String getStringValue(DataContainer dataContainer, String nodeId)
           
 String getStringValue(DataContainer dataContainer, String nodeId, String defaultValue)
           
 T getValue(DataContainer dataContainer, PropertyHolder holder)
          Default implementation throws an Exception.
 T getValue(DataContainer dataContainer, PropertyHolder holder, T defaultValue)
           
 T getValue(DataContainer dataContainer, String nodeId)
          Default implementation throws an Exception.
 T getValue(DataContainer dataContainer, String nodeId, T defaultValue)
           
 T getValue(PropertyHolder holder)
           
 T getValue(PropertyHolder holder, T defaultValue)
           
 boolean isSet(DataContainer dataContainer, PropertyHolder propertyHolder)
           
 boolean isSet(DataContainer dataContainer, String nodeId)
           
 boolean isSet(PropertyHolder holder)
           
 void restoreValue(DataContainer dataContainer, PropertyHolder holder)
           
 void restoreValue(DataContainer dataContainer, PropertyHolder holder, T defaultValue)
          Restore a value from the dataContainer to the element.
 void setStringValue(DataContainer dataContainer, PropertyHolder holder, String value)
           
 void setStringValue(DataContainer dataContainer, String nodeId, String value)
           
 void setValue(DataContainer dataContainer, PropertyHolder holder)
           
 void setValue(DataContainer dataContainer, PropertyHolder holder, T value)
           
 void setValue(DataContainer dataContainer, String nodeId, T value)
           
 void setValue(PropertyHolder holder, T value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericProperty

public GenericProperty(String propertyName,
                       Class<T> propertyType)
Creates a new property object.

Method Detail

getPropertyName

public String getPropertyName()
Specified by:
getPropertyName in interface Property<T>

getPropertyType

public Class<?> getPropertyType()
Specified by:
getPropertyType in interface Property<T>

isSet

public boolean isSet(PropertyHolder holder)

isSet

public boolean isSet(DataContainer dataContainer,
                     PropertyHolder propertyHolder)

isSet

public boolean isSet(DataContainer dataContainer,
                     String nodeId)

getValue

public T getValue(PropertyHolder holder)
Specified by:
getValue in interface Property<T>

getValue

public T getValue(PropertyHolder holder,
                  T defaultValue)
Specified by:
getValue in interface Property<T>

getStringValue

public String getStringValue(DataContainer dataContainer,
                             PropertyHolder holder)
Specified by:
getStringValue in interface Property<T>

getStringValue

public String getStringValue(DataContainer dataContainer,
                             String nodeId)
Specified by:
getStringValue in interface Property<T>

getStringValue

public String getStringValue(DataContainer dataContainer,
                             PropertyHolder holder,
                             String defaultValue)
Specified by:
getStringValue in interface Property<T>

getStringValue

public String getStringValue(DataContainer dataContainer,
                             String nodeId,
                             String defaultValue)
Specified by:
getStringValue in interface Property<T>

setValue

public void setValue(PropertyHolder holder,
                     T value)
Specified by:
setValue in interface Property<T>

setValue

public void setValue(DataContainer dataContainer,
                     PropertyHolder holder)
Specified by:
setValue in interface Property<T>

setValue

public void setValue(DataContainer dataContainer,
                     PropertyHolder holder,
                     T value)
Specified by:
setValue in interface Property<T>

setValue

public void setValue(DataContainer dataContainer,
                     String nodeId,
                     T value)
Specified by:
setValue in interface Property<T>

setStringValue

public void setStringValue(DataContainer dataContainer,
                           PropertyHolder holder,
                           String value)
Specified by:
setStringValue in interface Property<T>

setStringValue

public void setStringValue(DataContainer dataContainer,
                           String nodeId,
                           String value)
Specified by:
setStringValue in interface Property<T>

clearValue

public void clearValue(PropertyHolder holder)
Specified by:
clearValue in interface Property<T>

clearValue

public void clearValue(DataContainer dataContainer,
                       PropertyHolder holder)
Specified by:
clearValue in interface Property<T>

clearValue

public void clearValue(DataContainer dataContainer,
                       String nodeId)
Specified by:
clearValue in interface Property<T>

getValue

public T getValue(DataContainer dataContainer,
                  PropertyHolder holder)
Default implementation throws an Exception.

Specified by:
getValue in interface Property<T>

getValue

public T getValue(DataContainer dataContainer,
                  String nodeId)
Default implementation throws an Exception.

Specified by:
getValue in interface Property<T>

getValue

public T getValue(DataContainer dataContainer,
                  PropertyHolder holder,
                  T defaultValue)
Specified by:
getValue in interface Property<T>

getValue

public T getValue(DataContainer dataContainer,
                  String nodeId,
                  T defaultValue)
Specified by:
getValue in interface Property<T>

restoreValue

public void restoreValue(DataContainer dataContainer,
                         PropertyHolder holder)
Specified by:
restoreValue in interface Property<T>

restoreValue

public void restoreValue(DataContainer dataContainer,
                         PropertyHolder holder,
                         T defaultValue)
Restore a value from the dataContainer to the element.

Specified by:
restoreValue in interface Property<T>

ensureValue

public T ensureValue(DataContainer dataContainer,
                     PropertyHolder holder)
Ensure a value, using whatever default should be used for this property.


ensureValue

public T ensureValue(DataContainer dataContainer,
                     String nodeId)
Ensures a value, using the default value defined by this property. Note: by default this method throws an UnsupportedOperationException

Throws:
UnsupportedOperationException

ensureValue

public T ensureValue(DataContainer dataContainer,
                     PropertyHolder holder,
                     T defaultValue)

ensureValue

public T ensureValue(DataContainer dataContainer,
                     String nodeId,
                     T defaultValue)
Ensure a value is set. Sets the default value if not already available.

Returns:
the value currently set, will be the passed in defaultValue if it wasn't set previously

copyValue

public boolean copyValue(DataContainer dataContainer,
                         Node fromNode,
                         Node toNode,
                         T defaultValue)
Copy a property from one to another nodeId.

Parameters:
defaultValue - the value to use if fromNode does not contain a value for given property. If defaultValue is null and fromNode does not contain a value then nothing will be copied.

copyValue

public boolean copyValue(DataContainer dataContainer,
                         String fromId,
                         String toId,
                         T defaultValue)


Copyright © 2012. All Rights Reserved.