Class Ldif

  • All Implemented Interfaces:
    java.io.Serializable

    public class Ldif
    extends java.lang.Object
    implements java.io.Serializable
    Ldif contains functions for converting LDAP search result sets into LDIF.
    Version:
    $Revision: 1330 $ $Date: 2010-05-24 00:10:53 +0200 (Mon, 24 May 2010) $
    Author:
    Middleware Services
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected LdapBeanFactory beanFactory
      Ldap bean factory.
      static int COLON_CHAR
      ASCII decimal value of colon.
      static int CR_CHAR
      ASCII decimal value of carriage return.
      static int LA_CHAR
      ASCII decimal value of left arrow.
      static int LF_CHAR
      ASCII decimal value of line feed.
      protected org.apache.commons.logging.Log logger
      Log for this class.
      static int MAX_ASCII_CHAR
      ASCII decimal value of highest character.
      static int NUL_CHAR
      ASCII decimal value of nul.
      static int SP_CHAR
      ASCII decimal value of space.
    • Constructor Summary

      Constructors 
      Constructor Description
      Ldif()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String createLdif​(LdapResult result)
      This will take the results of a prior LDAP query and convert it to LDIF.
      java.lang.String createLdif​(java.util.Iterator<javax.naming.directory.SearchResult> results)
      This will take the results of a prior LDAP query and convert it to LDIF.
      protected java.lang.String createLdifEntry​(LdapEntry ldapEntry)
      This will take an LDAP entry and convert it to LDIF.
      LdapBeanFactory getLdapBeanFactory()
      Returns the factory for creating ldap beans.
      java.util.Iterator<javax.naming.directory.SearchResult> importLdif​(java.io.Reader reader)
      This will take a Reader containing an LDIF and convert it to an Iterator of LDAP search results.
      LdapResult importLdifToLdapResult​(java.io.Reader reader)
      This will take a Reader containing an LDIF and convert it to an LdapResult.
      void outputLdif​(LdapResult result, java.io.Writer writer)
      This will write the supplied LDAP search results to the supplied writer in LDIF form.
      void outputLdif​(java.util.Iterator<javax.naming.directory.SearchResult> results, java.io.Writer writer)
      This will write the supplied LDAP search results to the supplied writer in LDIF form.
      void setLdapBeanFactory​(LdapBeanFactory lbf)
      Sets the factory for creating ldap beans.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LF_CHAR

        public static final int LF_CHAR
        ASCII decimal value of line feed.
        See Also:
        Constant Field Values
      • CR_CHAR

        public static final int CR_CHAR
        ASCII decimal value of carriage return.
        See Also:
        Constant Field Values
      • COLON_CHAR

        public static final int COLON_CHAR
        ASCII decimal value of colon.
        See Also:
        Constant Field Values
      • LA_CHAR

        public static final int LA_CHAR
        ASCII decimal value of left arrow.
        See Also:
        Constant Field Values
      • MAX_ASCII_CHAR

        public static final int MAX_ASCII_CHAR
        ASCII decimal value of highest character.
        See Also:
        Constant Field Values
      • logger

        protected final org.apache.commons.logging.Log logger
        Log for this class.
    • Constructor Detail

      • Ldif

        public Ldif()
    • Method Detail

      • getLdapBeanFactory

        public LdapBeanFactory getLdapBeanFactory()
        Returns the factory for creating ldap beans.
        Returns:
        LdapBeanFactory
      • setLdapBeanFactory

        public void setLdapBeanFactory​(LdapBeanFactory lbf)
        Sets the factory for creating ldap beans.
        Parameters:
        lbf - LdapBeanFactory
      • createLdif

        public java.lang.String createLdif​(java.util.Iterator<javax.naming.directory.SearchResult> results)
        This will take the results of a prior LDAP query and convert it to LDIF.
        Parameters:
        results - Iterator of LDAP search results
        Returns:
        String
      • createLdif

        public java.lang.String createLdif​(LdapResult result)
        This will take the results of a prior LDAP query and convert it to LDIF.
        Parameters:
        result - LdapResult
        Returns:
        String
      • createLdifEntry

        protected java.lang.String createLdifEntry​(LdapEntry ldapEntry)
        This will take an LDAP entry and convert it to LDIF.
        Parameters:
        ldapEntry - LdapEntry to convert
        Returns:
        String
      • outputLdif

        public void outputLdif​(java.util.Iterator<javax.naming.directory.SearchResult> results,
                               java.io.Writer writer)
                        throws java.io.IOException
        This will write the supplied LDAP search results to the supplied writer in LDIF form.
        Parameters:
        results - Iterator of LDAP search results
        writer - Writer to write to
        Throws:
        java.io.IOException - if an error occurs while writing to the output stream
      • outputLdif

        public void outputLdif​(LdapResult result,
                               java.io.Writer writer)
                        throws java.io.IOException
        This will write the supplied LDAP search results to the supplied writer in LDIF form.
        Parameters:
        result - LdapResult
        writer - Writer to write to
        Throws:
        java.io.IOException - if an error occurs while writing to the output stream
      • importLdif

        public java.util.Iterator<javax.naming.directory.SearchResult> importLdif​(java.io.Reader reader)
                                                                           throws java.io.IOException
        This will take a Reader containing an LDIF and convert it to an Iterator of LDAP search results. Provides a loose implementation of RFC 2849. Should not be used to validate LDIF format as it does not enforce strictness.
        Parameters:
        reader - Reader containing LDIF content
        Returns:
        Iterator - of LDAP search results
        Throws:
        java.io.IOException - if an I/O error occurs
      • importLdifToLdapResult

        public LdapResult importLdifToLdapResult​(java.io.Reader reader)
                                          throws java.io.IOException
        This will take a Reader containing an LDIF and convert it to an LdapResult. Provides a loose implementation of RFC 2849. Should not be used to validate LDIF format as it does not enforce strictness.
        Parameters:
        reader - Reader containing LDIF content
        Returns:
        LdapResult - LDAP search results
        Throws:
        java.io.IOException - if an I/O error occurs