public abstract class Declaration extends java.lang.Object implements java.lang.Cloneable, Traversable, Annotatable
TranslationUnit and CompoundStatement are the two
typical symbol table objects. It is highly recommended to use the high-level
interface methods of SymbolTable, not the low-level methods of
Traversable, for consistent management of symbol table features.| Modifier and Type | Method and Description |
|---|---|
void |
annotate(Annotation annotation)
Inserts the given annotation to this declaration.
|
void |
annotateAfter(Annotation annotation)
Inserts the given annotation after this declaration.
|
void |
annotateBefore(Annotation annotation)
Inserts the given annotation before this declaration.
|
Declaration |
clone()
Creates and returns a deep copy of this declaration.
|
boolean |
containsAnnotation(java.lang.Class<? extends Annotation> type,
java.lang.String key)
Checks if this declaration contains any annotation with the specified type
and the string key.
|
void |
detach()
Detaches this declaration from it's parent, if it has one.
|
boolean |
equals(java.lang.Object o)
Checks if the declaration is equal to the given object.
|
<T extends Annotation> |
getAnnotation(java.lang.Class<T> type,
java.lang.String key)
Returns the first occurrence of the annotation with the specified type
and the string key.
|
java.util.List<Annotation> |
getAnnotations()
Returns the list of annotations attached to this declaration.
|
<T extends Annotation> |
getAnnotations(java.lang.Class<T> type)
Returns the list of annotations with the specified type, attached to this
declaration.
|
java.util.List<Annotation> |
getAnnotations(int position)
Returns the list of annotations attached at the specified position of this
declaration.
|
java.util.List<Traversable> |
getChildren()
Provides access to the children of this object as a list.
|
abstract java.util.List<IDExpression> |
getDeclaredIDs()
Returns a list of name ID introduced by this declaration.
|
Traversable |
getParent()
Provides access to the parent of this object.
|
int |
hashCode()
Returns the hash code of the declaration.
|
void |
print(java.io.PrintWriter o)
Prints this declaration to the specified print writer.
|
void |
removeAnnotations()
Removes all annotations attached to this declaration.
|
void |
removeAnnotations(java.lang.Class<? extends Annotation> type)
Removes all annotations with the specified type.
|
void |
removeChild(Traversable child)
This operation is not allowed.
|
void |
setChild(int index,
Traversable t)
Sets the indexth child of this object to t.
|
void |
setParent(Traversable t)
Sets the parent of this object.
|
void |
setPrintMethod(java.lang.reflect.Method m)
Overrides the print method for this object only.
|
void |
setSemiColon(boolean needs_semi_colon)
Marks this declaration needs semi colon when printed.
|
java.lang.String |
toString()
Converts this declaration to a string by calling the default print method.
|
void |
verify()
Verifies three properties of this object:
(1) All children are not null, (2) the parent object has this
object as a child, (3) all children have this object as the parent.
|
public Declaration clone()
clone in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to be compared.o == this.public int hashCode()
hashCode in class java.lang.Objectpublic void detach()
public java.util.List<Traversable> getChildren()
TraversablegetChildren in interface Traversablepublic abstract java.util.List<IDExpression> getDeclaredIDs()
public Traversable getParent()
TraversablegetParent in interface Traversablepublic void print(java.io.PrintWriter o)
public java.lang.String toString()
toString in class java.lang.Objectpublic void removeChild(Traversable child)
removeChild in interface Traversablechild - a reference to a child object that must match with ==.java.lang.UnsupportedOperationException - always.public void setChild(int index,
Traversable t)
TraversablesetChild in interface Traversablepublic void setParent(Traversable t)
TraversablesetParent in interface Traversablepublic void setPrintMethod(java.lang.reflect.Method m)
m - The new print method.public void verify()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if any of the properties are not true.public void annotate(Annotation annotation)
annotate in interface Annotatableannotation - the annotation to be inserted.public void annotateAfter(Annotation annotation)
annotateAfter in interface Annotatableannotation - the annotation to be inserted.public void annotateBefore(Annotation annotation)
annotateBefore in interface Annotatableannotation - the annotation to be inserted.public java.util.List<Annotation> getAnnotations()
getAnnotations in interface Annotatablepublic <T extends Annotation> java.util.List<T> getAnnotations(java.lang.Class<T> type)
getAnnotations in interface Annotatabletype - the annotation type of intereset.public boolean containsAnnotation(java.lang.Class<? extends Annotation> type, java.lang.String key)
containsAnnotation in interface Annotatabletype - the annotation type of interest.key - the key to be searched for.public <T extends Annotation> T getAnnotation(java.lang.Class<T> type, java.lang.String key)
getAnnotation in interface Annotatabletype - the annotation type of interest.key - the key to be searched for.public java.util.List<Annotation> getAnnotations(int position)
getAnnotations in interface Annotatableposition - the annotation position to be searched.public void removeAnnotations()
removeAnnotations in interface Annotatablepublic void removeAnnotations(java.lang.Class<? extends Annotation> type)
removeAnnotations in interface Annotatabletype - the annotation type to be removed.public void setSemiColon(boolean needs_semi_colon)