From 1683816b3c9b06add23cd7a1c9358f86ac6ca6b6 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 02 Dec 2011 10:06:55 +0000
Subject: [PATCH] Fix OPENDJ-375: Add ConnectionEntryReader.isEntry()
---
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java | 73 ++++++++++++++++++++++++------------
1 files changed, 49 insertions(+), 24 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java
index 053da05..c522788 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java
+++ b/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;
--
Gitblit v1.10.0