Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jdt.core.dom
Class ASTNode.NodeList  view ASTNode.NodeList download ASTNode.NodeList.java

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byorg.eclipse.jdt.core.dom.ASTNode.NodeList
All Implemented Interfaces:
java.util.Collection, java.lang.Iterable, java.util.List
Enclosing class:
ASTNode

class ASTNode.NodeList
extends java.util.AbstractList

A specialized implementation of a list of ASTNodes. The implementation is based on an ArrayList.


Nested Class Summary
(package private)  class ASTNode.NodeList.Cursor
          A cursor for iterating over the elements of the list.
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
private  java.util.List cursors
          A list of currently active cursors (element type: Cursor), or null if there are no active cursors.
(package private)  ChildListPropertyDescriptor propertyDescriptor
          The property descriptor for this list.
(package private)  java.util.ArrayList store
          The underlying list in which the nodes of this list are stored (element type: ASTNode).
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
(package private) ASTNode.NodeList(ChildListPropertyDescriptor property)
          Creates a new empty list of nodes owned by this node.
 
Method Summary
 void add(int index, java.lang.Object element)
          Insert an element into the list at a given position (optional operation).
 java.lang.Object get(int index)
          Returns the elements at the specified position in the list.
(package private)  int listSize()
          Returns an estimate of the memory footprint in bytes of this node list and all its subtrees.
(package private)  int memSize()
          Returns an estimate of the memory footprint of this node list instance in bytes.
(package private)  ASTNode.NodeList.Cursor newCursor()
          Allocate a cursor to use for a visit.
(package private)  void releaseCursor(ASTNode.NodeList.Cursor cursor)
          Releases the given cursor at the end of a visit.
 java.lang.Object remove(int index)
          Remove the element at a given position in this list (optional operation).
 java.lang.Object set(int index, java.lang.Object element)
          Replace an element of this list with another object (optional operation).
 int size()
          Get the number of elements in this list.
private  void updateCursors(int index, int delta)
          Adjusts all cursors to accomodate an add/remove at the given index.
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

store

java.util.ArrayList store
The underlying list in which the nodes of this list are stored (element type: ASTNode).

Be stingy on storage - assume that list will be empty.

This field declared default visibility (rather than private) so that accesses from NodeList.Cursor do not require a synthetic accessor method.


propertyDescriptor

ChildListPropertyDescriptor propertyDescriptor
The property descriptor for this list.


cursors

private java.util.List cursors
A list of currently active cursors (element type: Cursor), or null if there are no active cursors.

It is important for storage considerations to maintain the null-means-empty invariant; otherwise, every NodeList instance will waste a lot of space. A cursor is needed only for the duration of a visit to the child nodes. Under normal circumstances, only a single cursor is needed; multiple cursors are only required if there are multiple visits going on at the same time.

Constructor Detail

ASTNode.NodeList

ASTNode.NodeList(ChildListPropertyDescriptor property)
Creates a new empty list of nodes owned by this node. This node will be the common parent of all nodes added to this list.

Since:
3.0
Method Detail

size

public int size()
Description copied from interface: java.util.List
Get the number of elements in this list. If the list contains more than Integer.MAX_VALUE elements, return Integer.MAX_VALUE.


get

public java.lang.Object get(int index)
Description copied from class: java.util.AbstractList
Returns the elements at the specified position in the list.


set

public java.lang.Object set(int index,
                            java.lang.Object element)
Description copied from class: java.util.AbstractList
Replace an element of this list with another object (optional operation). This implementation always throws an UnsupportedOperationException.


add

public void add(int index,
                java.lang.Object element)
Description copied from class: java.util.AbstractList
Insert an element into the list at a given position (optional operation). This shifts all existing elements from that position to the end one index to the right. This version of add has no return, since it is assumed to always succeed if there is no exception. This implementation always throws UnsupportedOperationException, and must be overridden to make a modifiable List. If you want fail-fast iterators, be sure to increment modCount when overriding this.


remove

public java.lang.Object remove(int index)
Description copied from class: java.util.AbstractList
Remove the element at a given position in this list (optional operation). Shifts all remaining elements to the left to fill the gap. This implementation always throws an UnsupportedOperationException. If you want fail-fast iterators, be sure to increment modCount when overriding this.


newCursor

ASTNode.NodeList.Cursor newCursor()
Allocate a cursor to use for a visit. The client must call releaseCursor when done.

This method is internally synchronized on this NodeList. It is thread-safe to create a cursor.


releaseCursor

void releaseCursor(ASTNode.NodeList.Cursor cursor)
Releases the given cursor at the end of a visit.

This method is internally synchronized on this NodeList. It is thread-safe to release a cursor.


updateCursors

private void updateCursors(int index,
                           int delta)
Adjusts all cursors to accomodate an add/remove at the given index.

This method is only used when the list is being modified. The AST is not thread-safe if any of the clients are modifying it.


memSize

int memSize()
Returns an estimate of the memory footprint of this node list instance in bytes.
  • 1 object header for the NodeList instance
  • 5 4-byte fields of the NodeList instance
  • 0 for cursors since null unless walk in progress
  • 1 object header for the ArrayList instance
  • 2 4-byte fields of the ArrayList instance
  • 1 object header for an Object[] instance
  • 4 bytes in array for each element


listSize

int listSize()
Returns an estimate of the memory footprint in bytes of this node list and all its subtrees.