com.ifcomputer.minerva
Class MinervaList

java.lang.Object
  |
  +--com.ifcomputer.minerva.MinervaTerm
        |
        +--com.ifcomputer.minerva.MinervaStruct
              |
              +--com.ifcomputer.minerva.MinervaList
All Implemented Interfaces:
java.io.Serializable

public class MinervaList
extends MinervaStruct
implements java.io.Serializable

The class MinervaList is used to represent a Minerva list term.


Field Summary
 
Fields inherited from class com.ifcomputer.minerva.MinervaTerm
ATOM, COMPOUND, DOUBLE, LIST, LONG, OBJECT, VARIABLE
 
Constructor Summary
MinervaList()
          Constructs a Minerva list with undefined head and tail (use 'new MinervaAtom("[]")' to construct an empty list).
MinervaList(com.ifcomputer.minerva.MinervaTerm head, com.ifcomputer.minerva.MinervaTerm tail)
          Constructs a Minerva list (use 'new MinervaAtom("[]")' to construct an empty list)
 
Method Summary
static com.ifcomputer.minerva.MinervaTerm create(com.ifcomputer.minerva.MinervaTerm[] args)
          Constructs a Minerva list, where the list arguments are extracted from the int array 'args'.
static com.ifcomputer.minerva.MinervaTerm create(com.ifcomputer.minerva.MinervaTerm[] args, int off, int len)
          Constructs a Minerva list, where the list arguments are extracted from the int array 'args'.
static com.ifcomputer.minerva.MinervaTerm create(java.lang.String[] args)
          Constructs a Minerva list, where the list arguments are atoms.
static com.ifcomputer.minerva.MinervaTerm create(java.lang.String[] args, int off, int len)
          Constructs a Minerva list, where the list arguments are atoms.
 boolean equals(java.lang.Object other)
          This function returns true, if 'other' is a list and the arguments of 'other' and 'this' are equal.
 com.ifcomputer.minerva.MinervaTerm getArg(int i)
          This function returns the i-th argument (0 <= i < 2) of a list, where argument 0 is the head of a list and argument 1 is the tail of the list
 int getArity()
          This function returns the arity of a list term (2)
 java.util.Enumeration getEnumeration()
          This functions returns an enumeration for the elements of a Minerva list.
 java.lang.String getFunctor()
          This function returns the functor of a list term (".")
 com.ifcomputer.minerva.MinervaTerm getHead()
          This function returns the head of the list.
 int getListLength()
          This function returns the length of a Minerva list.
 java.lang.String[] getStringArray()
          If this is a Minerva list, then the function returns a list of strings, representing each element of the list.
 com.ifcomputer.minerva.MinervaTerm getTail()
          This function returns the tail of the list.
 com.ifcomputer.minerva.MinervaTerm[] getTermArray()
          If this is a Minerva list, then the function returns a list of Minerva terms, containing all elements of the list.
 int hashCode()
          This function calculates a hashcode for a list term.
 boolean isList()
          This function returns true if this is a Minerva list or a Minerva atom with value [].
 void reset()
          This function is used to unbind all variables (MinervaVariable) in this term.
 com.ifcomputer.minerva.MinervaTerm resolve()
          This function is used to create a copy of this term, where all bound variable will be replaced by the term to which they are bound
 void setArg(int i, com.ifcomputer.minerva.MinervaTerm term)
          This function replaces the i-th argument of a compound term by 'term' (argument 0 is the head of the list; argument 1 is the tail of the list).
 void setHead(com.ifcomputer.minerva.MinervaTerm term)
          This function replaces the head of the list by 'term'.
 void setTail(com.ifcomputer.minerva.MinervaTerm term)
          This function replaces the head of the list by 'term'.
 java.lang.String toString()
          Stringifies a list term.
 int typeOf()
          This function returns the type (VARIABLE, ATOM, etc.) of this term.
 
Methods inherited from class com.ifcomputer.minerva.MinervaTerm
setValue
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MinervaList

public MinervaList(com.ifcomputer.minerva.MinervaTerm head,
                   com.ifcomputer.minerva.MinervaTerm tail)
Constructs a Minerva list (use 'new MinervaAtom("[]")' to construct an empty list)

Parameters:
head - the head of the list
tail - the tail of the list

MinervaList

public MinervaList()
Constructs a Minerva list with undefined head and tail (use 'new MinervaAtom("[]")' to construct an empty list). Use setArg(0, tm) to set the head of the list and setArg(1, tm) to set the tail of the list.

Method Detail

create

public static com.ifcomputer.minerva.MinervaTerm create(java.lang.String[] args)
Constructs a Minerva list, where the list arguments are atoms.

Parameters:
args - the arguments of the list

create

public static com.ifcomputer.minerva.MinervaTerm create(java.lang.String[] args,
                                                        int off,
                                                        int len)
Constructs a Minerva list, where the list arguments are atoms.

Parameters:
args - the arguments of the list
off - the offset of the first argument in args that should be used as list argument.
len - len-1 is the index of the last argument in args that should be used as list argument.

create

public static com.ifcomputer.minerva.MinervaTerm create(com.ifcomputer.minerva.MinervaTerm[] args)
Constructs a Minerva list, where the list arguments are extracted from the int array 'args'.

Parameters:
args - the arguments of the list

create

public static com.ifcomputer.minerva.MinervaTerm create(com.ifcomputer.minerva.MinervaTerm[] args,
                                                        int off,
                                                        int len)
Constructs a Minerva list, where the list arguments are extracted from the int array 'args'.

Parameters:
args - the arguments of the list
off - the offset of the first argument in args that should be used as list argument.
len - len-1 is the index of the last argument in args that should be used as list argument.

reset

public void reset()
Description copied from class: MinervaTerm
This function is used to unbind all variables (MinervaVariable) in this term.

Overrides:
reset in class MinervaTerm
Following copied from class: com.ifcomputer.minerva.MinervaTerm
See Also:
MinervaVariable.setValue(com.ifcomputer.minerva.MinervaTerm)

resolve

public com.ifcomputer.minerva.MinervaTerm resolve()
Description copied from class: MinervaTerm
This function is used to create a copy of this term, where all bound variable will be replaced by the term to which they are bound

Overrides:
resolve in class MinervaTerm
Following copied from class: com.ifcomputer.minerva.MinervaTerm
See Also:
MinervaVariable.setValue(com.ifcomputer.minerva.MinervaTerm), MinervaTerm.reset()

getFunctor

public java.lang.String getFunctor()
This function returns the functor of a list term (".")

Specified by:
getFunctor in class MinervaStruct

getArity

public int getArity()
This function returns the arity of a list term (2)

Specified by:
getArity in class MinervaStruct

getArg

public com.ifcomputer.minerva.MinervaTerm getArg(int i)
This function returns the i-th argument (0 <= i < 2) of a list, where argument 0 is the head of a list and argument 1 is the tail of the list

Specified by:
getArg in class MinervaStruct
Parameters:
i - argument index

setArg

public void setArg(int i,
                   com.ifcomputer.minerva.MinervaTerm term)
This function replaces the i-th argument of a compound term by 'term' (argument 0 is the head of the list; argument 1 is the tail of the list).

Specified by:
setArg in class MinervaStruct
Parameters:
i - argument index (0 <= index < 2)
term - term by which the selected argument has to be replaced

getHead

public com.ifcomputer.minerva.MinervaTerm getHead()
This function returns the head of the list.


getTail

public com.ifcomputer.minerva.MinervaTerm getTail()
This function returns the tail of the list.


setHead

public void setHead(com.ifcomputer.minerva.MinervaTerm term)
This function replaces the head of the list by 'term'.


setTail

public void setTail(com.ifcomputer.minerva.MinervaTerm term)
This function replaces the head of the list by 'term'.


equals

public boolean equals(java.lang.Object other)
This function returns true, if 'other' is a list and the arguments of 'other' and 'this' are equal.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
This function calculates a hashcode for a list term. The hashcode is valid as long as the arguments of the list term will not be changed.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Stringifies a list term. The format will be readable by the read-predicates of Minerva.

Overrides:
toString in class java.lang.Object

typeOf

public int typeOf()
Description copied from class: MinervaTerm
This function returns the type (VARIABLE, ATOM, etc.) of this term.

Specified by:
typeOf in class MinervaTerm
Following copied from class: com.ifcomputer.minerva.MinervaTerm
See Also:
MinervaTerm.VARIABLE, MinervaTerm.ATOM, MinervaTerm.LONG, MinervaTerm.DOUBLE, MinervaTerm.OBJECT, MinervaTerm.COMPOUND, MinervaTerm.LIST

isList

public boolean isList()
Description copied from class: MinervaTerm
This function returns true if this is a Minerva list or a Minerva atom with value [].

Overrides:
isList in class MinervaTerm

getEnumeration

public java.util.Enumeration getEnumeration()
                                     throws java.lang.IllegalArgumentException
Description copied from class: MinervaTerm
This functions returns an enumeration for the elements of a Minerva list. If this is not a Minerva list then the function throws an IllegalArgumentException.

Overrides:
getEnumeration in class MinervaTerm

getStringArray

public java.lang.String[] getStringArray()
                                  throws java.lang.IllegalArgumentException
Description copied from class: MinervaTerm
If this is a Minerva list, then the function returns a list of strings, representing each element of the list. If this is not a Minerva list, then the function throws an IllegalArgumentException.

Overrides:
getStringArray in class MinervaTerm

getTermArray

public com.ifcomputer.minerva.MinervaTerm[] getTermArray()
                                                  throws java.lang.IllegalArgumentException
Description copied from class: MinervaTerm
If this is a Minerva list, then the function returns a list of Minerva terms, containing all elements of the list. If this is not a Minerva list, then the function throws an IllegalArgumentException.

Overrides:
getTermArray in class MinervaTerm

getListLength

public int getListLength()
                  throws java.lang.IllegalArgumentException
Description copied from class: MinervaTerm
This function returns the length of a Minerva list. If this is not a valid Minerva list, the function throws an IllegalArgumentException.

Overrides:
getListLength in class MinervaTerm