orc.runtime
Class Args

java.lang.Object
  extended by orc.runtime.Args
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<java.lang.Object>

public class Args
extends java.lang.Object
implements java.io.Serializable, java.lang.Iterable<java.lang.Object>

Container for arguments to a site.

Author:
dkitchin
See Also:
Serialized Form

Nested Class Summary
static interface Args.NumericBinaryOperator<T>
          A binary operator on numbers
static interface Args.NumericUnaryOperator<T>
          A unary operator on numbers
 
Constructor Summary
Args(java.util.List<java.lang.Object> values)
           
Args(java.lang.Object[] values)
           
 
Method Summary
static
<T> T
applyNumericOperator(java.lang.Number a, Args.NumericUnaryOperator<T> op)
          Dispatch a unary operator based on the type of a number.
static
<T> T
applyNumericOperator(java.lang.Number a, java.lang.Number b, Args.NumericBinaryOperator<T> op)
          Dispatch a binary operator based on the widest type of two numbers.
 java.lang.Object[] asArray()
          Return the entire tuple as an object array.
 boolean boolArg(int n)
          Helper function for booleans
 java.lang.Object condense()
           
 java.lang.String fieldName()
           
 java.lang.Object getArg(int n)
          Helper function to retrieve the nth element as an object (starting from 0), with error checking
 int intArg(int n)
          Helper function for integers
 java.util.Iterator<java.lang.Object> iterator()
           
 ListLike listLikeArg(int n)
           
 long longArg(int n)
          Helper function for longs
 java.lang.Number numberArg(int n)
           
 int size()
           
 java.lang.String stringArg(int n)
          Helper function for strings.
 Value valArg(int n)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Args

public Args(java.util.List<java.lang.Object> values)

Args

public Args(java.lang.Object[] values)
Method Detail

size

public int size()

condense

public java.lang.Object condense()

valArg

@Deprecated
public Value valArg(int n)
             throws TokenException
Deprecated. 

Helper function to retrieve the nth value (starting from 0), with error checking.

Throws:
TokenException

fieldName

public java.lang.String fieldName()
                           throws TokenException
Throws:
TokenException

getArg

public java.lang.Object getArg(int n)
                        throws TokenException
Helper function to retrieve the nth element as an object (starting from 0), with error checking

Throws:
TokenException

asArray

public java.lang.Object[] asArray()
Return the entire tuple as an object array. Please don't mutate the array.


intArg

public int intArg(int n)
           throws TokenException
Helper function for integers

Throws:
TokenException

longArg

public long longArg(int n)
             throws TokenException
Helper function for longs

Throws:
TokenException

numberArg

public java.lang.Number numberArg(int n)
                           throws TokenException
Throws:
TokenException

boolArg

public boolean boolArg(int n)
                throws TokenException
Helper function for booleans

Throws:
TokenException

stringArg

public java.lang.String stringArg(int n)
                           throws TokenException
Helper function for strings. Note that this requires a strict String type. If you don't care whether the argument is really a string, use valArg(n).toString().

Throws:
TokenException

listLikeArg

public ListLike listLikeArg(int n)
                     throws TokenException
Throws:
TokenException

applyNumericOperator

public static <T> T applyNumericOperator(java.lang.Number a,
                                         java.lang.Number b,
                                         Args.NumericBinaryOperator<T> op)
                              throws TokenException
Dispatch a binary operator based on the widest type of two numbers.

Throws:
TokenException

applyNumericOperator

public static <T> T applyNumericOperator(java.lang.Number a,
                                         Args.NumericUnaryOperator<T> op)
Dispatch a unary operator based on the type of a number.


iterator

public java.util.Iterator<java.lang.Object> iterator()
Specified by:
iterator in interface java.lang.Iterable<java.lang.Object>