xref: /AOO41X/main/toolkit/test/accessibility/VectorNode.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir import com.sun.star.lang.IndexOutOfBoundsException;
2*cdf0e10cSrcweir import java.util.Vector;
3*cdf0e10cSrcweir 
4*cdf0e10cSrcweir /** The VectorNode class is a simple container whose list of children is
5*cdf0e10cSrcweir     managed entirely by its owner.
6*cdf0e10cSrcweir */
7*cdf0e10cSrcweir class VectorNode
8*cdf0e10cSrcweir     extends StringNode
9*cdf0e10cSrcweir {
10*cdf0e10cSrcweir     private Vector maChildren;
11*cdf0e10cSrcweir 
12*cdf0e10cSrcweir     public VectorNode (String sDisplayObject, AccessibleTreeNode aParent)
13*cdf0e10cSrcweir     {
14*cdf0e10cSrcweir         super (sDisplayObject, aParent);
15*cdf0e10cSrcweir 
16*cdf0e10cSrcweir         maChildren = new Vector ();
17*cdf0e10cSrcweir     }
18*cdf0e10cSrcweir 
19*cdf0e10cSrcweir     public void addChild (AccessibleTreeNode aChild)
20*cdf0e10cSrcweir     {
21*cdf0e10cSrcweir         maChildren.add (aChild);
22*cdf0e10cSrcweir     }
23*cdf0e10cSrcweir 
24*cdf0e10cSrcweir     public int getChildCount ()
25*cdf0e10cSrcweir     {
26*cdf0e10cSrcweir         return maChildren.size();
27*cdf0e10cSrcweir     }
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir     public AccessibleTreeNode getChild (int nIndex)
30*cdf0e10cSrcweir         throws IndexOutOfBoundsException
31*cdf0e10cSrcweir     {
32*cdf0e10cSrcweir         return (AccessibleTreeNode)maChildren.elementAt (nIndex);
33*cdf0e10cSrcweir     }
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir     public boolean removeChild (int nIndex)
36*cdf0e10cSrcweir         throws IndexOutOfBoundsException
37*cdf0e10cSrcweir     {
38*cdf0e10cSrcweir         return maChildren.remove (nIndex) != null;
39*cdf0e10cSrcweir     }
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir     public int indexOf (AccessibleTreeNode aNode)
42*cdf0e10cSrcweir     {
43*cdf0e10cSrcweir         return maChildren.indexOf (aNode);
44*cdf0e10cSrcweir     }
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir     public boolean isLeaf()
47*cdf0e10cSrcweir     {
48*cdf0e10cSrcweir         return maChildren.isEmpty();
49*cdf0e10cSrcweir     }
50*cdf0e10cSrcweir }
51