com.sri.oaa2.icl
Class IclStruct

java.lang.Object
  |
  +--com.sri.oaa2.icl.IclTerm
        |
        +--com.sri.oaa2.icl.IclComposite
              |
              +--com.sri.oaa2.icl.IclStruct
All Implemented Interfaces:
java.lang.Cloneable, OaaPrologVocabTokenTypes, java.io.Serializable

public final class IclStruct
extends com.sri.oaa2.icl.IclComposite

Represents an IclTerm of the form a(b).

See Also:
Serialized Form

Field Summary
protected  java.lang.String functor
           
 
Fields inherited from class com.sri.oaa2.icl.IclTerm
children, readOnly, 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
IclStruct(java.lang.String inFunctor)
          Construct with functor, no children
IclStruct(java.lang.String inFunctor, IclTerm first)
          Functor + one term
IclStruct(java.lang.String inFunctor, IclTerm first, IclTerm second)
          etc
IclStruct(java.lang.String inFunctor, IclTerm first, IclTerm second, IclTerm third)
          etc
IclStruct(java.lang.String inFunctor, IclTerm first, IclTerm second, IclTerm third, IclTerm fourth)
          etc
IclStruct(java.lang.String inFunctor, IclTerm first, IclTerm second, IclTerm third, IclTerm fourth, IclTerm fifth)
          etc
IclStruct(java.lang.String inFunctor, IclTerm first, IclTerm second, IclTerm third, IclTerm fourth, IclTerm fifth, IclTerm sixth)
          etc
IclStruct(java.lang.String inFunctor, IclTerm first, IclTerm second, IclTerm third, IclTerm fourth, IclTerm fifth, IclTerm sixth, IclTerm seventh)
          etc
IclStruct(java.lang.String inFunctor, IclTerm first, IclTerm second, IclTerm third, IclTerm fourth, IclTerm fifth, IclTerm sixth, IclTerm seventh, IclTerm eighth)
          etc
IclStruct(java.lang.String inFunctor, java.util.List args)
          Construct with functor, and given children
IclStruct(java.lang.String inFunctor, java.util.Vector inVector)
          Deprecated.  
 
Method Summary
protected  java.lang.Object accept(OaaPrologVisitor visitor, java.lang.Object data)
          Accept the visitor.
 void add(IclTerm n)
          Add a child to the end of the list of children.
 void add(int index, IclTerm n)
          Add a child to this term at the given index
 void addAll(IclTerm l)
          Add all the children of the given term to this term.
 void clearTerms()
          Remove all children of this node.
 boolean equals(java.lang.Object o)
           
protected  IclTerm getChild(int i)
          Get the child at the given Index.
 java.lang.String getFunctor()
          Get the functor
 int getNumChildren()
          Get the number of children of this node.
 IclTerm getTerm(int i)
          Get the term at the given index.
 int hashCode()
           
 java.lang.String iclStr()
          Deprecated. use getFunctor
 boolean isAtomic()
          Check if this term is atomic--can never have children.
 boolean isComposite()
          Check if this term is composite--can have children.
 java.util.Iterator iterator()
          Get an iterator for the children of this term.
 java.util.ListIterator listIterator()
          Get an iterator for the children of this term.
 void removeAllUnifying(IclTerm n)
          Remove all terms from this term's children for which the given term unifies.
 void removeElement(int i)
          Remove the child at the given index.
 IclTerm removeUnifying(IclTerm n)
          Remove the first child found that unifies with the given one.
 void replaceElement(int target, IclTerm replacement)
          Replace the term at the given index.
 void replaceUnifying(IclTerm target, IclTerm replacement)
          Replace all terms that unify with target with replacement.
protected  void setFunctor(java.lang.String s)
          Set the functor from a String
 int size()
          Get the number of children of this node.
 java.util.ArrayList toArrayList()
          Get the children of this node as an ArrayList.
 java.lang.String toIdentifyingString()
          Returns the functor.
 
Methods inherited from class com.sri.oaa2.icl.IclTerm
checkWritable, childrenAccept, clone, dump, fromString, fromString, getChildren, getType, iclAddToList, iclAddToList, iclAppend, iclArguments, iclArgumentsIterator, iclClone, iclDelete, iclDerefTerm, iclFloat, iclFunctor, iclInt, iclListIterator, iclListLen, iclNthTerm, iclNumTerms, iclRemoveElement, iclRemoveFromList, iclReplaceElement, iclReplaceNthTerm, iclRetractAll, iclStarter, iclUnify, iclUnify, iclUnify, isEmptyList, isFloat, isGroup, isIclDataQ, isInt, isList, isOfType, isReadOnly, isStr, isStruct, isVar, setReadOnly, setType, toString, toString, toVector
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

functor

protected java.lang.String functor
Constructor Detail

IclStruct

public IclStruct(java.lang.String inFunctor)
Construct with functor, no children


IclStruct

public IclStruct(java.lang.String inFunctor,
                 java.util.List args)
Construct with functor, and given children


IclStruct

public IclStruct(java.lang.String inFunctor,
                 java.util.Vector inVector)
Deprecated.  

Class Constructor.

Parameters:
inFunctor - the functor for the struct
inVector - the args for the struct

IclStruct

public IclStruct(java.lang.String inFunctor,
                 IclTerm first)
Functor + one term


IclStruct

public IclStruct(java.lang.String inFunctor,
                 IclTerm first,
                 IclTerm second)
etc


IclStruct

public IclStruct(java.lang.String inFunctor,
                 IclTerm first,
                 IclTerm second,
                 IclTerm third)
etc


IclStruct

public IclStruct(java.lang.String inFunctor,
                 IclTerm first,
                 IclTerm second,
                 IclTerm third,
                 IclTerm fourth)
etc


IclStruct

public IclStruct(java.lang.String inFunctor,
                 IclTerm first,
                 IclTerm second,
                 IclTerm third,
                 IclTerm fourth,
                 IclTerm fifth)
etc


IclStruct

public IclStruct(java.lang.String inFunctor,
                 IclTerm first,
                 IclTerm second,
                 IclTerm third,
                 IclTerm fourth,
                 IclTerm fifth,
                 IclTerm sixth)
etc


IclStruct

public IclStruct(java.lang.String inFunctor,
                 IclTerm first,
                 IclTerm second,
                 IclTerm third,
                 IclTerm fourth,
                 IclTerm fifth,
                 IclTerm sixth,
                 IclTerm seventh)
etc


IclStruct

public IclStruct(java.lang.String inFunctor,
                 IclTerm first,
                 IclTerm second,
                 IclTerm third,
                 IclTerm fourth,
                 IclTerm fifth,
                 IclTerm sixth,
                 IclTerm seventh,
                 IclTerm eighth)
etc

Method Detail

setFunctor

protected void setFunctor(java.lang.String s)
Set the functor from a String


getFunctor

public java.lang.String getFunctor()
Get the functor


accept

protected java.lang.Object accept(OaaPrologVisitor visitor,
                                  java.lang.Object data)
Accept the visitor.

Overrides:
accept in class IclTerm
Parameters:
visitor - the visitor
data - generic data for the visitor
Returns:
Object: generic return value
See Also:
for an alternative

toIdentifyingString

public java.lang.String toIdentifyingString()
Returns the functor.

Overrides:
toIdentifyingString in class IclTerm

iclStr

public java.lang.String iclStr()
Deprecated. use getFunctor

Overrides:
iclStr in class IclTerm

isAtomic

public final boolean isAtomic()
Description copied from class: IclTerm
Check if this term is atomic--can never have children.

Specified by:
isAtomic in class IclTerm

isComposite

public final boolean isComposite()
Description copied from class: IclTerm
Check if this term is composite--can have children.

Specified by:
isComposite in class IclTerm

toArrayList

public final java.util.ArrayList toArrayList()
Description copied from class: IclTerm
Get the children of this node as an ArrayList. Returns a new, empty ArrayList for nodes without children. For IclTerms that cannot have children, this returns null. You should not alter this ArrayList.

Specified by:
toArrayList in class IclTerm
Returns:
ArrayList the list of children--altering this will alter the internal data structure used by the IclTerm! Don't do it! Use the listIterator() or iterator() methods.

getNumChildren

public final int getNumChildren()
Description copied from class: IclTerm
Get the number of children of this node.

Specified by:
getNumChildren in class IclTerm
Returns:
int: the number of children

add

public void add(IclTerm n)
         throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Add a child to the end of the list of children.

Specified by:
add in class IclTerm
Parameters:
n - the term to add.
java.lang.UnsupportedOperationException

add

public void add(int index,
                IclTerm n)
         throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Add a child to this term at the given index

Specified by:
add in class IclTerm
Throws:
java.lang.UnsupportedOperationException - if term cannot have children

addAll

public void addAll(IclTerm l)
            throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Add all the children of the given term to this term. The order in which they are added is the same order in which they are encountered using l.toArrayList().listIterator(). Uses the add(IclTerm) method to actually do the adding.

Specified by:
addAll in class IclTerm
Parameters:
l - the IclTerm containing the children to add.
Throws:
java.lang.UnsupportedOperationException - if term cannot have children

clearTerms

public final void clearTerms()
                      throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Remove all children of this node.

Specified by:
clearTerms in class IclTerm
Throws:
java.lang.UnsupportedOperationException - if term cannot have children

getChild

protected final IclTerm getChild(int i)
                          throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Get the child at the given Index. Assumes children exists.

Specified by:
getChild in class IclTerm
Returns:
IclTerm: the child at the index
Throws:
java.lang.UnsupportedOperationException - if term cannot have children

getTerm

public final IclTerm getTerm(int i)
                      throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Get the term at the given index. For a readonly term, returns a clone.

Specified by:
getTerm in class IclTerm
Parameters:
i - index of term (first term has index 0, and last has index (size() -1)
Returns:
IclTerm: the term, or null if no such child
java.lang.UnsupportedOperationException

size

public final int size()
Description copied from class: IclTerm
Get the number of children of this node.

Specified by:
size in class IclTerm
Returns:
int: the number of children

removeAllUnifying

public final void removeAllUnifying(IclTerm n)
                             throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Remove all terms from this term's children for which the given term unifies.

Specified by:
removeAllUnifying in class IclTerm
Parameters:
n - the term against which children must unify to be removed
Throws:
java.lang.UnsupportedOperationException - if term cannot have children

removeUnifying

public final IclTerm removeUnifying(IclTerm n)
                             throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Remove the first child found that unifies with the given one.

Specified by:
removeUnifying in class IclTerm
Parameters:
n - the term against which to unify
Returns:
IclTerm: the removed term, or null
Throws:
java.lang.UnsupportedOperationException - if term cannot have children

removeElement

public final void removeElement(int i)
                         throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Remove the child at the given index.

Specified by:
removeElement in class IclTerm
Parameters:
i - the index
Throws:
java.lang.UnsupportedOperationException - if term cannot have children

replaceUnifying

public final void replaceUnifying(IclTerm target,
                                  IclTerm replacement)
                           throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Replace all terms that unify with target with replacement. Note that we don't use copies of the replacement, but the replacement itself.

Specified by:
replaceUnifying in class IclTerm
Parameters:
target - the target against which to unify
replacement - the replacement
Throws:
java.lang.UnsupportedOperationException - if term cannot have children

replaceElement

public final void replaceElement(int target,
                                 IclTerm replacement)
                          throws java.lang.IndexOutOfBoundsException,
                                 java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Replace the term at the given index. If there is no child at the given index, nothing happens. Again, no copies of the replacement are used.

Specified by:
replaceElement in class IclTerm
Parameters:
target - the index to replace
replacement - the replacement
Throws:
java.lang.IndexOutOfBoundsException - if target is out of bounds
java.lang.UnsupportedOperationException

iterator

public final java.util.Iterator iterator()
                                  throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Get an iterator for the children of this term. If no iterator is possible for this type of term, returns an empty Iterator that cannot be modified. If there are no children, but children are possible, then return an empty Iterator. All optional methods of the Iterator interface are implemented if the term is composite.

Specified by:
iterator in class IclTerm
Returns:
Iterator an iterator over the children of this term
java.lang.UnsupportedOperationException
See Also:
IclTerm.isAtomic(), IclTerm.isComposite()

listIterator

public final java.util.ListIterator listIterator()
                                          throws java.lang.UnsupportedOperationException
Description copied from class: IclTerm
Get an iterator for the children of this term. If no iterator is possible for this type of term, returns an empty ListIterator that cannot be modified. If there are no children, but children are possible, then return an empty Iterator. All optional methods of the ListIterator interface are implemented if the term is composite.

Specified by:
listIterator in class IclTerm
Returns:
ListIterator, an iterator over the children of this term
java.lang.UnsupportedOperationException
See Also:
IclTerm.isAtomic(), IclTerm.isComposite()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object