org.pf.osf
Class ObjectSearchResult

java.lang.Object
  extended by org.pf.osf.ObjectContainer
      extended by org.pf.osf.ObjectSearchResult
Direct Known Subclasses:
LDAPSearchResult

public class ObjectSearchResult
extends ObjectContainer

Apart from returning the found objects a search result can contain information whether or not the size limit has been reached.

Version:
1.0
Author:
Manfred Duchrow

Field Summary
static int UNLIMITED_SIZE
          Represents the definition of an unlimited result container (value = 0)
 
Constructor Summary
ObjectSearchResult()
          Initialize the new instance with default values.
ObjectSearchResult(int initialCapacity)
          Initialize the new instance with an initial size.
ObjectSearchResult(int initialCapacity, int maximumSize)
          Initialize the new instance with an initial size and a maximum size.
 
Method Summary
 void add(AttributeReadAccess object)
          Adds the given object to the result if it is not yet full.
 void clear()
          Resets the result to contain nothing at all.
 int getSizeLimit()
          Returns the size limit that was set for the search that produced this result
 boolean isFull()
          Returns true if the result is full and no further objects can be added.
 boolean isSizeLimitExceeded()
          Returns true if the size limit has been exceeded.
 boolean remove(AttributeReadAccess object)
          Removes the given object from the container.
 void setSizeLimit(int limit)
          Sets the limit of objects this result may contain.
 
Methods inherited from class org.pf.osf.ObjectContainer
asArray, asList, contains, containsEqualObject, copy, find, find, find, find, find, find, findFirst, findFirst, findFirst, findFirstIgnoreCase, findIgnoreCase, get, isEmpty, removeEqual, set, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNLIMITED_SIZE

public static final int UNLIMITED_SIZE
Represents the definition of an unlimited result container (value = 0)

See Also:
Constant Field Values
Constructor Detail

ObjectSearchResult

public ObjectSearchResult()
Initialize the new instance with default values.


ObjectSearchResult

public ObjectSearchResult(int initialCapacity)
Initialize the new instance with an initial size.

Parameters:
initialCapacity - Initial size reserved for elements

ObjectSearchResult

public ObjectSearchResult(int initialCapacity,
                          int maximumSize)
Initialize the new instance with an initial size and a maximum size. If the given initial size is greater than the maximum size, then the maximum size will be used as initial size too.

Parameters:
initialCapacity - Initial size reserved for elements
Method Detail

getSizeLimit

public int getSizeLimit()
Returns the size limit that was set for the search that produced this result


setSizeLimit

public void setSizeLimit(int limit)
Sets the limit of objects this result may contain. Setting a value 0 means that there is no limit.

Parameters:
limit - The maximum number of objects to be contained by this result

add

public void add(AttributeReadAccess object)
Adds the given object to the result if it is not yet full. If it is full, the object will not be added and the flag sizeLimitExceeded will be set to true.

Overrides:
add in class ObjectContainer
See Also:
ObjectContainer.add(org.pf.reflect.AttributeReadAccess)

clear

public void clear()
Resets the result to contain nothing at all.

Overrides:
clear in class ObjectContainer
See Also:
ObjectContainer.clear()

remove

public boolean remove(AttributeReadAccess object)
Description copied from class: ObjectContainer
Removes the given object from the container. Returns true if the object was in the container, otherwise false. The object is looked up by identity (==) rather than equality (equals()).

Overrides:
remove in class ObjectContainer
Parameters:
object - The object to remove
See Also:
ObjectContainer.remove(org.pf.reflect.AttributeReadAccess)

isFull

public boolean isFull()
Returns true if the result is full and no further objects can be added. An attempt to add another object will set the flag sizeLimitExceeded to true and the object will not be added.


isSizeLimitExceeded

public boolean isSizeLimitExceeded()
Returns true if the size limit has been exceeded. That is, there has been an attempt to add another object to the result after it was full according to the defined size limit.