001: /*
002: * <copyright>
003: *
004: * Copyright 2001-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: package org.cougaar.tools.csmart.core.cdata;
027:
028: import java.io.Serializable;
029:
030: /**
031: * Represents a Relationship for an asset.
032: * All relationships contain three values:
033: * <ul>
034: * <li> Type: This is the type of relationship </li>
035: * <li> Item: This is Agent we are forming a relationship with </li>
036: * <li> Role: This is a role performed by this asset. </li>
037: * </ul>
038: *
039: * There are two type of ini file formats: <br>
040: * "Supporting" "1BDE" "StrategicTransportProvider" <br>
041: * Where the fields are: <br>
042: * <Type> <Supported Agent> <Role>
043: * <br>and<br>
044: * "StrategicTransportProvider" "UIC/1BDE" "UTC/RTOrg" "1BDE" "" "" <br>
045: * Where the fields are: <br>
046: * <Type> <ItemId> <TypeId> <Supported Agent> <Start Time> <Stop Time>
047: *
048: */
049: public class RelationshipData implements Serializable {
050:
051: private String type = "";
052: private String role = "";
053: private String itemId = "";
054: private String typeId = "";
055: private long startTime = 0L;
056: private long endTime = 0L;
057: private String supported = "";
058:
059: /** Types of relationships **/
060: // (not really important if everything else is correct)
061: public static final String SUPERIOR = "Superior";
062: public static final String SUPPORTING = "Supporting";
063:
064: /**
065: * Creates a new <code>RelationshipData</code> instance.
066: *
067: */
068: public RelationshipData() {
069: }
070:
071: /**
072: * Sets the type of relationship
073: *
074: * @param type of relationship
075: */
076: public void setType(String type) {
077: if (type == null)
078: throw new IllegalArgumentException(
079: "Attempt to set Type to null for RelationshipData: "
080: + this );
081:
082: this .type = type;
083: }
084:
085: /**
086: * Gets the type of relationship.
087: *
088: * @return relationship type.
089: */
090: public String getType() {
091: return this .type;
092: }
093:
094: /**
095: * Sets the ItemId of a relationship, this
096: * is usually the agent name we are forming
097: * a relationship with.
098: *
099: * @param itemId name
100: */
101: public void setItemId(String itemId) {
102: this .itemId = itemId;
103: }
104:
105: /**
106: * Gets the ItemId for this relationship
107: *
108: * @return an itemId name
109: */
110: public String getItemId() {
111: return this .itemId;
112: }
113:
114: public void setTypeId(String typeId) {
115: this .typeId = typeId;
116: }
117:
118: public String getTypeId() {
119: return this .typeId;
120: }
121:
122: /**
123: * Sets a single role for this relationship
124: *
125: * @param role performed by this asset.
126: */
127: public void setRole(String role) {
128: this .role = role;
129: }
130:
131: /**
132: * Gets a single role performed by this asset.
133: *
134: * @return role
135: */
136: public String getRole() {
137: return this .role;
138: }
139:
140: /**
141: * Sets the start time for the time-phased object
142: *
143: * @param start
144: */
145: public void setStartTime(long start) {
146: this .startTime = start;
147: }
148:
149: /**
150: * Sets the End time for the time-phased object.
151: *
152: * @param end
153: */
154: public void setEndTime(long end) {
155: this .endTime = end;
156: }
157:
158: /**
159: * Gets the Start Time for the time
160: * phased object
161: *
162: * @return start time.
163: */
164: public long getStartTime() {
165: return startTime;
166: }
167:
168: /**
169: * Gets the End time for the time
170: * phased object.
171: *
172: * @return end time
173: */
174: public long getEndTime() {
175: return endTime;
176: }
177:
178: /**
179: * Sets the agent supported by this relationship
180: *
181: * @param supported agent
182: */
183: public void setSupported(String supported) {
184: this .supported = supported;
185: }
186:
187: /**
188: * Gets the agent supported by this relationship
189: *
190: * @return agent
191: */
192: public String getSupported() {
193: return this .supported;
194: }
195:
196: /**
197: * For debugging, get contents of relationship data.
198: * @return String fields in relationship data
199: */
200: public String toString() {
201: StringBuffer sb = new StringBuffer(300);
202: sb.append("Type: " + type);
203: sb.append(" Role: " + role);
204: sb.append(" ItemId: " + itemId);
205: sb.append(" TypeId: " + typeId);
206: sb.append(" Start Time: " + startTime);
207: sb.append(" End Time: " + endTime);
208: sb.append(" Supported: " + supported);
209: return sb.toString();
210: }
211: }
|