|
|||||||||
Home >> All >> alice >> [ tuprolog overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
alice.tuprolog
Class Struct

java.lang.Objectalice.tuprolog.Term
alice.tuprolog.Struct
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class Struct
- extends Term
Struct class represents both compound prolog term and alphanumeric atom term (considered as 0-arity compound).
Field Summary | |
Term[] |
arg
args array |
int |
arity
arity of the structure note: 0 -> string atom |
private java.lang.Object[] |
builtin_args
for optimization purposes |
(package private) int |
code
|
java.lang.String |
functor
pure name of the structure note: without arity indication |
(package private) int |
hash
to speedup hash map operation |
private java.lang.Object |
library
lib object where the builtins are defined |
private java.lang.reflect.Method |
method
method (of the lib object) representing the builtin behaviour |
Fields inherited from class alice.tuprolog.Term |
FALSE, FLOAT, id, INT, NULL, OBJECT, STRUCT, TRUE, VAR |
Constructor Summary | |
|
Struct()
empty list constructor |
private |
Struct(int a)
|
|
Struct(java.lang.String f)
atom |
private |
Struct(java.lang.String f,
int ar)
|
|
Struct(java.lang.String f,
alice.util.LinkedList al)
1-arity constructor - providing arg linked list |
|
Struct(java.lang.String f,
Term at0)
1-arity constructor |
|
Struct(java.lang.String f,
Term[] argList)
n-arity constructor - providing arg list |
|
Struct(java.lang.String f,
Term at0,
Term at1)
2-arity constructor |
|
Struct(java.lang.String f,
Term at0,
Term at1,
Term at2)
3-arity constructor |
|
Struct(java.lang.String f,
Term at0,
Term at1,
Term at2,
Term at3)
4-arity constructor |
|
Struct(java.lang.String f,
Term at0,
Term at1,
Term at2,
Term at3,
Term at4)
5-arity constructor |
|
Struct(java.lang.String f,
Term at0,
Term at1,
Term at2,
Term at3,
Term at4,
Term at5)
6-arity constructor |
|
Struct(java.lang.String f,
Term at0,
Term at1,
Term at2,
Term at3,
Term at4,
Term at5,
Term at6)
7-arity constructor |
|
Struct(Term h,
Term t)
constructor for list providing head and tail |
Method Summary | |
void |
append(Term t)
significant only for list compound: appends an element to the list compound |
void |
bindToBuiltinFunctor(java.lang.Object lib)
links this compound to builtin functor method execution of an object |
void |
bindToBuiltinPredicate(java.lang.Object lib)
links this compound to builtin predicate method execution of an object |
Term |
copy(alice.util.LinkedList vl)
gets a copy (with renamed variables) of the term. |
boolean |
equals(java.lang.Object t)
Determine whether this Object is semantically equal to another Object. |
Term |
evalAsBuiltinFunctor()
invokes the built-in functor linked to the compound |
boolean |
evalAsBuiltinPredicate()
invokes the built-in predicate linked to the compound |
void |
free(int m)
significant for Var terms. |
Struct |
fromList()
gets a flat Struct from a list compound |
java.lang.String |
getName()
significant only for Var and Struct derived class. |
java.lang.String |
getString(int index)
significant only for Struct derived class. |
Struct |
getStruct(int index)
gets the i-th arg as a Struct |
Struct |
getStruct(java.lang.String name)
gets the first arg which is a compound with functor specified |
Term |
getTerm()
gets the actual term of the object. |
Term |
getTerm(int index)
gets the i-th arg as a Term |
Term |
getVar(java.lang.String name)
gets the first arg which is a variable with functor specified |
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
void |
insert(Term t)
significant only for list compound: head insertion |
boolean |
isAny()
is it a prolog any(_) variable? |
boolean |
isAtom()
is it a prolog (alphanumeric) atom? |
boolean |
isBuiltinFunctor()
tests for bultin functor |
boolean |
isBuiltinPredicate()
tests for bultin predicate |
boolean |
isClause()
is it a prolog clause? |
boolean |
isCompound()
is it a prolog compound term? |
boolean |
isConst()
is it a constant prolog term? |
boolean |
isEmptyList()
is it a prolog empty list? |
boolean |
isEQU(Term t)
is term equal to term t? |
boolean |
isFalse()
is it a prolog false atom? |
boolean |
isGround()
is it a ground term? |
boolean |
isGT(Term t)
is term greater than term t? |
boolean |
isList()
is it a prolog list? |
boolean |
isNum()
is it a prolog numeric term? |
boolean |
isTrue()
is it a prolog true atom? |
java.util.Iterator |
iterator()
for list compound |
Term |
listHead()
significant only for list compound: gets the head |
Struct |
listTail()
significant only for list compound: gets the tail |
boolean |
match(Term t)
matching without unification; only true or false, without bindings. |
private void |
readObject(java.io.ObjectInputStream in)
|
(package private) int |
renameVars(alice.util.LinkedList vars,
int count)
|
int |
resolveVarTimes(alice.util.LinkedList vars,
int count)
|
java.lang.Object[] |
toArray()
gets an array from a list compound |
Struct |
toList()
gets a list Struct from a flat Struct |
java.lang.String |
toRawString()
as toString but without eventually present '' in functor string |
java.lang.String |
toString()
stringizing the Struct, with different representation for list, atom, compound |
private java.lang.String |
toString0()
|
(package private) java.lang.String |
toStringAsArg(OperatorManager op,
int prio,
boolean x)
stringize term as operator of priority prio. |
(package private) java.lang.String |
toStringAsList(OperatorManager op)
|
void |
unbind()
unlinks compound from builtin |
boolean |
unify(Term t,
int m)
tries to unify a term with the provided term argument. |
private void |
writeObject(java.io.ObjectOutputStream out)
serialization: in order to avoid the serialization of library and method fields nullify them |
Methods inherited from class alice.tuprolog.Term |
clone, getDouble, getFloat, getInt, getIterator, getLong, getObject, getObject, isFloat, isInt, isObject, isStruct, isVar, parse, parse, parseSentence, renameVars, toString, toStringAsArgX, toStringAsArgY |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
functor
public java.lang.String functor
- pure name of the structure
note: without arity indication
arity
public int arity
- arity of the structure
note: 0 -> string atom
arg
public Term[] arg
- args array
hash
int hash
- to speedup hash map operation
code
int code
method
private java.lang.reflect.Method method
- method (of the lib object) representing the builtin behaviour
library
private java.lang.Object library
- lib object where the builtins are defined
builtin_args
private java.lang.Object[] builtin_args
- for optimization purposes
Constructor Detail |
Struct
public Struct(java.lang.String f)
- atom
Struct
public Struct(java.lang.String f, Term at0)
- 1-arity constructor
Struct
public Struct(java.lang.String f, Term at0, Term at1)
- 2-arity constructor
Struct
public Struct(java.lang.String f, Term at0, Term at1, Term at2)
- 3-arity constructor
Struct
public Struct(java.lang.String f, Term at0, Term at1, Term at2, Term at3)
- 4-arity constructor
Struct
public Struct(java.lang.String f, Term at0, Term at1, Term at2, Term at3, Term at4)
- 5-arity constructor
Struct
public Struct(java.lang.String f, Term at0, Term at1, Term at2, Term at3, Term at4, Term at5)
- 6-arity constructor
Struct
public Struct(java.lang.String f, Term at0, Term at1, Term at2, Term at3, Term at4, Term at5, Term at6)
- 7-arity constructor
Struct
public Struct(java.lang.String f, Term[] argList)
- n-arity constructor - providing arg list
Struct
public Struct(java.lang.String f, alice.util.LinkedList al)
- 1-arity constructor - providing arg linked list
Struct
public Struct()
- empty list constructor
Struct
public Struct(Term h, Term t)
- constructor for list providing head and tail
Struct
private Struct(int a)
Struct
private Struct(java.lang.String f, int ar)
Method Detail |
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object
- Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)
is true, thena.hashCode() == b.hashCode()
must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCode
is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this)
- Semantic equality implies identical hashcodes. In other
words, if
equals
public boolean equals(java.lang.Object t)
- Description copied from class:
java.lang.Object
- Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this method which subclasses must follow:
- It must be transitive. If
a.equals(b)
andb.equals(c)
, thena.equals(c)
must be true as well. - It must be symmetric.
a.equals(b)
andb.equals(a)
must have the same value. - It must be reflexive.
a.equals(a)
must always be true. - It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
a.equals(null)
must be false.- It must be consistent with hashCode(). That is,
a.equals(b)
must implya.hashCode() == b.hashCode()
. The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.
This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for
a.equals(b)
to be true even thougha.getClass() != b.getClass()
. Also, it is typical to never cause a java.lang.NullPointerException.In general, the Collections API (
java.util
) use theequals
method rather than the==
operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.The default implementation returns
this == o
. - It must be transitive. If
toList
public Struct toList()
- gets a list Struct from a flat Struct
fromList
public Struct fromList()
- gets a flat Struct from a list compound
toArray
public java.lang.Object[] toArray()
- gets an array from a list compound
listHead
public Term listHead()
- significant only for list compound: gets the head
listTail
public Struct listTail()
- significant only for list compound: gets the tail
append
public void append(Term t)
- significant only for list compound:
appends an element to the list compound
insert
public void insert(Term t)
- significant only for list compound:
head insertion
getString
public java.lang.String getString(int index)
- Description copied from class:
Term
- significant only for Struct derived class.
getName
public java.lang.String getName()
- Description copied from class:
Term
- significant only for Var and Struct derived class.
getTerm
public Term getTerm(int index)
getStruct
public Struct getStruct(int index)
getStruct
public Struct getStruct(java.lang.String name)
getVar
public Term getVar(java.lang.String name)
getTerm
public Term getTerm()
- Description copied from class:
Term
- gets the actual term of the object.
if the Term is a bound variable, the method get the Term linked to the variable
isConst
public boolean isConst()
isNum
public boolean isNum()
isCompound
public boolean isCompound()
- Description copied from class:
Term
- is it a prolog compound term?
- Overrides:
isCompound
in classTerm
isAtom
public boolean isAtom()
- Description copied from class:
Term
- is it a prolog (alphanumeric) atom?
isClause
public boolean isClause()
isList
public boolean isList()
isEmptyList
public boolean isEmptyList()
- Description copied from class:
Term
- is it a prolog empty list?
- Overrides:
isEmptyList
in classTerm
isTrue
public boolean isTrue()
isFalse
public boolean isFalse()
isAny
public boolean isAny()
isGround
public boolean isGround()
unify
public boolean unify(Term t, int m)
- Description copied from class:
Term
- tries to unify a term with the provided term argument.
Try the unification among the term and the term specified The unification is qualified with the integer passed as argument m in order to make reverisble unification using free(int), passing a code >= of m
match
public boolean match(Term t)
- Description copied from class:
Term
- matching without unification; only true or false, without bindings.
free
public void free(int m)
copy
public Term copy(alice.util.LinkedList vl)
- Description copied from class:
Term
- gets a copy (with renamed variables) of the term.
the list argument passed contains the list of variables to be renamed (if empty list then no renaming)
renameVars
int renameVars(alice.util.LinkedList vars, int count)
- Overrides:
renameVars
in classTerm
resolveVarTimes
public int resolveVarTimes(alice.util.LinkedList vars, int count)
isGT
public boolean isGT(Term t)
isEQU
public boolean isEQU(Term t)
toString
public java.lang.String toString()
- stringizing the Struct, with different representation for list, atom, compound
toRawString
public java.lang.String toRawString()
- as toString but without eventually present '' in functor string
- Overrides:
toRawString
in classTerm
toString0
private java.lang.String toString0()
toStringAsList
java.lang.String toStringAsList(OperatorManager op)
toStringAsArg
java.lang.String toStringAsArg(OperatorManager op, int prio, boolean x)
- Description copied from class:
Term
- stringize term as operator of priority prio.
x true then X arg, if false then Y arg; actually for example +(a,*(b,c)) becomes 5+6*3
significant only for Struct Term
- Overrides:
toStringAsArg
in classTerm
evalAsBuiltinPredicate
public boolean evalAsBuiltinPredicate()
- invokes the built-in predicate linked to the compound
evalAsBuiltinFunctor
public Term evalAsBuiltinFunctor()
- invokes the built-in functor linked to the compound
bindToBuiltinPredicate
public void bindToBuiltinPredicate(java.lang.Object lib) throws java.lang.NoSuchMethodException
- links this compound to builtin predicate method
execution of an object
bindToBuiltinFunctor
public void bindToBuiltinFunctor(java.lang.Object lib) throws java.lang.NoSuchMethodException
- links this compound to builtin functor method
execution of an object
unbind
public void unbind()
- unlinks compound from builtin
isBuiltinPredicate
public boolean isBuiltinPredicate()
- tests for bultin predicate
isBuiltinFunctor
public boolean isBuiltinFunctor()
- tests for bultin functor
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
- serialization: in order to avoid the serialization
of library and method fields nullify them
readObject
private void readObject(java.io.ObjectInputStream in) throws java.lang.Exception
iterator
public java.util.Iterator iterator()
- for list compound
|
|||||||||
Home >> All >> alice >> [ tuprolog overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |