Package org.ldaptive.beans.reflect
Class DefaultReflectionTranscoder
- java.lang.Object
-
- org.ldaptive.beans.reflect.DefaultReflectionTranscoder
-
- All Implemented Interfaces:
ReflectionTranscoder
public class DefaultReflectionTranscoder extends java.lang.Object implements ReflectionTranscoder
Default implementation of a reflection transcoder. Determines the correct underlying reflection transcoder by inspecting the class type characteristics.- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.LoggerloggerLogger for this class.
-
Constructor Summary
Constructors Constructor Description DefaultReflectionTranscoder(java.lang.reflect.Type type)Creates a new default reflection transcoder.DefaultReflectionTranscoder(java.lang.reflect.Type type, ValueTranscoder<?> transcoder)Creates a new default reflection transcoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectdecodeBinaryValues(java.util.Collection<byte[]> values)Decodes the supplied values into an object.java.lang.ObjectdecodeStringValues(java.util.Collection<java.lang.String> values)Decodes the supplied values into an object.java.util.Collection<byte[]>encodeBinaryValues(java.lang.Object values)Encodes the supplied value into one or more byte arrays for use in an attribute.java.util.Collection<java.lang.String>encodeStringValues(java.lang.Object values)Encodes the supplied value into one or more strings for use in an attribute.protected ReflectionTranscodergetCollectionEncoder(java.lang.Class<?> type, java.lang.reflect.Type genericType)Returns the appropriate collection encoder for the supplied type.protected java.util.Set<SingleValueReflectionTranscoder<?>>getDefaultSingleValueTranscoders()Initializes the set of default single value transcoders.protected SingleValueReflectionTranscodergetSingleValueReflectionTranscoder(java.lang.Class<?> type)Returns the appropriate single value encoder for the supplied type.java.lang.Class<?>getType()Returns the type produced by this transcoder.booleansupports(java.lang.Class<?> type)Returns whether this transcoder can convert object of the supplied type.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultReflectionTranscoder
public DefaultReflectionTranscoder(java.lang.reflect.Type type)
Creates a new default reflection transcoder.- Parameters:
type- of object to transcode
-
DefaultReflectionTranscoder
public DefaultReflectionTranscoder(java.lang.reflect.Type type, ValueTranscoder<?> transcoder)Creates a new default reflection transcoder.- Parameters:
type- of object to transcodetranscoder- custom transcoder for this type
-
-
Method Detail
-
getDefaultSingleValueTranscoders
protected java.util.Set<SingleValueReflectionTranscoder<?>> getDefaultSingleValueTranscoders()
Initializes the set of default single value transcoders.- Returns:
- single value transcoders
-
getSingleValueReflectionTranscoder
protected SingleValueReflectionTranscoder getSingleValueReflectionTranscoder(java.lang.Class<?> type)
Returns the appropriate single value encoder for the supplied type.- Parameters:
type- to provide a single value encoder for- Returns:
- single value reflection transcoder
-
getCollectionEncoder
protected ReflectionTranscoder getCollectionEncoder(java.lang.Class<?> type, java.lang.reflect.Type genericType)
Returns the appropriate collection encoder for the supplied type.- Parameters:
type- to provide a collection encoder forgenericType- of the collection- Returns:
- reflection transcoder for a collection
-
decodeStringValues
public java.lang.Object decodeStringValues(java.util.Collection<java.lang.String> values)
Description copied from interface:ReflectionTranscoderDecodes the supplied values into an object.- Specified by:
decodeStringValuesin interfaceReflectionTranscoder- Parameters:
values- to decode- Returns:
- object initialized with the values
-
decodeBinaryValues
public java.lang.Object decodeBinaryValues(java.util.Collection<byte[]> values)
Description copied from interface:ReflectionTranscoderDecodes the supplied values into an object.- Specified by:
decodeBinaryValuesin interfaceReflectionTranscoder- Parameters:
values- to decode- Returns:
- object initialized with the values
-
encodeStringValues
public java.util.Collection<java.lang.String> encodeStringValues(java.lang.Object values)
Description copied from interface:ReflectionTranscoderEncodes the supplied value into one or more strings for use in an attribute.- Specified by:
encodeStringValuesin interfaceReflectionTranscoder- Parameters:
values- containing data to encode as strings- Returns:
- string attribute values
-
encodeBinaryValues
public java.util.Collection<byte[]> encodeBinaryValues(java.lang.Object values)
Description copied from interface:ReflectionTranscoderEncodes the supplied value into one or more byte arrays for use in an attribute.- Specified by:
encodeBinaryValuesin interfaceReflectionTranscoder- Parameters:
values- containing data to encode as byte arrays- Returns:
- binary attribute values
-
getType
public java.lang.Class<?> getType()
Description copied from interface:ReflectionTranscoderReturns the type produced by this transcoder.- Specified by:
getTypein interfaceReflectionTranscoder- Returns:
- type produced by this transcoder
-
supports
public boolean supports(java.lang.Class<?> type)
Description copied from interface:ReflectionTranscoderReturns whether this transcoder can convert object of the supplied type.- Specified by:
supportsin interfaceReflectionTranscoder- Parameters:
type- of object- Returns:
- whether the supplied type can be converted
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-