cz.cuni.amis.pogamut.sposh.elements
Class Arguments

Package class diagram package Arguments
java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<Arguments.Argument>
          extended by cz.cuni.amis.pogamut.sposh.elements.Arguments
All Implemented Interfaces:
Iterable<Arguments.Argument>, Collection<Arguments.Argument>, List<Arguments.Argument>

public class Arguments
extends AbstractList<Arguments.Argument>

This class represents arguments passed to PrimitiveCall. PrimitiveCall can reference either normal IAction, ActionPattern or Competence that will get these arguments, mix them with their own FormalParameters and create the values for the Action/C/AP. Arguments is stored as list of Arguments.Argument, each argument is basically (key; argument) pair. Arguments are sorted according to the key. What is the key? Either a variable name of the argument in the list or arguments. Variable names have '$' prefix, e.g. $name. TODO: This probably doesn;t need to be abstract list Example: call run($dest="street", $speed=$number) will create Arguments with two arguments, value arg $dest and variable arg $speed.

Author:
Honza

Nested Class Summary
static class Arguments.Argument
          Representation of argument in Yaposh plan.
protected static class Arguments.ValueArgument
          This argument is a static value, neverchanging, e.g.
protected static class Arguments.VariableArgument
          This argument value is dependent on value of some variable.
 
Field Summary
static Arguments EMPTY
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
  Arguments()
          Create a new list of call parameters.
protected Arguments(Arguments parameters)
          Copy constructor.
 
Method Summary
 void add(int index, Arguments.Argument element)
          Add argument at specified index.
 boolean addFormal(Arguments.Argument newArgument, FormalParameters formalParams)
          Add argument to this list + following check: This list doesn't containe argument with same name as @newArgument.
 Arguments.Argument get(int index)
          Get indexth argument according to order of specification.
 String[] getAllNames()
          Get all names of arguments, sorted.
 int size()
           
 String toString()
          Get string representation of arguments (comma separated arguments, compatible with lap).
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

EMPTY

public static Arguments EMPTY
Constructor Detail

Arguments

public Arguments()
Create a new list of call parameters.

Every added variable parameter has to be checked against list of formal parameters.


Arguments

protected Arguments(Arguments parameters)
Copy constructor. Beware, this doesn't copy reference to the formal parameters.

Parameters:
parameters - orginal
Method Detail

getAllNames

public String[] getAllNames()
Get all names of arguments, sorted.

Returns:
Sorted names of all arguments.

get

public Arguments.Argument get(int index)
Get indexth argument according to order of specification.

Specified by:
get in interface List<Arguments.Argument>
Specified by:
get in class AbstractList<Arguments.Argument>
Parameters:
index - Index of argument.

size

public int size()
Specified by:
size in interface Collection<Arguments.Argument>
Specified by:
size in interface List<Arguments.Argument>
Specified by:
size in class AbstractCollection<Arguments.Argument>
Returns:
How many arguments does this list hold.

add

public void add(int index,
                Arguments.Argument element)
Add argument at specified index.

Specified by:
add in interface List<Arguments.Argument>
Overrides:
add in class AbstractList<Arguments.Argument>
Parameters:
index - Index at which to add argument
element - Argument to add

addFormal

public boolean addFormal(Arguments.Argument newArgument,
                         FormalParameters formalParams)
Add argument to this list + following check: This list doesn't containe argument with same name as @newArgument.

Parameters:
newArgument - Argument to add to this list.
formalParams - Parameters that are used for check if @newArgument is varaiblae arg.
Throws:
IllegalArgumentException - If the check fails

toString

public String toString()
Get string representation of arguments (comma separated arguments, compatible with lap).

Overrides:
toString in class AbstractCollection<Arguments.Argument>
Returns:
arguments separated with comma (e.g. |"Friends of peace.", $when=now, $who=just_first_player|)


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.