|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectua.gradsoft.termware.Term
ua.gradsoft.termware.jj.NodeTerm
public class NodeTerm
Term which can be instance of JJTree node. If you want to use this term, you must define own SimpleNode interface as extension of NodeTerm and delegate all work in jjt* methods in SimpleNode to appropriative jjt*Internal methods of NodeTerm.
| Constructor Summary | |
|---|---|
NodeTerm(INode node)
create NodeTerm based on existing node. |
|
NodeTerm(int id,
String name)
create NodeTerm with given id and name |
|
NodeTerm(Term t)
credte NodeTerm from normal term. |
|
| Method Summary | |
|---|---|
boolean |
boundEquals(Term x)
equality, when propositional variables are already bounded. |
boolean |
boundUnify(Term t,
Substitution s)
unification when we already have s
and when same propositional variables means same things |
PartialOrderingResult |
concreteOrder(Term x,
Substitution s)
compare for 'more concrete' relation. |
Term |
createSame(Term[] newBody)
create term, with same name but new body. |
boolean |
emptyFv()
true, if term does not contains free propositional variables. |
int |
findSubtermIndexBoundEqualsTo(Term x)
|
boolean |
freeEquals(Term x)
Equality when all propositional variables are equal |
boolean |
freeUnify(Term t,
Substitution s)
do unification of this and t
and store in s substitution. |
int |
getArity()
get arity (i. |
Term |
getAttribute(String attribute)
get attribute with name name . |
Map<String,Term> |
getAttributes()
return map, where keys are attribute names, value - values of attributes. |
BigDecimal |
getBigDecimal()
get BigDecimal value, if this term represent BigDecimal, otherwise throw UnsupportedOperationException |
BigInteger |
getBigInteger()
get BigDecimal value, if this term represent BigInteger, otherwise throw UnsupportedOperationException |
boolean |
getBoolean()
get boolean value, if this term represent boolean, otherwise throw UnsupportedOperationException |
byte |
getByte()
get byte value, if this term represent byte, otherwise throw UnsupportedOperationException |
char |
getChar()
get char value, if this term represent char, otherwise throw UnsupportedOperationException |
double |
getDouble()
get double value, if this term represent double, otherwise throw UnsupportedOperationException Note, that this method does not provide conversion of other numeric types to double. |
float |
getFloat()
get float value, if this term represent float, otherwise throw UnsupportedOperationException. |
int |
getInt()
get integer value, if this term represent integer, otherwise throw UnsupportedOperationException |
Object |
getJavaObject()
|
long |
getLong()
get long value, if this term represent long, otherwise throw UnsupportedOperationException Note, that this method does not provide conversion of other numeric types to long. |
String |
getName()
get name of functional symbol. |
Object |
getNameIndex()
get index of name in instance symbol table. |
Number |
getNumber()
get numeric value, if this term represent number, otherwise throw UnsupportedOperationException |
int |
getPrimaryType0()
return code of level-0 primary type |
short |
getShort()
get short value, if this term represent short, otherwise throw UnsupportedOperationException Note, that this method does not provide conversion of other numeric types to short. |
String |
getString()
get string value, if this term represent string, otherwise throw InvalidPrimitiveTypeException |
Term |
getSubtermAt(int i)
get subterm of current term. |
Term |
getTerm()
get term. |
int |
getXIndex()
if this variable is a propositional variable, return index of one. |
boolean |
isAtom()
is term is atom ? |
boolean |
isBigDecimal()
true, if this term is BigDecimal |
boolean |
isBigInteger()
true, if this term is BigInteger |
boolean |
isBoolean()
is term is booleam ? |
boolean |
isByte()
true, if this term is Byte |
boolean |
isChar()
is term is char ? |
boolean |
isComplexTerm()
true, if this term have subterms |
boolean |
isDouble()
is Term is double ? |
boolean |
isFloat()
is Term is float ? |
boolean |
isInt()
is term is Int ? |
boolean |
isJavaObject()
if this term is Java Object ? |
boolean |
isLong()
is Term is long ? |
boolean |
isNil()
is term is nil ? |
boolean |
isNumber()
is term is Number ? |
boolean |
isShort()
is Term is short ? |
boolean |
isString()
is Term is string ? |
boolean |
isX()
true if this term is propositional variable. |
void |
jjtAddChildInternal(INode n,
int i)
add child at given place. |
void |
jjtClose()
This method is called after all the child nodes have been added. |
INode |
jjtGetChildInternal(int i)
This method returns a child node. |
int |
jjtGetNumChildren()
Return the number of children the node has. |
INode |
jjtGetParentInternal()
|
void |
jjtInsertChildInternal(INode n,
int i)
Insert node at index i |
void |
jjtOpen()
This method is called after the node has been made the current node. |
void |
jjtSetChildInternal(INode n,
int i)
set child at given place, replcing existing. |
void |
jjtSetParentInternal(INode n)
This pair of methods are used to inform the node of its parent. |
int |
maxFv()
get maximum index of free propositional variable in term |
int |
minFv()
get minimal index of free propositional variable in term. |
void |
print(PrintWriter out)
print term on out |
void |
setAttribute(String attribute,
String value)
|
void |
setAttribute(String attribute,
Term value)
set attribute with name name and value value . |
void |
setSubtermAt(int i,
Term t)
set i-th subterm to t when i < arity then throw IndexOutOfBoundsException |
void |
shiftFv(int newMinFv)
renumerate propositional variables in such case, that minFv(shiftFv(t))==newMinFv |
Term |
subst(Substitution s)
receive new term, which is sibstution of current term and s |
boolean |
substInside(Substitution s)
apply substitution s to current term. |
Term |
termClone()
deep clone of term. |
int |
termCompare(Term x)
compare functions. |
| Methods inherited from class ua.gradsoft.termware.Term |
|---|
containsSubtermBoundEqualsTo, getAsBigDecimal, getAsBigInteger, getAsBoolean, getAsByte, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsJavaObject, getAsLong, getAsNumber, getAsShort, getAsString, getPatternName, getPatternNameIndex, getPrimaryType1, print, println, println |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NodeTerm(INode node)
public NodeTerm(Term t)
public NodeTerm(int id,
String name)
| Method Detail |
|---|
public void jjtAddChildInternal(INode n,
int i)
i
-- add NIL subterms as emty trees, otherwise -- replace existing subterm.
Implementator can delegate functionality of jjtAddChild of own node interface
in JJTree SimpleNode. add is bad name (this in not add in strice sence), but this is semantics of
JJTree node interface
jjtAddChildInternal in interface INode
public void jjtSetChildInternal(INode n,
int i)
public void jjtInsertChildInternal(INode n,
int i)
i
If arity of existing term is less than i -- add NIL
subterms as emty trees, otherwise -- insert n at index i, moving next elements
up at one index. (this is difference from jjtAddInternal).
Implementator can use this in JJTree actions for adding extra custom subterms from actions
to parse tree.
public void jjtClose()
INode
jjtClose in interface INodepublic INode jjtGetChildInternal(int i)
INode
jjtGetChildInternal in interface INodepublic int jjtGetNumChildren()
INode
jjtGetNumChildren in interface INodepublic INode jjtGetParentInternal()
jjtGetParentInternal in interface INodepublic void jjtOpen()
INode
jjtOpen in interface INodepublic void jjtSetParentInternal(INode n)
INode
jjtSetParentInternal in interface INode
public boolean boundEquals(Term x)
throws TermWareException
Term
boundEquals in class Termx - - term to compare.
TermWareException
public boolean boundUnify(Term t,
Substitution s)
throws TermWareException
Term s
and when same propositional variables means same things
boundUnify in class TermTermWareException
public Term createSame(Term[] newBody)
throws TermWareException
Term
createSame in class TermTermWareExceptionpublic boolean emptyFv()
Term
emptyFv in class Term
public int findSubtermIndexBoundEqualsTo(Term x)
throws TermWareException
findSubtermIndexBoundEqualsTo in class TermTermWareException
public boolean freeEquals(Term x)
throws TermWareException
Term
freeEquals in class Termx - - term to compare.
TermWareException
public boolean freeUnify(Term t,
Substitution s)
throws TermWareException
Term this and t
and store in s substitution.
freeUnify in class TermTermWareExceptionpublic int getArity()
Term
getArity in class Term
public BigDecimal getBigDecimal()
throws UnsupportedOperationException
Term
getBigDecimal in class TermUnsupportedOperationException - raised if this term does not represent BigDecimal value.
public BigInteger getBigInteger()
throws UnsupportedOperationException
Term
getBigInteger in class TermUnsupportedOperationException - raised if this term does not represent BigInteger value.public boolean getBoolean()
Term
getBoolean in class Termpublic byte getByte()
Term
getByte in class Termpublic char getChar()
Term
getChar in class Term
public double getDouble()
throws UnsupportedOperationException
Term
getDouble in class TermUnsupportedOperationException - raised if this term does not represent double value.
public float getFloat()
throws UnsupportedOperationException
Term
getFloat in class TermUnsupportedOperationException - raised if this term does not represent double value.
public int getInt()
throws UnsupportedOperationException
Term
getInt in class TermUnsupportedOperationExceptionpublic Object getJavaObject()
getJavaObject in class Term
public long getLong()
throws UnsupportedOperationException
Term
getLong in class TermUnsupportedOperationException - raised if this term does not represent double value.public String getName()
Term
getName in interface INodegetName in class Termpublic Object getNameIndex()
Term
getNameIndex in class Termpublic Number getNumber()
Term
getNumber in class Termpublic int getPrimaryType0()
Term
getPrimaryType0 in class TermPrimaryTypes
public short getShort()
throws UnsupportedOperationException
Term
getShort in class TermUnsupportedOperationException - raised if this term does not represent double value.public String getString()
Term
getString in class Termpublic Term getSubtermAt(int i)
Term
getSubtermAt in class Termi - - index of subterm, starting from 0
public Term getTerm()
Term
getTerm in class Termpublic int getXIndex()
Term
getXIndex in class Termpublic boolean isAtom()
Term
isAtom in class Termpublic boolean isBigDecimal()
Term
isBigDecimal in class Termpublic boolean isBigInteger()
Term
isBigInteger in class Termpublic boolean isBoolean()
Term
isBoolean in class Termpublic boolean isByte()
Term
isByte in class Termpublic boolean isChar()
Term
isChar in class Termpublic boolean isComplexTerm()
Term
isComplexTerm in class Termpublic boolean isDouble()
Term
isDouble in class Termpublic boolean isFloat()
Term
isFloat in class Termpublic boolean isInt()
Term
isInt in class Termpublic boolean isJavaObject()
Term
isJavaObject in class Termpublic boolean isLong()
Term
isLong in class Termpublic boolean isNil()
Term
isNil in class Termpublic boolean isNumber()
Term
isNumber in class Termpublic boolean isShort()
Term
isShort in class Termpublic boolean isString()
Term
isString in class Termpublic boolean isX()
Term
isX in class Term
public int maxFv()
throws TermWareException
Term
maxFv in class TermTermWareException
public int minFv()
throws TermWareException
Term
minFv in class TermTermWareExceptionpublic void print(PrintWriter out)
Term out
print in class Termout - - PrintWriter, where to print term.
public void setSubtermAt(int i,
Term t)
throws TermWareException
Term
setSubtermAt in class Termi - - index of subterm to set.t - - subterm to set.
TermWareException
public void shiftFv(int newMinFv)
throws TermWareException
Term minFv(shiftFv(t))==newMinFv
shiftFv in class TermTermWareException
public Term subst(Substitution s)
throws TermWareException
Term s
subst in class TermTermWareException
public boolean substInside(Substitution s)
throws TermWareException
Term s to current term.
substInside in class TermTermWareException
public Term termClone()
throws TermWareException
Term
termClone in class TermTermWareExceptionpublic int termCompare(Term x)
Term
termCompare in class Termx - - term to compare
public PartialOrderingResult concreteOrder(Term x,
Substitution s)
throws TermWareException
Term x.<(concrete)<(y) means, that for each substitution
of free variables sx exists substituion sy :
x[sx] = y[sy] . s store previously matched variables.
concreteOrder in class TermTermWareExceptionpublic Term getAttribute(String attribute)
Attributed name .
When such attribute does not exists -- return NIL.
getAttribute in interface Attributedpublic Map<String,Term> getAttributes()
Attributed
getAttributes in interface Attributed
public void setAttribute(String attribute,
Term value)
Attributed name and value value .
If value is NIL, then attribute is erased from set.
setAttribute in interface Attributed
public void setAttribute(String attribute,
String value)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||