mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
02.06.2011 1683816b3c9b06add23cd7a1c9358f86ac6ca6b6
Fix OPENDJ-375: Add ConnectionEntryReader.isEntry()
4 files modified
79 ■■■■■ changed files
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java 73 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/javadoc/overview.html 2 ●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/site/xdoc/index.xml 2 ●●● patch | view | raw | blame | history
opendj3/src/main/docbkx/dev-guide/chap-get-sdk.xml 2 ●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java
@@ -70,7 +70,7 @@
 * {
 *   while (reader.hasNext())
 *   {
 *     if (!reader.isReference())
 *     if (reader.isEntry())
 *     {
 *       SearchResultEntry entry = reader.readEntry();
 *
@@ -283,6 +283,52 @@
  /**
   * Waits for the next search result entry or reference to become available and
   * returns {@code true} if it is an entry, or {@code false} if it is a
   * reference.
   *
   * @return {@code true} if the next search result is an entry, or
   *         {@code false} if it is a reference.
   * @throws ErrorResultIOException
   *           If there are no more search result entries or references and the
   *           search result code indicates that the search operation failed for
   *           some reason.
   * @throws InterruptedIOException
   *           If the current thread was interrupted while waiting.
   * @throws NoSuchElementException
   *           If there are no more search result entries or references and the
   *           search result code indicates that the search operation succeeded.
   */
  public boolean isEntry() throws ErrorResultIOException,
      InterruptedIOException, NoSuchElementException
  {
    // Throws ErrorResultIOException if search returned error.
    if (!hasNext())
    {
      // Search has completed successfully.
      throw new NoSuchElementException();
    }
    // Entry or reference?
    final Response r = nextResponse;
    if (r instanceof SearchResultEntry)
    {
      return true;
    }
    else if (r instanceof SearchResultReference)
    {
      return false;
    }
    else
    {
      throw new RuntimeException("Unexpected response type: "
          + r.getClass().toString());
    }
  }
  /**
   * Waits for the next search result entry or reference to become available and
   * returns {@code true} if it is a reference, or {@code false} if it is an
   * entry.
   *
@@ -301,28 +347,7 @@
  public boolean isReference() throws ErrorResultIOException,
      InterruptedIOException, NoSuchElementException
  {
    // Throws ErrorResultIOException if search returned error.
    if (!hasNext())
    {
      // Search has completed successfully.
      throw new NoSuchElementException();
    }
    // Entry or reference.
    final Response r = nextResponse;
    if (r instanceof SearchResultEntry)
    {
      return false;
    }
    else if (r instanceof SearchResultReference)
    {
      return true;
    }
    else
    {
      throw new RuntimeException("Unexpected response type: "
          + r.getClass().toString());
    }
    return !isEntry();
  }
@@ -353,7 +378,7 @@
  public SearchResultEntry readEntry() throws SearchResultReferenceIOException,
      ErrorResultIOException, InterruptedIOException, NoSuchElementException
  {
    if (!isReference())
    if (isEntry())
    {
      final SearchResultEntry entry = (SearchResultEntry) nextResponse;
      nextResponse = null;
opendj3/opendj-ldap-sdk/src/main/javadoc/overview.html
@@ -32,7 +32,7 @@
      final ConnectionEntryReader reader = connection.search(baseDN, scope, filter, attributes);
      while (reader.hasNext())
      {
        if (!reader.isReference())
        if (reader.isEntry())
        {
          // Got an entry.
          final SearchResultEntry entry = reader.readEntry();
opendj3/opendj-ldap-sdk/src/site/xdoc/index.xml
@@ -147,7 +147,7 @@
  final ConnectionEntryReader reader = connection.search(baseDN, scope, filter, attributes);
  while (reader.hasNext())
  {
    if (!reader.isReference())
    if (reader.isEntry())
    {
      // Got an entry.
      final SearchResultEntry entry = reader.readEntry();
opendj3/src/main/docbkx/dev-guide/chap-get-sdk.xml
@@ -244,7 +244,7 @@
        "dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(uid=bjensen)", "*");
      while (reader.hasNext())
      {
        if (!reader.isReference())
        if (reader.isEntry())
        {
          // Got an entry.
          final SearchResultEntry entry = reader.readEntry();