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/EntryReader.java |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/sdk/src/org/opends/sdk/ldif/EntryReader.java b/sdk/src/org/opends/sdk/ldif/EntryReader.java
index a42c293..688b827 100644
--- a/sdk/src/org/opends/sdk/ldif/EntryReader.java
+++ b/sdk/src/org/opends/sdk/ldif/EntryReader.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,8 @@
 
 import java.io.Closeable;
 import java.io.IOException;
+import java.util.NoSuchElementException;
 
-import org.opends.sdk.DecodeException;
 import org.opends.sdk.Entry;
 
 
@@ -46,10 +46,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 EntryReader extends Closeable
 {
@@ -62,19 +58,32 @@
    * @throws IOException
    *           If an unexpected IO error occurred while closing.
    */
+  @Override
   void close() throws IOException;
 
 
 
   /**
+   * Returns {@code true} if this reader contains another entry, blocking if
+   * necessary until either the next entry is available or the end of the stream
+   * is reached.
+   *
+   * @return {@code true} if this reader contains another entry.
+   * @throws IOException
+   *           If an unexpected IO error occurred.
+   */
+  boolean hasNext() throws IOException;
+
+
+
+  /**
    * Reads the next entry, blocking if necessary until an entry is available.
    *
-   * @return The next entry or {@code null} if there are no more entries to be
-   *         read.
-   * @throws DecodeException
-   *           If the entry could not be decoded because it was malformed.
+   * @return The next entry.
    * @throws IOException
    *           If an unexpected IO error occurred while reading the entry.
+   * @throws NoSuchElementException
+   *           If this reader does not contain any more entries.
    */
-  Entry readEntry() throws DecodeException, IOException;
+  Entry readEntry() throws IOException, NoSuchElementException;
 }

--
Gitblit v1.10.0