EclipseLink 2.2.0, build 'v20110202-r8913' API Reference

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:
java.io.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.

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

Field Summary
protected  java.lang.Object value
           
 
Constructor Summary
ConstantTransformer()
           
ConstantTransformer(java.lang.Object value)
          PUBLIC: Return a constant transformer for the constant value.
 
Method Summary
 java.lang.Object buildFieldValue(java.lang.Object object, java.lang.String fieldName, Session session)
          INTERNAL: Always return the constant value.
 java.lang.Object getValue()
          PUBLIC: Return the value of the constant.
 void setValue(java.lang.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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

protected java.lang.Object value
Constructor Detail

ConstantTransformer

public ConstantTransformer()

ConstantTransformer

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

Method Detail

getValue

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


setValue

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


buildFieldValue

public java.lang.Object buildFieldValue(java.lang.Object object,
                                        java.lang.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

EclipseLink 2.2.0, build 'v20110202-r8913' API Reference