summaryrefslogtreecommitdiff
path: root/src/main/java/io/devnulllabs/openjava/ptree/CaseGroupList.java
blob: 8efb2cff8b040c38bc118d12c11a4f74405c1966 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * CaseGroupList.java 1.0
 *
 * @see io.devnulllabs.openjava.ptree.ParseTree
 * @version last updated: 06/11/97
 * @author  Michiaki Tatsubori
 */
package io.devnulllabs.openjava.ptree;

import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor;

/**
 * The CaseGroupList class presents for the node of parse tree
 * of CaseGroup
 *
 */
public class CaseGroupList extends List {
    private static final String LNLN = ParseTreeObject.LN + ParseTreeObject.LN;

    public CaseGroupList() {
        super(LNLN);
    }

    public CaseGroupList(CaseGroup e0) {
        super(LNLN, (ParseTree) e0);
    }

    /**
     * Gets the specified element at the index.
     *
     * @param  n  index
     */
    public CaseGroup get(int n) {
        return (CaseGroup) contents_elementAt(n);
    }

    /**
     * Adds the specified element after the list
     * This causes side-effect.
     *
     * @param  p  CaseGroup to be inserted into the list
     */
    public void add(CaseGroup p) {
        contents_addElement(p);
    }

    /**
     * Adds the specified element after the list
     * This causes side-effect.
     *
     * @param  p  CaseGroup to be inserted into the list
     */
    public void set(int index, CaseGroup p) {
        contents_setElementAt(p, index);
    }

    /**
     * Removes the element at the specified position in this Vector.
     * shifts any subsequent elements to the left (subtracts one from their
     * indices).  Returns the element that was removed from the Vector.
     *
     * @exception ArrayIndexOutOfBoundsException index out of range (index
     *            < 0 || index >= size()).
     * @param index the index of the element to removed.
     * @since JDK1.2
     */
    public CaseGroup remove(int index) {
        CaseGroup removed = (CaseGroup) contents_elementAt(index);
        contents_removeElementAt(index);
        return removed;
    }

    /**
     * Inserts the specified element into the list
     * before the specified element of the list.
     * This causes side-effect.
     *
     * @param  p  the element to be inserted into the list
     * @param  n  number of the element before which insertion ocuurs
     */
    public void insertElementAt(CaseGroup p, int n) {
        contents_insertElementAt(p, n);
    }

    /**
     * Appends a list after this list.
     *
     * @param  lst  a list to be appended
     */
    public void addAll(CaseGroupList lst) {
        for (int i = 0, len = lst.size(); i < len; i++) {
            contents_addElement(lst.get(i));
        }
    }

    /**
     * Returns a view of the portion of this List between fromIndex,
     * inclusive, and toIndex, exclusive.  The returned List is backed by this
     * List, but changes in the returned List are not reflected in this List.
     * <p>
     *
     * @param fromIndex low endpoint (inclusive) of the subList.
     * @param toKey high endpoint (exclusive) of the subList.
     * @return a view of the specified range within this List.
     * @exception IndexOutOfBoundsException Illegal endpoint index value
     *     (fromIndex &lt; 0 || toIndex &gt; size || fromIndex &gt; toIndex).
     */
    public CaseGroupList subList(int from_index, int to_index) {
        CaseGroupList result = new CaseGroupList();
        for (int i = from_index; i < to_index; ++i) {
            result.add(this.get(i));
        }
        return result;
    }

    public void accept(ParseTreeVisitor v) throws ParseTreeException {
        v.visit(this);
    }
}