|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.sri.oaa2.icl.IclTerm
The root of the IclTerm class heirarchy. Implements the composite pattern.
| Field Summary | |
protected java.util.ArrayList |
children
|
protected boolean |
readOnly
|
protected int |
type
|
| Fields inherited from interface com.sri.oaa2.icl.OaaPrologVocabTokenTypes |
BACKSLASH, BANG, COLON, COMMA, DBL_COLON, DBLQUOTE, DBLQUOTED, DIV, DOT, ENDPAREN_LITERAL, EOF, EQUAL, EXPONENT, FLOAT, GROUP, ICLDATAQ, ICLDATAQ_LITERAL, IDENT, INT, LBRACE, LBRACK, LIST, LPAREN, MINUS, NULL_TREE_LOOKAHEAD, NUM_FLOAT, NUM_INT, PIPE, PLUS, RBRACE, RBRACK, RPAREN, SEMI, SIGNED_EXPONENT, SPECIAL_CHAR_LITERAL, STAR, STR, STRING_LITERAL, STRUCT, TERM_LITERAL, TILDE, TURNSTILE, VAR, VARIABLE, WS |
| Constructor Summary | |
|
IclTerm()
Create an empty IclTerm. |
protected |
IclTerm(int i)
Create a new term of a specific type. |
| Method Summary | |
protected java.lang.Object |
accept(OaaPrologVisitor visitor,
java.lang.Object data)
Accept a visitor. |
abstract void |
add(IclTerm n)
Add a child to the end of the list of children. |
abstract void |
add(int index,
IclTerm n)
Add a child to this term at the given index |
abstract void |
addAll(IclTerm l)
Add all the children of the given term to this term. |
void |
checkWritable()
Check read only flag. |
protected java.lang.Object |
childrenAccept(OaaPrologVisitor visitor,
java.lang.Object data)
Have children accept the visitor. |
abstract void |
clearTerms()
Remove all children of this node. |
java.lang.Object |
clone()
Clone this node. |
protected void |
dump(java.lang.String prefix)
Override this method if you want to customize how the node dumps out its children. |
static IclTerm |
fromString(boolean failFast,
java.lang.String t)
Generate an IclTerm from a string, throwing a RuntimeException on any parsing exceptions. |
static IclTerm |
fromString(java.lang.String t)
Generate an IclTerm from a string. |
protected abstract IclTerm |
getChild(int i)
Get the child at the given Index. |
protected java.util.ArrayList |
getChildren()
Get the children of this node. |
abstract int |
getNumChildren()
Get the number of children of this node. |
abstract IclTerm |
getTerm(int i)
Get the term at the given index. |
int |
getType()
Get the token type for this node. |
void |
iclAddToList(IclTerm t)
Deprecated. use add |
void |
iclAddToList(IclTerm t,
boolean atEnd)
Deprecated. use add(IclTerm) or add(int, IclTerm) |
void |
iclAppend(IclTerm inList)
Deprecated. use add |
java.util.ArrayList |
iclArguments()
Deprecated. use toArrayList() |
java.util.ListIterator |
iclArgumentsIterator()
Deprecated. use listIterator() or iterator() |
IclTerm |
iclClone()
Deprecated. use clone() |
void |
iclDelete(IclTerm t)
Deprecated. use removeUnifying |
static IclTerm |
iclDerefTerm(IclTerm t1,
java.util.HashMap bindings)
Deprecated. use Unifier.getInstance().deref() |
float |
iclFloat()
Deprecated. use ToFloat.getInstance().from() or ((IclFloat)this).toFloat or ((IclFloat)this).toDouble |
java.lang.String |
iclFunctor()
Deprecated. use ToFunctor.getInstance().from() or ((IclStruct)this).getFunctor() |
int |
iclInt()
Deprecated. use ToInt.getInstance().from() or ((IclInt)this).toInt |
java.util.ListIterator |
iclListIterator()
Deprecated. use listIterator() or iterator() |
int |
iclListLen()
Deprecated. use size |
IclTerm |
iclNthTerm(int index)
Deprecated. use getTerm(index - 1) |
int |
iclNumTerms()
Deprecated. use size |
IclTerm |
iclRemoveElement(IclTerm t)
Deprecated. use removeUnifying |
void |
iclRemoveFromList(IclTerm t)
Deprecated. use removeUnifying |
void |
iclReplaceElement(IclTerm oldTerm,
IclTerm newTerm)
Deprecated. use replaceUnifying |
void |
iclReplaceNthTerm(int position,
IclTerm newTerm)
Deprecated. use replaceElement |
void |
iclRetractAll()
Deprecated. use clearTerms |
char |
iclStarter()
Deprecated. use ToStarter.getInstance().from() or ((IclGroup)this).getStarter |
java.lang.String |
iclStr()
Deprecated. use toIdentifyingString() |
static IclTerm |
iclUnify(IclTerm t1,
IclTerm t2)
Deprecated. use Unifier.getInstance().unify() |
static IclTerm |
iclUnify(IclTerm t1,
IclTerm t2,
boolean inDebug)
Deprecated. use Unifier.getInstance().unify() |
static IclTerm |
iclUnify(IclTerm t1,
IclTerm t2,
java.util.HashMap bindings)
Deprecated. use Unifier.getInstance().unify() |
abstract boolean |
isAtomic()
Check if this term is atomic--can never have children. |
abstract boolean |
isComposite()
Check if this term is composite--can have children. |
boolean |
isEmptyList()
Check if this term is the empty list. |
boolean |
isFloat()
Check if this term is a float. |
boolean |
isGroup()
Check if this term is a group. |
boolean |
isIclDataQ()
Check if this term is an IclDataQ. |
boolean |
isInt()
Check if this term is an int. |
boolean |
isList()
Check if this term is a list. |
boolean |
isOfType(int t)
Check if this term is of a certain type. |
boolean |
isReadOnly()
Get read only flag. |
boolean |
isStr()
Check if this term is an atom. |
boolean |
isStruct()
Check if this term is a struct. |
boolean |
isVar()
Check if this term is an variable. |
abstract java.util.Iterator |
iterator()
Get an iterator for the children of this term. |
abstract java.util.ListIterator |
listIterator()
Get an iterator for the children of this term. |
abstract void |
removeAllUnifying(IclTerm n)
Remove all terms from this term's children for which the given term unifies. |
abstract void |
removeElement(int i)
Remove the child at the given index. |
abstract IclTerm |
removeUnifying(IclTerm n)
Remove the first child found that unifies with the given one. |
abstract void |
replaceElement(int target,
IclTerm replacement)
Replace the term at the given index. |
abstract void |
replaceUnifying(IclTerm target,
IclTerm replacement)
Replace all terms that unify with target with replacement. |
void |
setReadOnly(boolean r)
Set read only flag. |
void |
setType(int ttype)
Set the token type for this node. |
abstract int |
size()
Get the number of children of this node. |
abstract java.util.ArrayList |
toArrayList()
Deprecated. Use iterator() or listIterator() methods. |
java.lang.String |
toIdentifyingString()
Get the identifying string. |
java.lang.String |
toString()
Convert this term into a string. |
java.lang.String |
toString(java.lang.String prefix)
Do the conversion with a prefix. |
java.util.Vector |
toVector()
Deprecated. use toArrayList() |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.ArrayList children
protected boolean readOnly
protected int type
| Constructor Detail |
public IclTerm()
protected IclTerm(int i)
| Method Detail |
public int getType()
public void setType(int ttype)
public final void setReadOnly(boolean r)
public final boolean isReadOnly()
public final void checkWritable()
java.lang.RuntimeException - if not writable.public abstract boolean isAtomic()
public abstract boolean isComposite()
public final boolean isOfType(int t)
public final boolean isStruct()
public final boolean isList()
public final boolean isGroup()
public final boolean isIclDataQ()
public final boolean isInt()
public final boolean isFloat()
public final boolean isVar()
public final boolean isStr()
public final boolean isEmptyList()
public abstract java.util.ArrayList toArrayList()
protected final java.util.ArrayList getChildren()
public java.lang.Object clone()
clone in class java.lang.Objectpublic abstract int getNumChildren()
public abstract void add(IclTerm n)
throws java.lang.UnsupportedOperationException
n - the term to add.
UnsupportOperationException - if term cannot have children
java.lang.UnsupportedOperationException
public abstract void add(int index,
IclTerm n)
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if term cannot have children
public abstract void addAll(IclTerm l)
throws java.lang.UnsupportedOperationException
l - the IclTerm containing the children to add.
java.lang.UnsupportedOperationException - if term cannot have children
public abstract void clearTerms()
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if term cannot have children
protected abstract IclTerm getChild(int i)
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if term cannot have children
public abstract IclTerm getTerm(int i)
throws java.lang.UnsupportedOperationException
i - index of term (first term has index 0, and last has
index (size() -1)
java.lang.IndexOutOfBoundsException - if i is out of bounds
java.lang.UnsupportedOperationExceptionpublic abstract int size()
protected java.lang.Object accept(OaaPrologVisitor visitor,
java.lang.Object data)
visitor - the visitordata - generic data for the visitor
for an alternative
protected final java.lang.Object childrenAccept(OaaPrologVisitor visitor,
java.lang.Object data)
visitor - the visitordata - generic data for the visitor
public final java.lang.String toString()
Unfortunately, this is very slow! If you happen to know a term is atomic, you might be better off casting to the specific type, and then grabbing the data from one of the public methods of that class.
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String prefix)
public java.lang.String toIdentifyingString()
protected final void dump(java.lang.String prefix)
public abstract void removeAllUnifying(IclTerm n)
throws java.lang.UnsupportedOperationException
n - the term against which children must unify to be removed
java.lang.UnsupportedOperationException - if term cannot have children
public abstract IclTerm removeUnifying(IclTerm n)
throws java.lang.UnsupportedOperationException
n - the term against which to unify
java.lang.UnsupportedOperationException - if term cannot have children
public abstract void removeElement(int i)
throws java.lang.UnsupportedOperationException
i - the index
java.lang.UnsupportedOperationException - if term cannot have children
public abstract void replaceUnifying(IclTerm target,
IclTerm replacement)
throws java.lang.UnsupportedOperationException
target - the target against which to unifyreplacement - the replacement
java.lang.UnsupportedOperationException - if term cannot have children
public abstract void replaceElement(int target,
IclTerm replacement)
throws java.lang.IndexOutOfBoundsException,
java.lang.UnsupportedOperationException
target - the index to replacereplacement - the replacement
java.lang.IndexOutOfBoundsException - if target is out of bounds
java.lang.UnsupportedOperationException
public static final IclTerm fromString(boolean failFast,
java.lang.String t)
failFast - if true, throw RuntimeException on error; if
false, just display errors to stderrt - the string from which to generate an IclTerm
java.lang.RuntimeException - if the string could not be parsed
public static final IclTerm fromString(java.lang.String t)
throws antlr_oaa.RecognitionException,
antlr_oaa.TokenStreamException
antlr_oaa.RecognitionException - if the string could not be parsed
antlr_oaa.TokenStreamException - if the string could not be tokenizedpublic abstract java.util.Iterator iterator()
isAtomic(),
isComposite()public abstract java.util.ListIterator listIterator()
isAtomic(),
isComposite()public final java.util.ListIterator iclListIterator()
public final java.util.ListIterator iclArgumentsIterator()
public final IclTerm iclClone()
public final void iclAddToList(IclTerm t,
boolean atEnd)
public final void iclAddToList(IclTerm t)
public final void iclDelete(IclTerm t)
public final IclTerm iclRemoveElement(IclTerm t)
public final void iclRemoveFromList(IclTerm t)
public final void iclReplaceElement(IclTerm oldTerm,
IclTerm newTerm)
public final void iclReplaceNthTerm(int position,
IclTerm newTerm)
public final void iclAppend(IclTerm inList)
public final void iclRetractAll()
public final int iclListLen()
public final int iclNumTerms()
public final IclTerm iclNthTerm(int index)
public static final IclTerm iclUnify(IclTerm t1,
IclTerm t2,
boolean inDebug)
public static final IclTerm iclUnify(IclTerm t1,
IclTerm t2)
public static final IclTerm iclUnify(IclTerm t1,
IclTerm t2,
java.util.HashMap bindings)
public static final IclTerm iclDerefTerm(IclTerm t1,
java.util.HashMap bindings)
public java.lang.String iclStr()
public java.util.Vector toVector()
public int iclInt()
public char iclStarter()
public float iclFloat()
public java.lang.String iclFunctor()
public java.util.ArrayList iclArguments()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||