Class AbstractContextMapper<T>

java.lang.Object
org.springframework.ldap.core.support.AbstractContextMapper<T>
All Implemented Interfaces:
ContextMapper<T>

public abstract class AbstractContextMapper<T> extends Object implements ContextMapper<T>
Abstract superclass that may be used instead of implementing ContextMapper directly. Subclassing from this superclass, the supplied context will be automatically cast to DirContextOperations. Note that if you use your own DirObjectFactory, this implementation will fail with a ClassCastException.
  • Constructor Details

    • AbstractContextMapper

      public AbstractContextMapper()
  • Method Details

    • mapFromContext

      public final T mapFromContext(Object ctx)
      Map a single LDAP Context to an object. The supplied Object ctx is the object from a single SearchResult, Binding, or a lookup operation.
      Specified by:
      mapFromContext in interface ContextMapper<T>
      Parameters:
      ctx - the context to map to an object. Typically this will be a DirContextAdapter instance, unless a project specific DirObjectFactory has been specified on the ContextSource.
      Returns:
      an object built from the data in the context.
      Throws:
      ClassCastException - if a custom DirObjectFactory implementation is used, causing the objects passed in be anything else than DirContextOperations instances.
    • doMapFromContext

      protected abstract T doMapFromContext(DirContextOperations ctx)
      Map a single DirContextOperation to an object. The supplied instance is the object supplied to mapFromContext(Object) cast to a DirContextOperations.
      Parameters:
      ctx - the context to map to an object.
      Returns:
      an object built from the data in the context.