KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xpath > impl > XPathOperatorOrFunctionImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.xpath.impl;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24 import java.util.Collections JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.netbeans.modules.xml.xpath.XPathExpression;
28 import org.netbeans.modules.xml.xpath.XPathOperationOrFuntion;
29
30
31 /**
32  *
33  * @author radval
34  *
35  */

36 public abstract class XPathOperatorOrFunctionImpl extends XPathExpressionImpl implements XPathOperationOrFuntion {
37
38     /** List of child expressions. */
39     protected List JavaDoc mChildren;
40     
41     
42     /** Constructor. */
43     protected XPathOperatorOrFunctionImpl() {
44         mChildren = new ArrayList JavaDoc();
45     }
46     
47     /**
48      * Gets the list of child expressions.
49      * @return a collection of child expressions
50      */

51     public Collection JavaDoc getChildren() {
52         return Collections.unmodifiableCollection(mChildren);
53     }
54     
55     
56     /**
57      * Gets the number of children expressions.
58      * @return the count of children expressions
59      */

60     public int getChildCount() {
61         return mChildren.size();
62     }
63     
64     
65     /**
66      * Gets the child expression at the specified location.
67      * @param index the index of the child to get
68      * @return the child
69      * @throws IndexOutOfBoundsException if index is out of bounds
70      */

71     public XPathExpression getChild(int index)
72         throws IndexOutOfBoundsException JavaDoc {
73         return (XPathExpression) mChildren.get(index);
74     }
75     
76     
77     /**
78      * Adds a child expression.
79      * @param child to be added
80      */

81     public void addChild(XPathExpression child) {
82         mChildren.add(child);
83     }
84     
85     
86     /**
87      * Removes a child expression.
88      * @param child to be removed
89      * @return <code>true</code> if the child was found and removed
90      */

91     public boolean removeChild(XPathExpression child) {
92         return mChildren.remove(child);
93     }
94     
95     
96     /**
97      * Removes all the child expressions.
98      */

99     public void clearChildren() {
100         mChildren.clear();
101     }
102
103 }
104
Popular Tags