alice.logictuple
Class LogicTuple

java.lang.Object
  |
  +--alice.logictuple.LogicTuple
All Implemented Interfaces:
java.io.Serializable, Tuple, TupleTemplate

public class LogicTuple
extends java.lang.Object
implements Tuple, TupleTemplate, java.io.Serializable

Defines the communication language based on logic tuples, which stand both for tuple and tuple template For logic tuple, the matching is the classic prolog matching and the propagation corresponds to unification. A logic tuple is like a Prolog term, usually a Prolog structure characterized by a name and 0 or more argument (which in this case are objects of the class TupleArgument)

See Also:
TupleArgument, Tuple, TupleTemplate, Serialized Form

Constructor Summary
LogicTuple()
           
LogicTuple(java.lang.String name)
          Constructs the logic tuple providing the tuple name, without arguments
LogicTuple(java.lang.String name, TupleArgument t1)
          Constructs the logic tuple providing the tuple name and one argument
LogicTuple(java.lang.String name, TupleArgument[] list)
          Constructs the logic tuple providing the tuple name and argument list
LogicTuple(java.lang.String name, TupleArgument t1, TupleArgument t2)
          Constructs the logic tuple providing the tuple name and two arguments
LogicTuple(java.lang.String name, TupleArgument t1, TupleArgument t2, TupleArgument t3)
          Constructs the logic tuple providing the tuple name and three arguments
LogicTuple(java.lang.String name, TupleArgument t1, TupleArgument t2, TupleArgument t3, TupleArgument t4)
          Constructs the logic tuple providing the tuple name and four arguments
LogicTuple(java.lang.String name, TupleArgument t1, TupleArgument t2, TupleArgument t3, TupleArgument t4, TupleArgument t5)
          Constructs the logic tuple providing the tuple name and five arguments
LogicTuple(java.lang.String name, TupleArgument t1, TupleArgument t2, TupleArgument t3, TupleArgument t4, TupleArgument t5, TupleArgument t6)
          Constructs the logic tuple providing the tuple name and six arguments
LogicTuple(java.lang.String name, TupleArgument t1, TupleArgument t2, TupleArgument t3, TupleArgument t4, TupleArgument t5, TupleArgument t6, TupleArgument t7)
          Constructs the logic tuple providing the tuple name and seven arguments
LogicTuple(alice.tuprolog.Term t)
          Constructs the logic tuple from a tuprolog term
LogicTuple(TupleArgument t)
          Constructs the logic tuple from a tuple argument (it's the most free form of construction)
 
Method Summary
 TupleArgument getArg(int index)
          Gets a argument inside the logic tuple
 int getArity()
          Gets the number of argument of the logic tuple
 float getFloat(int index)
          Helper service to get directly a float argument inside the logic tuple
 int getInt(int index)
          Helper service to get directly an integer argument inside the logic tuple
 java.lang.String getName()
          Gets the name of the logic tuple
 java.lang.String getString(int index)
          Helper service to get directly a string argument inside the logic tuple
 boolean match(Tuple t)
          Specifies if a logic tuple (as a tuple template) matches with a specified tuple, typically an other logic tuple
static LogicTuple parse(java.lang.String st)
          Static service to get a Logic tuple from a textual representation
 boolean propagate(Tuple t)
          Tries to unify a logic tuple (as a tuple template) with a specified tuple, typically an other logic tuple
 java.lang.String toString()
          Gets the string representation of the logic tuple
 alice.tuprolog.Term toTerm()
          Gets the Term representation of the logic tuple
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LogicTuple

public LogicTuple(java.lang.String name,
                  TupleArgument[] list)
Constructs the logic tuple providing the tuple name and argument list
Parameters:
name - the name of the tuple (the functor)
list - the list of tuple argument

LogicTuple

public LogicTuple(java.lang.String name)
Constructs the logic tuple providing the tuple name, without arguments
Parameters:
name - the name of the tuple (the functor)

LogicTuple

public LogicTuple(java.lang.String name,
                  TupleArgument t1)
Constructs the logic tuple providing the tuple name and one argument
Parameters:
name - the name of the tuple (the functor)
t1 - the tuple argument

LogicTuple

public LogicTuple(java.lang.String name,
                  TupleArgument t1,
                  TupleArgument t2)
Constructs the logic tuple providing the tuple name and two arguments
Parameters:
name - the name of the tuple (the functor)
t1 - the first tuple argument
t2 - the second tuple argument

LogicTuple

public LogicTuple(java.lang.String name,
                  TupleArgument t1,
                  TupleArgument t2,
                  TupleArgument t3)
Constructs the logic tuple providing the tuple name and three arguments
Parameters:
name - the name of the tuple (the functor)
t1 - the first tuple argument
t2 - the second tuple argument
t3 - the third tuple argument

LogicTuple

public LogicTuple(java.lang.String name,
                  TupleArgument t1,
                  TupleArgument t2,
                  TupleArgument t3,
                  TupleArgument t4)
Constructs the logic tuple providing the tuple name and four arguments
Parameters:
name - the name of the tuple (the functor)
t1 - the first tuple argument
t2 - the second tuple argument
t3 - the third tuple argument
t4 - the fourth tuple argument

LogicTuple

public LogicTuple(java.lang.String name,
                  TupleArgument t1,
                  TupleArgument t2,
                  TupleArgument t3,
                  TupleArgument t4,
                  TupleArgument t5)
Constructs the logic tuple providing the tuple name and five arguments
Parameters:
name - the name of the tuple (the functor)
t1 - the first tuple argument
t2 - the second tuple argument
t3 - the third tuple argument
t4 - the fourth tuple argument
t5 - the fifth tuple argument

LogicTuple

public LogicTuple(java.lang.String name,
                  TupleArgument t1,
                  TupleArgument t2,
                  TupleArgument t3,
                  TupleArgument t4,
                  TupleArgument t5,
                  TupleArgument t6)
Constructs the logic tuple providing the tuple name and six arguments
Parameters:
name - the name of the tuple (the functor)
t1 - the first tuple argument
t2 - the second tuple argument
t3 - the third tuple argument
t4 - the fourth tuple argument
t5 - the fifth tuple argument
t6 - the sixth tuple argument

LogicTuple

public LogicTuple(java.lang.String name,
                  TupleArgument t1,
                  TupleArgument t2,
                  TupleArgument t3,
                  TupleArgument t4,
                  TupleArgument t5,
                  TupleArgument t6,
                  TupleArgument t7)
Constructs the logic tuple providing the tuple name and seven arguments
Parameters:
name - the name of the tuple (the functor)
t1 - the first tuple argument
t2 - the second tuple argument
t3 - the third tuple argument
t4 - the fourth tuple argument
t5 - the fifth tuple argument
t6 - the sixth tuple argument
t7 - the seventh tuple argument

LogicTuple

public LogicTuple(TupleArgument t)
Constructs the logic tuple from a tuple argument (it's the most free form of construction)
Parameters:
t - the tuple argument

LogicTuple

public LogicTuple(alice.tuprolog.Term t)
Constructs the logic tuple from a tuprolog term
Parameters:
t - the tuprolog term

LogicTuple

public LogicTuple()
Method Detail

getArity

public int getArity()
Gets the number of argument of the logic tuple
Returns:
the number of tuple arguments

getName

public java.lang.String getName()
Gets the name of the logic tuple
Returns:
the name of the logic tuple

getArg

public TupleArgument getArg(int index)
Gets a argument inside the logic tuple
Parameters:
index - the position (index) of the argument
Returns:
the tuple argument if it exists, null otherwise

getString

public java.lang.String getString(int index)
Helper service to get directly a string argument inside the logic tuple
Parameters:
index - the position (index) of the string argument
Returns:
the string value if it exists, null otherwise

getInt

public int getInt(int index)
Helper service to get directly an integer argument inside the logic tuple
Parameters:
index - the position (index) of the integer argument
Returns:
the integer value if it exists

getFloat

public float getFloat(int index)
Helper service to get directly a float argument inside the logic tuple
Parameters:
index - the position (index) of the float argument
Returns:
the float value if it exists

toTerm

public alice.tuprolog.Term toTerm()
Gets the Term representation of the logic tuple
Returns:
the logictuple as a term

toString

public java.lang.String toString()
Gets the string representation of the logic tuple
Overrides:
toString in class java.lang.Object
Returns:
the string representing the logic tuple

match

public boolean match(Tuple t)
Specifies if a logic tuple (as a tuple template) matches with a specified tuple, typically an other logic tuple
Specified by:
match in interface TupleTemplate
Parameters:
t - the matching tuple
Returns:
true if there is matching, false otherwise

propagate

public boolean propagate(Tuple t)
Tries to unify a logic tuple (as a tuple template) with a specified tuple, typically an other logic tuple
Specified by:
propagate in interface TupleTemplate
Parameters:
t - the matching tuple
Returns:
true if the propagation was successfull, false otherwise

parse

public static LogicTuple parse(java.lang.String st)
                        throws InvalidLogicTupleException
Static service to get a Logic tuple from a textual representation
Parameters:
st - the text representing the tuple
Returns:
the logic tuple interpreted from the text
Throws:
InvalidLogicTupleException - if the text does not represent a valid logic tuple