001: /*
002: * <copyright>
003: *
004: * Copyright 2000-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.tools.csmart.core.property;
028:
029: import org.cougaar.tools.csmart.core.property.name.CompositeName;
030:
031: import java.io.Serializable;
032: import java.util.Collection;
033:
034: /**
035: * Interface that defines all component, parent and child operations.
036: */
037: public interface ComposableComponent extends Serializable {
038:
039: /** Component Operations **/
040:
041: /**
042: * Iterates through all components returning all leaf components
043: * of the requested class.
044: *
045: * @param cls class of descendants to obtain
046: * @param c collection to add descendants to
047: * @return collection of all descendants
048: */
049: Collection getDescendentsOfClass(Class cls, Collection c);
050:
051: /**
052: * Iterates through all components returning all leaf components
053: * of the requested class.
054: *
055: * @param cls class of Descendants to obtain
056: * @return collection of all descendants
057: */
058: Collection getDescendentsOfClass(Class cls);
059:
060: /** Parent Operations **/
061:
062: /**
063: * Sets the parent of this component.
064: * If the parent name is changed, all property names need
065: * to be rehashed to reflect the new parent name.
066: *
067: * @param newParent New parent name.
068: */
069: void setParent(ComposableComponent newParent);
070:
071: /**
072: * Returns the parent of this component.
073: *
074: * @return parent of this component.
075: */
076: ComposableComponent getParent();
077:
078: /** Child Operations **/
079:
080: /**
081: * Add a child to this component.
082: * @param c the child to add
083: * @return child count.
084: */
085: int addChild(ComposableComponent c);
086:
087: /**
088: * Removes a child from this component.
089: * @param childIndex of child to remove.
090: */
091: void removeChild(int childIndex);
092:
093: /**
094: * Removes a child from this component.
095: * @param c Child to remove
096: */
097: void removeChild(ComposableComponent c);
098:
099: /**
100: * Removes all children from this component.
101: */
102: void removeAllChildren();
103:
104: /**
105: * Returns a child of this component.
106: * @param childIndex Index of the child within this component.
107: */
108: ComposableComponent getChild(int childIndex);
109:
110: /**
111: * Returns a child of this component.
112: * @param childName Name of child to retrieve
113: * @return Requested child or null of child not found
114: */
115: ComposableComponent getChild(CompositeName childName);
116:
117: /**
118: * Count of all children in this component.
119: * @return child count.
120: */
121: int getChildCount();
122: }
|