001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.xml.xpath.impl;
043:
044: import java.util.ArrayList;
045: import java.util.Collection;
046: import java.util.Collections;
047: import java.util.List;
048:
049: import org.netbeans.modules.xml.xpath.XPathExpression;
050: import org.netbeans.modules.xml.xpath.XPathOperationOrFuntion;
051:
052: /**
053: *
054: * @author radval
055: *
056: */
057: public abstract class XPathOperatorOrFunctionImpl extends
058: XPathExpressionImpl implements XPathOperationOrFuntion {
059:
060: /** List of child expressions. */
061: protected List mChildren;
062:
063: /** Constructor. */
064: protected XPathOperatorOrFunctionImpl() {
065: mChildren = new ArrayList();
066: }
067:
068: /**
069: * Gets the list of child expressions.
070: * @return a collection of child expressions
071: */
072: public Collection getChildren() {
073: return Collections.unmodifiableCollection(mChildren);
074: }
075:
076: /**
077: * Gets the number of children expressions.
078: * @return the count of children expressions
079: */
080: public int getChildCount() {
081: return mChildren.size();
082: }
083:
084: /**
085: * Gets the child expression at the specified location.
086: * @param index the index of the child to get
087: * @return the child
088: * @throws IndexOutOfBoundsException if index is out of bounds
089: */
090: public XPathExpression getChild(int index)
091: throws IndexOutOfBoundsException {
092: return (XPathExpression) mChildren.get(index);
093: }
094:
095: /**
096: * Adds a child expression.
097: * @param child to be added
098: */
099: public void addChild(XPathExpression child) {
100: mChildren.add(child);
101: }
102:
103: /**
104: * Removes a child expression.
105: * @param child to be removed
106: * @return <code>true</code> if the child was found and removed
107: */
108: public boolean removeChild(XPathExpression child) {
109: return mChildren.remove(child);
110: }
111:
112: /**
113: * Removes all the child expressions.
114: */
115: public void clearChildren() {
116: mChildren.clear();
117: }
118:
119: }
|