class LdifReader implements SearchResultReader {

  @Override
  public SearchResponse read()
    throws IOException
  {
    final SearchResponse result = new SearchResponse();
    final BufferedReader br = new BufferedReader(ldifReader);
    String line;
    br.mark(READ_AHEAD_LIMIT);
    while ((line = br.readLine()) != null) {
      if (!"".equals(line)) {
        br.reset();
        final List<String> section = readSection(br);
        if (!section.isEmpty()) {
          if (section.get(0).startsWith("version")) {
            section.remove(0);
          }
          if (!section.isEmpty()) {
            if (section.get(0).startsWith("dn")) {
              result.addEntries(parseEntry(section));
            } else if (section.get(0).startsWith("ref")) {
              result.addReferences(parseReference(section));
            } else {
              logger.debug("Unknown LDIF section {}", section.get(0));
            }
          }
        }
      }
      br.mark(READ_AHEAD_LIMIT);
    }
    return result;
  }

  public  LdifReader(final Reader reader);

}