Class LdifReader

java.lang.Object
org.ldaptive.io.LdifReader
All Implemented Interfaces:
SearchResultReader

public class LdifReader extends Object implements SearchResultReader
Reads an LDIF from a Reader and returns a SearchResponse. This implementation only supports entry records. It does not support change records or include statements.
  • Field Details

    • READ_AHEAD_LIMIT

      private static final int READ_AHEAD_LIMIT
      Mark read back buffer size.
      See Also:
    • logger

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

      private final Reader ldifReader
      Reader to read from.
  • Constructor Details

    • LdifReader

      public LdifReader(Reader reader)
      Creates a new ldif reader.
      Parameters:
      reader - to read LDIF from
  • Method Details

    • read

      public SearchResponse read() throws IOException
      Reads LDIF data from the reader and returns a search result.
      Specified by:
      read in interface SearchResultReader
      Returns:
      search result derived from the LDIF
      Throws:
      IOException - if an error occurs using the reader
    • readSection

      private List<String> readSection(BufferedReader reader) throws IOException
      Reads the supplied reader line-by-line until the reader is empty or a empty line is encountered. Lines containing comments are ignored.
      Parameters:
      reader - to read
      Returns:
      list of a lines in the section
      Throws:
      IOException - if an error occurs reading
    • parseEntry

      private LdapEntry parseEntry(List<String> section) throws IOException
      Parses the supplied array of LDIF lines and returns an LDAP entry.
      Parameters:
      section - of LDIF lines
      Returns:
      ldap entry
      Throws:
      IOException - if an errors occurs reading a URI in the LDIF
    • parseAttribute

      private LdapAttribute parseAttribute(String line) throws IOException
      Parses the supplied line and returns an attribute with a single value found in the line.
      Parameters:
      line - to parse
      Returns:
      ldap attribute
      Throws:
      IOException - if an errors occurs reading a URI in the LDIF
    • parseReference

      private SearchResultReference parseReference(List<String> section)
      Parses the supplied array of LDIF lines and returns a search reference.
      Parameters:
      section - of LDIF lines
      Returns:
      search reference