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.cdata.ComponentData;
030: import org.cougaar.tools.csmart.core.db.PopulateDb;
031: import org.cougaar.tools.csmart.core.property.name.CompositeName;
032:
033: import java.io.Serializable;
034: import java.net.URL;
035: import java.util.Iterator;
036: import java.util.List;
037: import java.util.Map;
038:
039: /**
040: * The interface that every configurable component must implement.
041: * This interface handles all operations related to the
042: * <code>ComponentData</code> structures of a component and also
043: * all of the Properties within a component.
044: *
045: * The gui uses this interface to get and set properties.
046: */
047: public interface BaseComponent extends ComposableComponent,
048: Serializable {
049:
050: /**
051: * Gets the short name of this component. All component names
052: * are made up of a chain based on the component hierarchy.
053: * This chain is: grandparent.parent.child
054: * Short name is just 'child'.
055: *
056: * @return a <code>String</code> value of the short name.
057: */
058: String getShortName();
059:
060: /**
061: * Gets the full name of this component. All component names
062: * are made up of a chain based on the component hierarchy.
063: * This chain is: grandparent.parent.child
064: *
065: * Full name is the complete chain.
066: *
067: * @return a <code>CompositeName</code> value of the full component name.
068: */
069: CompositeName getFullName();
070:
071: /**
072: * Set the name of this component. The name is relative to the
073: * parent and must be distinct in that context.
074: * @param newName the new name for this component.
075: */
076:
077: void setName(String newName);
078:
079: /**
080: * Initialize the properties of a new instance. All components
081: * implementing this interface should delay the initialization of
082: * their properties until this method is called;
083: **/
084: void initProperties();
085:
086: /**
087: * Set a bunch of Properties at once. Used when creating a component
088: * from the database.
089: *
090: * @param props a <code>Map</code> of <code>String</code> property names and <code>Object</code> values
091: */
092: void setProperties(Map props);
093:
094: /**
095: * Get a <code>URL</code> for a description of the component. May return <code>null</code>.
096: *
097: * @return an <code>URL</code> describing this component.
098: */
099: URL getDescription();
100:
101: /**
102: * Gets a <code>Property</code> based on the
103: * property name specified as a <code>CompositeName</code>
104: *
105: * @param name of the Property
106: * @return <code>Property</code> object for the property.
107: */
108: Property getProperty(CompositeName name);
109:
110: /**
111: * Get a property using its local name
112: *
113: * @param localName of property
114: * @return <Property> object for the property.
115: */
116: Property getProperty(String localName);
117:
118: Property getInvisibleProperty(CompositeName name);
119:
120: Property getInvisibleProperty(String localName);
121:
122: /**
123: * Add a property with a given value. A new Property is created
124: * having the given name and value. In addition the other fields of
125: * the property set to default values consistent with the class of
126: * the value.
127: * @param name the name of the property
128: * @param value must be one of the supported value types
129: * @return a <code>Property</code> object for the new Property
130: **/
131: Property addProperty(String name, Object value);
132:
133: /**
134: * Returns a <code>Iterator</code> of all known property names for
135: * this component.
136: *
137: * @return <code>Iterator</code> of Property Names
138: */
139: Iterator getPropertyNames();
140:
141: Iterator getProperties();
142:
143: /**
144: * Returns a <code>Iterator</code> of all local property names for this component.
145: *
146: * @return <code>Iterator</code> of Local Property Names
147: */
148: Iterator getLocalPropertyNames();
149:
150: /**
151: * Returns a <code>List</code> of all property names.
152: *
153: * @return <code>List</code> of all property names
154: */
155: List getPropertyNamesList();
156:
157: /**
158: * Adds a <code>PropertiesListener</code> to this component.
159: *
160: * @param l The <code>PropertiesListener</code>
161: * @see PropertiesListener
162: */
163: void addPropertiesListener(PropertiesListener l);
164:
165: /**
166: * Removes a <code>PropertiesListener</code> to this component.
167: *
168: * @param l The <code>PropertiesListener</code>
169: */
170: void removePropertiesListener(PropertiesListener l);
171:
172: /**
173: * Adds a <code>ComponentData</code> to this component.
174: *
175: * @param data <code>ComponentData</code>
176: * @return the <code>ComponentData</code> that was just added.
177: * @see ComponentData
178: */
179: ComponentData addComponentData(ComponentData data);
180:
181: /**
182: * Modifies a <code>ComponentData</code>
183: *
184: * @param data a modified <code>ComponentData</code>
185: * @return the modified <code>ComponentData</code> object.
186: */
187: ComponentData modifyComponentData(ComponentData data);
188:
189: /**
190: * Describe <code>modifyComponentData</code> method here.
191: *
192: * @param data a modified <code>ComponentData</code>
193: * @param pdb
194: * @return the modified <code>ComponentData</code> object
195: */
196: ComponentData modifyComponentData(ComponentData data, PopulateDb pdb);
197:
198: boolean componentWasRemoved();
199:
200: /**
201: * Makes a copy of a <code>BaseComponent</code> Object.
202: *
203: * @param result object to copy
204: * @return a <code>ComponentProperties</code> copy
205: */
206: BaseComponent copy(BaseComponent result);
207:
208: /**
209: * Test if this has any unbound properties (properties for which
210: * isValueSet() return false)
211: *
212: * @return true if there are one or more unbound properties
213: */
214: boolean hasUnboundProperties();
215: }
|