2 Replies Latest reply on Jan 7, 2013 5:09 PM by bwallis42

    RangeIterator.getNumberRemaining() missing

    bwallis42

      The javadoc for the RangeIterator.getSize() method says that you should be able to call RangeIterator.getNumRemaining() to find out how many elements are left to be iterated over (at least an estimate of the number).

       

      This method is not present in the javax.jcr.RangeIterator interface in jcr 2.0. Is it meant to be there?

        • 1. Re: RangeIterator.getNumberRemaining() missing
          rhauch

          I actually don't remember that method being in JCR 1.0, either.

           

          You can easily determine how many are left by using "ri.getSize() - ri.getPosition()".

          • 2. Re: RangeIterator.getNumberRemaining() missing
            bwallis42

            Randall Hauch wrote:

             

            I actually don't remember that method being in JCR 1.0, either.

             

            You can easily determine how many are left by using "ri.getSize() - ri.getPosition()".

             

            Not always, the doco for RangeIterator.getSize() says that it must return -1 if it doesn't know what the size is and suggests using the missing getNumberRemaining() as an estimate of the remaining number.

             

            {quote}

            In some implementations precise information about the number of elements may not be available. In such cases this method must return -1. API clients will then be able to use RangeIterator.getNumberRemaining to get an estimate on the number of elements.

            {quote}

             

            It isn't a big problem for me, I was just using the value to correctly size an allocated list for a return value, I can just let the list grow as needed but I can see in some cases where this might be more annoying.