1 package net.sourceforge.phpdt.internal.compiler.parser;
3 import java.util.ArrayList;
7 * An abstract PHPSegment that can have children.
8 * @author khartlage, Matthieu Casanova
10 public abstract class PHPSegmentWithChildren extends PHPSegment {
11 private ArrayList children;
14 * Create a PHPSegment that can have children (class or functions).
15 * @param parent the parent object (it should be a php class)
16 * @param name the name of the function
17 * @param index where the function is in the file
19 public PHPSegmentWithChildren(Object parent, String name, int index) {
20 super(parent, name, index);
21 children = new ArrayList();
24 public List getList( ) {
29 * Appends the specified PHPSegment declaration
31 * @param o function declaration to be appended to this list.
32 * @return <tt>true</tt> (as per the general contract of Collection.add).
34 public boolean add(PHPSegment o) {
35 return children.add(o);
39 * Returns the PHPSegment declaration at the specified position in this list.
41 * @param index index of function declaration to return.
42 * @return the function declaration at the specified position in this list.
43 * @throws java.lang.IndexOutOfBoundsException if index is out of range <tt>(index
44 * < 0 || index >= size())</tt>.
46 public PHPSegment get(int index) {
47 return (PHPSegment) children.get(index);
51 * Returns the number of declarations in this list.
53 * @return the number of declarations in this list.
56 return children.size();