From d9722bcadc7bf619808426fc82cbb0c74b1646b0 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Thu, 09 Sep 2010 17:31:59 +0000
Subject: [PATCH] Make EntryReader and ChangeRecordReader APIs easier to use:

---
 sdk/src/org/opends/sdk/ldif/ChangeRecordReader.java |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/sdk/src/org/opends/sdk/ldif/ChangeRecordReader.java b/sdk/src/org/opends/sdk/ldif/ChangeRecordReader.java
index 0e73da8..5364319 100644
--- a/sdk/src/org/opends/sdk/ldif/ChangeRecordReader.java
+++ b/sdk/src/org/opends/sdk/ldif/ChangeRecordReader.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2009-2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.ldif;
@@ -31,8 +31,7 @@
 
 import java.io.Closeable;
 import java.io.IOException;
-
-import org.opends.sdk.DecodeException;
+import java.util.NoSuchElementException;
 
 
 
@@ -46,10 +45,6 @@
  * malformed change records and, if it is possible, how they are handled.
  * <li>Any synchronization limitations.
  * </ul>
- * <p>
- * TODO: LDIFInputStreamReader
- * <p>
- * TODO: SearchResultEntryReader
  */
 public interface ChangeRecordReader extends Closeable
 {
@@ -62,23 +57,35 @@
    * @throws IOException
    *           If an unexpected IO error occurred while closing.
    */
+  @Override
   void close() throws IOException;
 
 
 
   /**
+   * Returns {@code true} if this reader contains another change record,
+   * blocking if necessary until either the next change record is available or
+   * the end of the stream is reached.
+   *
+   * @return {@code true} if this reader contains another change record.
+   * @throws IOException
+   *           If an unexpected IO error occurred.
+   */
+  boolean hasNext() throws IOException;
+
+
+
+  /**
    * Reads the next change record, blocking if necessary until a change record
    * is available. If the next change record does not contain a change type then
    * it will be treated as an {@code Add} change record.
    *
-   * @return The next change record, or {@code null} if there are no more change
-   *         records to be read.
-   * @throws DecodeException
-   *           If the change record could not be decoded because it was
-   *           malformed.
+   * @return The next change record.
    * @throws IOException
    *           If an unexpected IO error occurred while reading the change
    *           record.
+   * @throws NoSuchElementException
+   *           If this reader does not contain any more change records.
    */
-  ChangeRecord readChangeRecord() throws DecodeException, IOException;
+  ChangeRecord readChangeRecord() throws IOException, NoSuchElementException;
 }

--
Gitblit v1.10.0