com.jrockit.memleak.value
Class KnownTruncatable<T>

java.lang.Object
  extended by com.jrockit.memleak.value.KnownTruncatable<T>
Type Parameters:
T - the element type
All Implemented Interfaces:
IResult<T[]>, ITruncatable<T>

public class KnownTruncatable<T>
extends java.lang.Object
implements ITruncatable<T>

An implementation of ITruncatable for known results. (Custom ITruncatable implementations may also be used for asynchronous results, similar to Future.)


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jrockit.memleak.ITruncatable
ITruncatable.Reason
 
Constructor Summary
KnownTruncatable(T[] result)
          Create a new KnownTruncatable, not truncated.
KnownTruncatable(T[] result, java.lang.Exception exception)
          Create a new KnownTruncatable, possibly truncated.
KnownTruncatable(T[] result, ITruncatable.Reason reason)
          Create a new KnownTruncatable, possibly truncated.
 
Method Summary
 T[] get()
          The actual result array, possibly truncated.
 long getChangeTime()
          Get the time stamp of when this result last changed state.
 java.lang.Exception getException()
          If an exception was thrown, returns that Exception.
 ITruncatable.Reason getTruncationReason()
          If the result was truncated, returns a ITruncatable.Reason for the truncation.
 boolean isDone()
          Returns true if this task completed.
 boolean isDone(java.lang.Object notificationToken)
          Checks if the result is available.
 boolean isTruncated()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KnownTruncatable

public KnownTruncatable(T[] result)
Create a new KnownTruncatable, not truncated.

Parameters:
result - the result array, never null

KnownTruncatable

public KnownTruncatable(T[] result,
                        ITruncatable.Reason reason)
Create a new KnownTruncatable, possibly truncated.

Parameters:
result - the result array, never null
reason - reason for truncating the result, or null if not truncated

KnownTruncatable

public KnownTruncatable(T[] result,
                        java.lang.Exception exception)
Create a new KnownTruncatable, possibly truncated.

Parameters:
result - the result array, never null
exception - reason for truncating the result, or null if not truncated
Method Detail

getChangeTime

public long getChangeTime()
Description copied from interface: IResult
Get the time stamp of when this result last changed state. In other words: If IResult.isDone() is false, returns the time when the request was sent. If IResult.isDone() is true, returns the time when the response was received.

Specified by:
getChangeTime in interface IResult<T[]>
Returns:
a time stamp (in milliseconds since 1970-01-01)

isDone

public boolean isDone()
Description copied from interface: IResult
Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Specified by:
isDone in interface IResult<T[]>
Returns:
true if this task completed.

isDone

public boolean isDone(java.lang.Object notificationToken)
Description copied from interface: IResult
Checks if the result is available. If so, simply returns true. Otherwise, notificationToken is added to the token set that will be given to notification listeners once the result is available. And false is returned.

Specified by:
isDone in interface IResult<T[]>
Returns:
true if this task completed.

get

public T[] get()
Description copied from interface: ITruncatable
The actual result array, possibly truncated. This method will never return null.

Specified by:
get in interface IResult<T[]>
Specified by:
get in interface ITruncatable<T>
Returns:
an array, possibly empty.

isTruncated

public boolean isTruncated()
Specified by:
isTruncated in interface ITruncatable<T>
Returns:
true iff this array was truncated

getTruncationReason

public ITruncatable.Reason getTruncationReason()
Description copied from interface: ITruncatable
If the result was truncated, returns a ITruncatable.Reason for the truncation. Otherwise, null is returned. Note that if ITruncatable.getException() returns non-null, this method will also return non-null, most probably ITruncatable.Reason.EXCEPTION.

Specified by:
getTruncationReason in interface ITruncatable<T>
Returns:
the reason for truncation, or null if the result wasn't truncated.

getException

public java.lang.Exception getException()
Description copied from interface: ITruncatable
If an exception was thrown, returns that Exception. Otherwise, null is returned.

Specified by:
getException in interface ITruncatable<T>
Returns:
the thrown exception, if any, null otherwise.


Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved.