kmy.jint.lang
Class ArgList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--kmy.jint.lang.ArgList

public final class ArgList
extends java.util.Vector

An ArgList object represets variable-length parameter list. When the last formal parameter in method is declared as ArgList, Jint compiler allows any number (including 0) of actual parameters of any type to match it. These parameters are wrapped if needed (so int becomes Integer) and combined into single ArgList object that is passed as a value for the last parameter. If the static type of last actual parameter is ArgList, though, and it is the only one that corresponds to ArgList formal parameter it will be passed "as is".

EXAMPLE:

  void foo( String form // regular parameter
            ArgList a // extra parameters
           )
  {
    int nExtra = a.length();
    Object arg1 = a.get(0); // first extra parameter
    Object arg1 = a.get(1); // second extra parameter
  }
  
Note: the first expression is valid only in Jint, the second one has the same meaning in Java and Jint.
  foo( "bar" ) is equivalent to foo( "bar", new ArgList() )
  foo( "bar", 1 ) is equivalent to foo( "bar", new ArgList( new Integer(1) ) )
  foo( "bar", 2.0, "a" ) is equivalent to foo( "bar", new ArgList( new Double(2.0), "a" ) )
  

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData, serialVersionUID
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ArgList()
          Creates empty ArgList.
ArgList(int n)
          Creates empty ArgList optimized to store given number of elements.
ArgList(java.lang.Object arg1)
          Creates ArgList that contains only one value.
ArgList(java.lang.Object[] argList)
          Creates ArgList from the array of values.
ArgList(java.lang.Object[] argList, int offset)
          Creates ArgList from the array of values, starting with value argList[offset].
ArgList(java.lang.Object arg1, java.lang.Object arg2)
          Creates ArgList that contains two values.
ArgList(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Creates ArgList that contains three values.
ArgList(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          Creates ArgList that contains four values.
 
Method Summary
 java.lang.Object get(int i)
          Returns object in the arglist by its index.
 java.lang.Object[] getList()
          Returns the list of objects in the arglist.
 int length()
          Returns the number of objects in the arglist
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, ensureCapacityHelper, equals, firstElement, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

ArgList

public ArgList(java.lang.Object[] argList)
Creates ArgList from the array of values.

ArgList

public ArgList(java.lang.Object[] argList,
               int offset)
Creates ArgList from the array of values, starting with value argList[offset].

ArgList

public ArgList()
Creates empty ArgList.

ArgList

public ArgList(int n)
Creates empty ArgList optimized to store given number of elements.

ArgList

public ArgList(java.lang.Object arg1)
Creates ArgList that contains only one value.

ArgList

public ArgList(java.lang.Object arg1,
               java.lang.Object arg2)
Creates ArgList that contains two values.

ArgList

public ArgList(java.lang.Object arg1,
               java.lang.Object arg2,
               java.lang.Object arg3)
Creates ArgList that contains three values.

ArgList

public ArgList(java.lang.Object arg1,
               java.lang.Object arg2,
               java.lang.Object arg3,
               java.lang.Object arg4)
Creates ArgList that contains four values. Use ArgList(Object[]) to create ArgList with more then four values.
Method Detail

getList

public java.lang.Object[] getList()
Returns the list of objects in the arglist.

length

public int length()
Returns the number of objects in the arglist

get

public java.lang.Object get(int i)
Returns object in the arglist by its index. The first object has index 0.
Overrides:
get in class java.util.Vector