org.eclipse.persistence.mappings.transformers
Class ConstantTransformer

java.lang.Object
  extended by org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter
      extended by org.eclipse.persistence.mappings.transformers.ConstantTransformer
All Implemented Interfaces:
Serializable, FieldTransformer

public class ConstantTransformer
extends FieldTransformerAdapter

Purpose: Allows a field to always be mapped to a constant value. This allows default values to be provided for un-mapped fields.

Since:
10.1.3
Author:
James Sutherland
See Also:
org.eclipse.persistence.mappings.FieldTransformer, Serialized Form

Constructor Summary
ConstantTransformer()
           
ConstantTransformer(Object value)
          PUBLIC: Return a constant transformer for the constant value.
 
Method Summary
 Object buildFieldValue(Object object, String fieldName, Session session)
          INTERNAL: Always return the constant value.
 Object getValue()
          PUBLIC: Return the value of the constant.
 void setValue(Object value)
          PUBLIC: Set the value of the constant.
 
Methods inherited from class org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter
initialize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstantTransformer

public ConstantTransformer()

ConstantTransformer

public ConstantTransformer(Object value)
PUBLIC: Return a constant transformer for the constant value.

Method Detail

getValue

public Object getValue()
PUBLIC: Return the value of the constant.


setValue

public void setValue(Object value)
PUBLIC: Set the value of the constant.


buildFieldValue

public Object buildFieldValue(Object object,
                              String fieldName,
                              Session session)
INTERNAL: Always return the constant value.

Specified by:
buildFieldValue in interface FieldTransformer
Overrides:
buildFieldValue in class FieldTransformerAdapter
Parameters:
object - - an instance of the domain class which contains the attribute
fieldName - - the name of the field being transformed. Used if the user wants to use this transformer for multiple fields.
session - - the current session
Returns:
- The value to be written for the field associated with this transformer