com.ca.jcs.enumeration
Class RawNamingEnumeration<T>

java.lang.Object
  extended by com.ca.jcs.enumeration.RawNamingEnumeration<T>
All Implemented Interfaces:
Enumeration<T>, NamingEnumeration<T>
Direct Known Subclasses:
AppendingNamingEnumeration, LookAheadRawNamingEnumeration, PagedResultsNamingEnumeration, SDKSearchEnumeration, SDKWSNamingEnumeration, UserNamingEnumeration

public abstract class RawNamingEnumeration<T>
extends Object
implements NamingEnumeration<T>

A NamingEnumeration which counts the number of returned objects, and which enforces any optionally provided time / size limits.


Field Summary
protected  long countLimit
           
protected  int scope
           
protected  long startTime
           
protected  long timeLimit
           
protected  long visitedCount
           
 
Constructor Summary
RawNamingEnumeration()
          Create an enumeration around the provided queryResults, which were determined in a single bulk query.
RawNamingEnumeration(long countLimit)
          Create an enumeration using the provided and countLimit (0 means unlimited).
RawNamingEnumeration(SearchControls searchControls)
          Create an enumeration taking the time and count limits from the provided searchControls.
 
Method Summary
 long getCountLimit()
          Returns any configured size limit (0 means no limit is enforced).
 NamingException getNonFatalException()
           
 long getTimeLimit()
          Returns any configured time limit, in milliseconds (0 means no limit is enforced).
 long getVisitedCount()
           
 boolean hasMore()
          Returns true if rawHasMore() returns true, unless a time limit was configured and has been exhausted in which case throws a LdapTimeLimitExceededException.
 boolean hasMoreElements()
          Exception-free wrapper around hasMore().
 T next()
          Returns value returned by rawNext(), unless a size limit was configured and has been exceeded in which case throws a LdapSizeLimitExceededException.
 T nextElement()
          Exception-free wrapper around next().
abstract  boolean rawHasMore()
          Override this method to return whether more values remain to be returned.
abstract  T rawNext()
          Override this method to return next value to be returned from next().
 void setCountLimit(long countLimit)
           
 void setNonFatalException(NamingException nonFatalException)
          Allows an exception to be stored and thrown after all results have been returned.
 void setTimeLimit(long timeLimit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.naming.NamingEnumeration
close
 

Field Detail

startTime

protected long startTime

timeLimit

protected long timeLimit

countLimit

protected long countLimit

scope

protected int scope

visitedCount

protected long visitedCount
Constructor Detail

RawNamingEnumeration

public RawNamingEnumeration(long countLimit)
Create an enumeration using the provided and countLimit (0 means unlimited). Should only be used when safer RawNamingEnumeration(SearchControls) constructor is not an option.


RawNamingEnumeration

public RawNamingEnumeration()
Create an enumeration around the provided queryResults, which were determined in a single bulk query. This can be more runtime efficient but is less scalable then streaming results through an enumeration one-by-one, due to needing all results in memory at once. Should only be used when safer RawNamingEnumeration(SearchControls) constructor is not an option.


RawNamingEnumeration

public RawNamingEnumeration(SearchControls searchControls)
Create an enumeration taking the time and count limits from the provided searchControls.

Method Detail

getTimeLimit

public long getTimeLimit()
Returns any configured time limit, in milliseconds (0 means no limit is enforced).


setTimeLimit

public void setTimeLimit(long timeLimit)

getCountLimit

public long getCountLimit()
Returns any configured size limit (0 means no limit is enforced).


setCountLimit

public void setCountLimit(long countLimit)

getVisitedCount

public long getVisitedCount()

getNonFatalException

public NamingException getNonFatalException()

setNonFatalException

public void setNonFatalException(NamingException nonFatalException)
Allows an exception to be stored and thrown after all results have been returned.


rawHasMore

public abstract boolean rawHasMore()
                            throws NamingException
Override this method to return whether more values remain to be returned.

Throws:
NamingException

rawNext

public abstract T rawNext()
                   throws NamingException
Override this method to return next value to be returned from next().

Throws:
NamingException

hasMore

public boolean hasMore()
                throws NamingException
Returns true if rawHasMore() returns true, unless a time limit was configured and has been exhausted in which case throws a LdapTimeLimitExceededException.

Specified by:
hasMore in interface NamingEnumeration<T>
Throws:
NamingException

next

public final T next()
             throws NamingException
Returns value returned by rawNext(), unless a size limit was configured and has been exceeded in which case throws a LdapSizeLimitExceededException. Also throws a NoSuchElementException if hasMore() returns false.

Specified by:
next in interface NamingEnumeration<T>
Throws:
NamingException

hasMoreElements

public boolean hasMoreElements()
Exception-free wrapper around hasMore().

Specified by:
hasMoreElements in interface Enumeration<T>

nextElement

public T nextElement()
Exception-free wrapper around next().

Specified by:
nextElement in interface Enumeration<T>


Created 2011-07-14 13:27 EST