org.ldaptive.beans.spring
Class SpelAttributeValueMutator

java.lang.Object
  extended by org.ldaptive.beans.spring.SpelAttributeValueMutator
All Implemented Interfaces:
AttributeValueMutator

public class SpelAttributeValueMutator
extends Object
implements AttributeValueMutator

Attribute mutator that uses a SPEL expression and evaluation context.

Version:
$Revision: 3013 $ $Date: 2014-07-02 11:26:52 -0400 (Wed, 02 Jul 2014) $
Author:
Middleware Services

Field Summary
protected  org.slf4j.Logger logger
          Logger for this class.
 
Constructor Summary
SpelAttributeValueMutator(Attribute attr, org.springframework.expression.EvaluationContext context)
          Creates a new spel attribute value mutator.
 
Method Summary
protected
<T> T
convertValue(Object value, Class<?> sourceType, Class<T> targetType)
          Converts the supplied value to the target type.
protected static
<T> Collection<T>
createCollection(Class<?> type, int size)
          Creates a best fit collection for the supplied type.
 Collection<byte[]> getBinaryValues(Object object)
          Returns the binary values of the attribute.
 String getName()
          Returns the name of the attribute.
 org.ldaptive.SortBehavior getSortBehavior()
          Returns the sort behavior of the attribute.
 Collection<String> getStringValues(Object object)
          Returns the string values of the attribute.
protected
<T> Collection<T>
getValues(Object object, Class<T> type)
          Uses the configured expression and evaluation context to retrieve values from the supplied object.
 boolean isBinary()
          Returns whether the attribute is binary.
 void setBinaryValues(Object object, Collection<byte[]> values)
          Sets the binary values of the attribute.
 void setStringValues(Object object, Collection<String> values)
          Sets the string values of the attribute.
protected
<T> void
setValues(Object object, Collection<T> values, Class<T> type)
          Uses the configured expression and evaluation context to set values on the supplied object.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Logger for this class.

Constructor Detail

SpelAttributeValueMutator

public SpelAttributeValueMutator(Attribute attr,
                                 org.springframework.expression.EvaluationContext context)
Creates a new spel attribute value mutator.

Parameters:
attr - containing the SPEL configuration
context - containing the values
Method Detail

getName

public String getName()
Returns the name of the attribute.

Specified by:
getName in interface AttributeValueMutator
Returns:
attribute name

isBinary

public boolean isBinary()
Returns whether the attribute is binary.

Specified by:
isBinary in interface AttributeValueMutator
Returns:
whether the attribute is binary

getSortBehavior

public org.ldaptive.SortBehavior getSortBehavior()
Returns the sort behavior of the attribute.

Specified by:
getSortBehavior in interface AttributeValueMutator
Returns:
sort behavior of the attribute

getStringValues

public Collection<String> getStringValues(Object object)
Returns the string values of the attribute.

Specified by:
getStringValues in interface AttributeValueMutator
Parameters:
object - containing attribute values
Returns:
attribute values

getBinaryValues

public Collection<byte[]> getBinaryValues(Object object)
Returns the binary values of the attribute.

Specified by:
getBinaryValues in interface AttributeValueMutator
Parameters:
object - containing attribute values
Returns:
attribute values

getValues

protected <T> Collection<T> getValues(Object object,
                                      Class<T> type)
Uses the configured expression and evaluation context to retrieve values from the supplied object. Values are the placed in a collection and returned.

Type Parameters:
T - either String or byte[]
Parameters:
object - to get values from
type - of objects to place in the collection
Returns:
values in the supplied object

convertValue

protected <T> T convertValue(Object value,
                             Class<?> sourceType,
                             Class<T> targetType)
Converts the supplied value to the target type. If a custom transcoder has been configured it is used. Otherwise the type converter from the evaluation context is used.

Type Parameters:
T - either String or byte[]
Parameters:
value - to convert
sourceType - to convert from
targetType - to convert to
Returns:
converted value

setStringValues

public void setStringValues(Object object,
                            Collection<String> values)
Sets the string values of the attribute.

Specified by:
setStringValues in interface AttributeValueMutator
Parameters:
object - to set values on
values - to set

setBinaryValues

public void setBinaryValues(Object object,
                            Collection<byte[]> values)
Sets the binary values of the attribute.

Specified by:
setBinaryValues in interface AttributeValueMutator
Parameters:
object - to set values on
values - to set

setValues

protected <T> void setValues(Object object,
                             Collection<T> values,
                             Class<T> type)
Uses the configured expression and evaluation context to set values on the supplied object. If a custom transcoder has been configured it is executed on the values before they are passed to the expression.

Type Parameters:
T - either String or byte[]
Parameters:
object - to set values on
values - to set
type - of objects in the collection

toString

public String toString()

Overrides:
toString in class Object

createCollection

protected static <T> Collection<T> createCollection(Class<?> type,
                                                    int size)
Creates a best fit collection for the supplied type.

Type Parameters:
T - collection type
Parameters:
type - of collection to create
size - of the collection
Returns:
collection


Copyright © 2003-2014 Virginia Tech. All Rights Reserved.