Jalog 1.4


io.github.JalogTeam.jalog
Class Pro_TermData_List

java.lang.Object
  extended by io.github.JalogTeam.jalog.Pro_TermData
    extended by io.github.JalogTeam.jalog.Pro_TermData_List

public class Pro_TermData_List

Pro_Term objects containing Prolog list data store the data as Pro_TermData_List objects.

There is one special data item EMPTY for the empty list.

Field Summary
Pro_Term t1
           Head of the list
Pro_Term t2
           Tail of the list
static final Pro_TermData_List EMPTY
           Empty list data
String typename
           Type of the term
 
Constructor Summary
Pro_TermData_List(Pro_Term head, Pro_Term tail)
           Constructs a Pro_TermData_List object.
 
Method Summary
Pro_TermData copy(Hashtable variable_map)
           Returns an independent copy this of term using variable_map.
String image()
           Returns human readable string representation of this term.
static Pro_TermData_List make(Pro_Term[] iniVal, Pro_Term tail)
           Constructs list data from an array of Pro_Term objects.
String toString()
           Returns Jalog syntax representation of this term.
String[] toStringList()
           Returns human readable images of the members of the list as a String array.
 

Field Detail

t1

public Pro_Term t1
Head (i.e. the first element) of the list. Must not be null (except in the constant EMPTY).

t2

public Pro_Term t2
Tail (i.e. all but the first element) of the list. Points to Pro_Term.EMPTY_LIST if there are no more elements. Must not be null (except in the constant EMPTY).

EMPTY

public static final Pro_TermData_List EMPTY
Empty list data for Pro_Term.EMPTY_LIST.

typename

public String typename
The type of this term. This is set in the constructor to Jalog.LIST. Do not change!
Constructor Detail

Pro_TermData_List

public Pro_TermData_List(Pro_Term head, Pro_Term tail)
Constructs a Pro_TermData_List object. head becomes the first element of the new list. tail becomes the rest of the list. If the list contains only one element, head, Pro_Term.EMPTY_LIST is used as tail.

Both head and tail must be non-null.

Parameters:
head - the first element of the list.
tail - a list containing the rest of the list. head, Pro_Term.EMPTY_LIST if no more elements.

Method Detail

copy

public Pro_TermData copy(Hashtable variable_map)
Returns a copy this term data using variable_map. Hashtable is used to map repeated open terms to repeated open terms. Hashtable is updated for new open terms. Used in database asserting and fetching.

This method copies t1 (the head) and t2 (the tail) using the copy method of Pro_Term. The copy method of Pro_Term may return the original object. If this happens for both t1 and t2 the original Pro_TermData_List object then this is returned. Otherwise a new Pro_TermData_List object is created and returned.

Parameters:
variable_map - contains open variable mapping for this term.
Returns:
a copy this term data using variable_map.

image

public String image()
Returns human readable string representation of this term. Used by built-in predicate write.


make

public static Pro_TermData_List make(Pro_Term[] iniVal, Pro_Term tail)
Constructs list data from an array of Pro_Term objects. If the first element is an empty array, data of tail is returned. If tail is Pro_Term.EMPTY_LIST then the constructed list contains only the elements of iniVal. Otherwise tail is concatenated to the end of the constructed list.

iniVal and all elements of iniVal and also tail must be non-null.

Parameters:
iniVal - the first elements to the list.
tail - the last elements to the list.
Returns:
the constructed list.

toString

public String toString()
Returns Jalog syntax representation of this term.

Returns:
Jalog syntax representation of this term.

toStringList

public String[] toStringList()
Returns human readable images of the members of the list as a String array. The empty list results an empty array.

Returns:
Array of strings.

Authors: Mikko Levanto, Ari Okkonen