/**
 * This class will instill 'normal' iterator behavior to a ColumnFamilyResult.
 * Simply instantiate this class while passing your ColumnFamilyResult as a 
 * constructor argument.
 * 
 * Ex.
 * 
 * ColumnFamilyResultIterator myResultsInterator = 
 *      new ColumnFamilyResultIterator(someColumnFamilyResult);
 * 
 * You can then use myResultsInterator with for loops or iterate with a while loop 
 * just as with any standard java iterator. 
 * 
 */
package me.prettyprint.cassandra.service.template;

import java.util.Iterator;

import me.prettyprint.cassandra.service.template.ColumnFamilyResult;

public class ColumnFamilyResultIterator implements Iterator<ColumnFamilyResult<?,?>> {
        private ColumnFamilyResult<?, ?> res;
        private boolean isStart = true;

        public ColumnFamilyResultIterator(ColumnFamilyResult<?, ?> res) {
            this.res = res;
        }
        
        public boolean hasNext()
        {
            boolean retval = false;
            if (isStart)
            {
                retval = res.hasResults();
            }
            else
            {
                retval = res.hasNext();
            }
            return retval;
        }

        public ColumnFamilyResult<?, ?> getRes()
        {
            return res;
        }

        public void setRes(ColumnFamilyResult<?, ?> res)
        {
            this.res = res;
        }

        public ColumnFamilyResult<?, ?> next()
        {
            if (isStart) 
            {
                isStart = false;
                return res;
            }
            else 
            {
                return (ColumnFamilyResult<?, ?>) res.next();
            }
        }
        
        public void remove()
        {
            res.remove();
        }
}

@@ -891,32 +891,26 @@
  %7D%0A        %0A
-        
+%09%09
 public boole
@@ -921,39 +921,25 @@
 asNext()
-%0A        %7B%0A            
+ %0A%09%09%7B%0A%09%09%09
 boolean 
@@ -958,201 +958,162 @@
 se;%0A
-            if (isStart)%0A            %7B%0A                retval = res.hasResults();%0A            %7D%0A            else%0A            %7B%0A                retval = res.hasNext();%0A            %7D%0A            
+%09%09%09if (isStart) %0A%09%09%09%7B%0A%09%09%09%09if(res.hasResults() %7C%7C res.hasNext()) %0A%09%09%09%09%7B%0A%09%09%09%09%09retval = true; %0A%09%09%09%09%7D%0A%09%09%09%7D %0A%09%09%09else %0A%09%09%09%7B%0A%09%09%09%09retval = res.hasNext();%0A%09%09%09%7D%0A%09%09%09
 retu
@@ -1123,25 +1123,20 @@
 retval;%0A
-        %7D
+%09%09%7D%0A
 %0A%0A      

Fix bug in hasNext when no result for a key is returned