com.onwbp.adaptation
Class RequestResult

java.lang.Object
  extended bycom.onwbp.adaptation.RequestResult

public final class RequestResult
extends Object

Represents the result of a Request.

Traversal

The preferred protocol for iterating over a request result is to use nextAdaptation(). This protocol is more adequate than getAdaptation(int), because in the default "READ UNCOMMITTED" isolation level, it supports transparently a concurrent deletion on the tables viewed. Moreover it does not call getSize(), hence it will be less expensive if the iteration is not performed on all occurrences.

Concurrency

Regarding multi-threading on a single instance, please note that the method nextAdaptation() is not synchronized. If multiple threads invoke it concurrently on the same instance, they must be synchronized externally.

If table is updated concurrently, the general rules regarding Concurrency and isolation levels are applied.

See Also:
Request, Concurrency and isolation levels

Method Summary
 boolean contains(Adaptation anOccurrence)
          Returns true if the occurrence specified belongs to the result of this request (even if the occurrence is obsolete).
 Adaptation getAdaptation(int anIndex)
           Returns the occurrence at the position specified in this result.
 Request getRequest()
          Returns the request that has created this result.
 int getSize()
          Returns the total number of occurrences held by this result.
 AdaptationTable getTable()
           
 boolean isEmpty()
          Returns true if result is empty (its size is 0).
 boolean isObsolete()
          Returns true if result may have changed since last computation.
 Adaptation nextAdaptation()
          Moves the cursor to the next occurrence in the result and returns it.
 void refresh()
          Forces a full recomputation of this result.
 boolean refreshIfNeeded()
          Performs a refresh of the result if it may have changed.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getTable

public AdaptationTable getTable()

getAdaptation

public Adaptation getAdaptation(int anIndex)
                         throws ArrayIndexOutOfBoundsException

Returns the occurrence at the position specified in this result.

Warning: this method will return null if a deletion has been concurrently performed (see Concurrency and isolation levels). It is advised to use nextAdaptation() instead.

Throws:
ArrayIndexOutOfBoundsException

isEmpty

public boolean isEmpty()
Returns true if result is empty (its size is 0).


isObsolete

public boolean isObsolete()
Returns true if result may have changed since last computation.

This happens if table has been updated or if request has been changed (via a set... method).

See Also:
refreshIfNeeded()

toString

public String toString()

getSize

public int getSize()
Returns the total number of occurrences held by this result.

Warning: as this method must perform the full computation of the result it may be expensive for large numbers of occurrences. For an iteration, it is more advisable to use the method nextAdaptation() than a loop between 0 and getSize().


nextAdaptation

public Adaptation nextAdaptation()
Moves the cursor to the next occurrence in the result and returns it. Returns null if result has no more elements.

Code sample

 RequestResult result = ...;
 for (Adaptation occ; (occ = result.nextAdaptation()) != null;)
 {
    ...
 }

or (better ?):

 while (true) 
 {
    Adaptation occ = result.nextAdaptation();
    if (occ == null)
       break;
    ...
 }

Concurrency

See Class comment

Returns:
the next occurrence in the result, null if no more elements.

refresh

public void refresh()
             throws IncompatibleChangeError
Forces a full recomputation of this result.

Throws:
IncompatibleChangeError - if underlying schema has become unavailable or table node has been removed from schema.

refreshIfNeeded

public boolean refreshIfNeeded()
                        throws IncompatibleChangeError
Performs a refresh of the result if it may have changed.

Returns:
true if a refresh has been done, false otherwise.
Throws:
IncompatibleChangeError
See Also:
isObsolete()

getRequest

public Request getRequest()
Returns the request that has created this result.


contains

public boolean contains(Adaptation anOccurrence)
Returns true if the occurrence specified belongs to the result of this request (even if the occurrence is obsolete).



(report a bug)
EBX.Platform 4.5.2 [0601:0004]
Copyright Orchestra Networks 2000-2008. All rights reserved.