nars.entity
Class TermLink

java.lang.Object
  extended by nars.entity.BudgetValue
      extended by nars.entity.Item
          extended by nars.entity.TermLink
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
TaskLink

public class TermLink
extends Item

A link between a compound term and a component term

A TermLink links the current Term to a target Term, which is either a component of, or compound made from, the current term.

Neither of the two terms contain variable shared with other terms.

The index value(s) indicates the location of the component in the compound.

This class is mainly used in inference.RuleTable to dispatch premises to inference rules


Field Summary
static short COMPONENT
          At (&&, A, C), point to C
static short COMPONENT_CONDITION
          At <(&&, C, B) ==> A>, point to C
static short COMPONENT_STATEMENT
          At A>, point to C
static short COMPOUND
          At C, point to (&&, A, C)
static short COMPOUND_CONDITION
          At C, point to <(&&, C, B) ==> A>
static short COMPOUND_STATEMENT
          At C, point to A>
protected  short[] index
          The index of the component in the component list of the compound, may have up to 4 levels
static short SELF
          At C, point to C; TaskLink only
private  Term target
          The linked Term
static short TRANSFORM
          At C, point to <(*, C, B) --> A>; TaskLink only
protected  short type
          The type of link, one of the above
 
Fields inherited from class nars.entity.Item
key
 
Fields inherited from class nars.entity.BudgetValue
durability, priority, quality
 
Constructor Summary
  TermLink()
          Default constructor
protected TermLink(BudgetValue v)
          Default Constructor need in TaskLink
  TermLink(Term t, short p, int... indices)
          Constructor for TermLink template
  TermLink(Term t, TermLink template, BudgetValue v)
          Constructor to make actual TermLink from a template
 
Method Summary
 short getIndex(int i)
          Get one index by level
 short[] getIndices()
          Get all the indices
 Term getTarget()
          Get the target of the link
 short getType()
          Get the link type
protected  void setKey()
          Set the key of the link
 java.lang.String toString()
          Get a String representation of the link, with full accuracy
 java.lang.String toString2()
          Get a String representation of the link, with 2-digit accuracy
 
Methods inherited from class nars.entity.Item
getBudget, getKey
 
Methods inherited from class nars.entity.BudgetValue
aboveThreshold, clone, decDurability, decPriority, decQuality, getDurability, getPriority, getQuality, incDurability, incPriority, incQuality, merge, setDurability, setPriority, setQuality, summary
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SELF

public static final short SELF
At C, point to C; TaskLink only

See Also:
Constant Field Values

COMPONENT

public static final short COMPONENT
At (&&, A, C), point to C

See Also:
Constant Field Values

COMPOUND

public static final short COMPOUND
At C, point to (&&, A, C)

See Also:
Constant Field Values

COMPONENT_STATEMENT

public static final short COMPONENT_STATEMENT
At A>, point to C

See Also:
Constant Field Values

COMPOUND_STATEMENT

public static final short COMPOUND_STATEMENT
At C, point to A>

See Also:
Constant Field Values

COMPONENT_CONDITION

public static final short COMPONENT_CONDITION
At <(&&, C, B) ==> A>, point to C

See Also:
Constant Field Values

COMPOUND_CONDITION

public static final short COMPOUND_CONDITION
At C, point to <(&&, C, B) ==> A>

See Also:
Constant Field Values

TRANSFORM

public static final short TRANSFORM
At C, point to <(*, C, B) --> A>; TaskLink only

See Also:
Constant Field Values

target

private Term target
The linked Term


type

protected short type
The type of link, one of the above


index

protected short[] index
The index of the component in the component list of the compound, may have up to 4 levels

Constructor Detail

TermLink

public TermLink()
Default constructor


TermLink

public TermLink(Term t,
                short p,
                int... indices)
Constructor for TermLink template

called in CompoundTerm.prepareComponentLinks only

Parameters:
t - Target Term
p - Link type
indices - Component indices in compound, may be 1 to 4

TermLink

protected TermLink(BudgetValue v)
Default Constructor need in TaskLink

Parameters:
v - Budget value of the link

TermLink

public TermLink(Term t,
                TermLink template,
                BudgetValue v)
Constructor to make actual TermLink from a template

called in Concept.buildTermLinks only

Parameters:
t - Target Term
template - TermLink template previously prepared
v - Budget value of the link
Method Detail

setKey

protected void setKey()
Set the key of the link


getTarget

public Term getTarget()
Get the target of the link

Returns:
The Term pointed by the link

getType

public short getType()
Get the link type

Returns:
Type of the link

getIndices

public short[] getIndices()
Get all the indices

Returns:
The index array

getIndex

public short getIndex(int i)
Get one index by level

Parameters:
i - The index level
Returns:
The index value

toString

public java.lang.String toString()
Get a String representation of the link, with full accuracy

Overrides:
toString in class BudgetValue
Returns:
The String

toString2

public java.lang.String toString2()
Get a String representation of the link, with 2-digit accuracy

Overrides:
toString2 in class BudgetValue
Returns:
The String