xtc.tree
Class Annotation

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.tree.Annotation
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable
Direct Known Subclasses:
Formatting

public abstract class Annotation
extends Node

The superclass of all annotations. An annotation adds information (such as comments) to an abstract syntax tree node; it is usually ignored while processing the AST.

Version:
$Revision: 1.17 $
Author:
Robert Grimm

Constructor Summary
Annotation()
          Create a new, empty annotation.
Annotation(Node node)
          Create a new annotation for the specified node.
 
Method Summary
 Node getNode()
          Get the annotated node.
 java.lang.String getTokenText()
          Treat this node as a token and get its text.
 Annotation innerMost()
          Return the inner-most annotation.
 boolean isAnnotation()
          Determine whether this node is an annotation.
 void setNode(Node node)
          Set the annotated node.
 Node strip()
          Strip any annotations.
 Annotation toAnnotation()
          Get this node as an annotation.
 
Methods inherited from class xtc.tree.Node
add, add, addAll, addAll, addAll, addAll, addAllTo, addNode, contains, get, getBoolean, getBooleanProperty, getGeneric, getList, getLocation, getName, getNode, getProperty, getString, getStringProperty, hasLocation, hasName, hasProperty, hasTraversal, hasVariable, indexOf, isEmpty, isGeneric, isList, isToken, iterator, lastIndexOf, properties, remove, removeProperty, set, setLocation, setLocation, setProperty, size, toList, toString, toToken, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Annotation

public Annotation()
Create a new, empty annotation.


Annotation

public Annotation(Node node)
Create a new annotation for the specified node.

Parameters:
node - The node.
Method Detail

getTokenText

public java.lang.String getTokenText()
Description copied from class: Node
Treat this node as a token and get its text. This method strips away any annotations, treats the resulting node as a token, and returns its text. User-specified classes must not override this method.

Overrides:
getTokenText in class Node
Returns:
The token's text.
See Also:
Node.strip()

isAnnotation

public boolean isAnnotation()
Description copied from class: Node
Determine whether this node is an annotation. User-specified classes must not override this method.

Overrides:
isAnnotation in class Node
Returns:
true if this node is an annotation.
See Also:
Annotation

toAnnotation

public Annotation toAnnotation()
Description copied from class: Node
Get this node as an annotation. User-specified classes must not override this method.

Overrides:
toAnnotation in class Node
Returns:
This node as an annotation.

getNode

public Node getNode()
Get the annotated node.

Returns:
The annotated node.

setNode

public void setNode(Node node)
Set the annotated node.

Parameters:
node - The new node.

strip

public Node strip()
Description copied from class: Node
Strip any annotations. This method removes any annotations starting with this node. The default implementation returns this node.

Overrides:
strip in class Node
Returns:
The node without annotations.
See Also:
Annotation

innerMost

public Annotation innerMost()
Return the inner-most annotation. This method strips all nested annotations, starting with this annotation, until it reaches the inner-most annotation.

Returns:
The inner-most annotation.


Copyright © 2012. All Rights Reserved.