xref: /AOO41X/main/toolkit/test/accessibility/VectorNode.java (revision 1b0aaa91df402a6f20c4769a008573eb958e886d)
1*1b0aaa91SAndrew Rist /**************************************************************
2*1b0aaa91SAndrew Rist  *
3*1b0aaa91SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1b0aaa91SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1b0aaa91SAndrew Rist  * distributed with this work for additional information
6*1b0aaa91SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1b0aaa91SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1b0aaa91SAndrew Rist  * "License"); you may not use this file except in compliance
9*1b0aaa91SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1b0aaa91SAndrew Rist  *
11*1b0aaa91SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1b0aaa91SAndrew Rist  *
13*1b0aaa91SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1b0aaa91SAndrew Rist  * software distributed under the License is distributed on an
15*1b0aaa91SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1b0aaa91SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1b0aaa91SAndrew Rist  * specific language governing permissions and limitations
18*1b0aaa91SAndrew Rist  * under the License.
19*1b0aaa91SAndrew Rist  *
20*1b0aaa91SAndrew Rist  *************************************************************/
21*1b0aaa91SAndrew Rist 
22cdf0e10cSrcweir import com.sun.star.lang.IndexOutOfBoundsException;
23cdf0e10cSrcweir import java.util.Vector;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir /** The VectorNode class is a simple container whose list of children is
26cdf0e10cSrcweir     managed entirely by its owner.
27cdf0e10cSrcweir */
28cdf0e10cSrcweir class VectorNode
29cdf0e10cSrcweir     extends StringNode
30cdf0e10cSrcweir {
31cdf0e10cSrcweir     private Vector maChildren;
32cdf0e10cSrcweir 
VectorNode(String sDisplayObject, AccessibleTreeNode aParent)33cdf0e10cSrcweir     public VectorNode (String sDisplayObject, AccessibleTreeNode aParent)
34cdf0e10cSrcweir     {
35cdf0e10cSrcweir         super (sDisplayObject, aParent);
36cdf0e10cSrcweir 
37cdf0e10cSrcweir         maChildren = new Vector ();
38cdf0e10cSrcweir     }
39cdf0e10cSrcweir 
addChild(AccessibleTreeNode aChild)40cdf0e10cSrcweir     public void addChild (AccessibleTreeNode aChild)
41cdf0e10cSrcweir     {
42cdf0e10cSrcweir         maChildren.add (aChild);
43cdf0e10cSrcweir     }
44cdf0e10cSrcweir 
getChildCount()45cdf0e10cSrcweir     public int getChildCount ()
46cdf0e10cSrcweir     {
47cdf0e10cSrcweir         return maChildren.size();
48cdf0e10cSrcweir     }
49cdf0e10cSrcweir 
getChild(int nIndex)50cdf0e10cSrcweir     public AccessibleTreeNode getChild (int nIndex)
51cdf0e10cSrcweir         throws IndexOutOfBoundsException
52cdf0e10cSrcweir     {
53cdf0e10cSrcweir         return (AccessibleTreeNode)maChildren.elementAt (nIndex);
54cdf0e10cSrcweir     }
55cdf0e10cSrcweir 
removeChild(int nIndex)56cdf0e10cSrcweir     public boolean removeChild (int nIndex)
57cdf0e10cSrcweir         throws IndexOutOfBoundsException
58cdf0e10cSrcweir     {
59cdf0e10cSrcweir         return maChildren.remove (nIndex) != null;
60cdf0e10cSrcweir     }
61cdf0e10cSrcweir 
indexOf(AccessibleTreeNode aNode)62cdf0e10cSrcweir     public int indexOf (AccessibleTreeNode aNode)
63cdf0e10cSrcweir     {
64cdf0e10cSrcweir         return maChildren.indexOf (aNode);
65cdf0e10cSrcweir     }
66cdf0e10cSrcweir 
isLeaf()67cdf0e10cSrcweir     public boolean isLeaf()
68cdf0e10cSrcweir     {
69cdf0e10cSrcweir         return maChildren.isEmpty();
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir }
72