com.vinculumtech.platform.async
Class Result

java.lang.Object
  extended bycom.vinculumtech.platform.async.Result

public class Result
extends java.lang.Object

The Result object is returned by the invoke method on the Future class.

Version:
$Id: //depot/carrierwave/src/shared/com/vinculumtech/platform/async/Result.java#5 $

Constructor Summary
protected Result(Future future)
           
 
Method Summary
 Future getFuture()
           
 java.lang.Object getResult()
          Returns the result value.
 java.lang.Object getResult(long wait)
          Returns the result value or a TimedOutException if the wait period expires.
 boolean getResultBoolean()
           
 double getResultDouble()
           
 float getResultFloat()
           
 int getResultInt()
           
 long getResultLong()
           
 java.lang.Object getResultSafe()
          Returns the result value.
 short getResultShort()
           
 java.lang.String getResultString()
           
 java.lang.Throwable getThrowable()
          Returns the exception thrown by the NullaryFunction, if any.
 boolean hasResult()
          Test if the result is available, or if there was an exception without blocking.
 boolean hasThrowable()
          Test if an exception was returned without blocking.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Result

protected Result(Future future)
Method Detail

getFuture

public Future getFuture()

getThrowable

public java.lang.Throwable getThrowable()
Returns the exception thrown by the NullaryFunction, if any. Does not block.

Returns:

hasThrowable

public boolean hasThrowable()
Test if an exception was returned without blocking.

Returns:

hasResult

public boolean hasResult()
Test if the result is available, or if there was an exception without blocking.

Returns:

getResultBoolean

public boolean getResultBoolean()
                         throws java.lang.Exception
Returns:
the return value as a boolean
Throws:
java.lang.Exception

getResultInt

public int getResultInt()
                 throws java.lang.Exception
Returns:
the return value as an int
Throws:
java.lang.Exception

getResultLong

public long getResultLong()
                   throws java.lang.Exception
Returns:
the return value as a long
Throws:
java.lang.Exception

getResultFloat

public float getResultFloat()
                     throws java.lang.Exception
Returns:
the return value as a float
Throws:
java.lang.Exception

getResultShort

public short getResultShort()
                     throws java.lang.Exception
Returns:
the return value as a short
Throws:
java.lang.Exception

getResultDouble

public double getResultDouble()
                       throws java.lang.Exception
Returns:
the return value as a double
Throws:
java.lang.Exception

getResultString

public java.lang.String getResultString()
                                 throws java.lang.Exception
Returns:
the return value as a String
Throws:
java.lang.Exception

getResult

public java.lang.Object getResult()
                           throws java.lang.Exception
Returns the result value. If an exception was thrown in the NullaryFunction it will be rethrown here. This method will also block until the result value or an exception was returned from the function.

Returns:
the return value
Throws:
java.lang.Exception

getResultSafe

public java.lang.Object getResultSafe()
Returns the result value. If an exception was thrown in the NullaryFunction it will be rethrown here as a NestedFunctionException unless the exception is a RuntimeException or Error. This method will also block until the result value or an exception was returned from the function.
The purpose behind this method is to allow functions to throw Runtime exceptions without interference. Any 'declared' exceptions will be wrapped. It is expected that functions that throw declared (expected) exceptions use the getResult method instead to simulate consitent behavior.

Returns:
the return value
Throws:
NestedFunctionException

getResult

public java.lang.Object getResult(long wait)
                           throws TimedOutException,
                                  java.lang.Exception
Returns the result value or a TimedOutException if the wait period expires. If an exception was thrown in the NullaryFunction it will be rethrown here. This method will also block until the result value or an exception was returned from the function.

Returns:
the return value
Throws:
TimedOutException - thrown if the wait period expires
java.lang.Exception


Copyright (C) 2002 Vinculum Technologies, Inc. All Rights Reserved.