001: /*
002: * <copyright>
003: *
004: * Copyright 1997-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: /* @generated Thu Sep 27 15:20:42 EDT 2007 from /u01/builds/cougaar/B12_4/B12_4/070927151721/src/planning/src/org/cougaar/planning/ldm/asset/properties.def - DO NOT HAND EDIT */
028: /** Implementation of CommunityPG.
029: * @see CommunityPG
030: * @see NewCommunityPG
031: **/package org.cougaar.planning.ldm.asset;
032:
033: import org.cougaar.planning.ldm.measure.*;
034: import org.cougaar.planning.ldm.asset.*;
035: import org.cougaar.planning.ldm.plan.*;
036: import org.cougaar.util.TimeSpan;
037: import java.util.*;
038:
039: import java.io.ObjectOutputStream;
040: import java.io.ObjectInputStream;
041: import java.io.IOException;
042: import java.beans.PropertyDescriptor;
043: import java.beans.IndexedPropertyDescriptor;
044:
045: public final class CommunityPGImpl extends java.beans.SimpleBeanInfo
046: implements NewCommunityPG, Cloneable {
047: public CommunityPGImpl() {
048: }
049:
050: //NewTimeSpan implementation
051: private long theStartTime = TimeSpan.MIN_VALUE;
052:
053: public long getStartTime() {
054: return theStartTime;
055: }
056:
057: private long theEndTime = TimeSpan.MAX_VALUE;
058:
059: public long getEndTime() {
060: return theEndTime;
061: }
062:
063: public void setTimeSpan(long startTime, long endTime) {
064: if ((startTime >= MIN_VALUE) && (endTime <= MAX_VALUE)
065: && (endTime >= startTime + EPSILON)) {
066: theStartTime = startTime;
067: theEndTime = endTime;
068: } else {
069: throw new IllegalArgumentException();
070: }
071: }
072:
073: public void setTimeSpan(TimeSpan timeSpan) {
074: setTimeSpan(timeSpan.getStartTime(), timeSpan.getEndTime());
075: }
076:
077: // Slots
078:
079: private Collection theCommunities = new ArrayList();
080:
081: public Collection getCommunities() {
082: return theCommunities;
083: }
084:
085: public boolean inCommunities(String _element) {
086: return (theCommunities == null) ? false : (theCommunities
087: .contains(_element));
088: }
089:
090: public String[] getCommunitiesAsArray() {
091: if (theCommunities == null)
092: return new String[0];
093: int l = theCommunities.size();
094: String[] v = new String[l];
095: int i = 0;
096: for (Iterator n = theCommunities.iterator(); n.hasNext();) {
097: v[i] = (String) n.next();
098: i++;
099: }
100: return v;
101: }
102:
103: public String getIndexedCommunities(int _index) {
104: if (theCommunities == null)
105: return null;
106: for (Iterator _i = theCommunities.iterator(); _i.hasNext();) {
107: String _e = (String) _i.next();
108: if (_index == 0)
109: return _e;
110: _index--;
111: }
112: return null;
113: }
114:
115: public void setCommunities(Collection communities) {
116: theCommunities = communities;
117: }
118:
119: public void clearCommunities() {
120: theCommunities.clear();
121: }
122:
123: public boolean removeFromCommunities(String _element) {
124: return theCommunities.remove(_element);
125: }
126:
127: public boolean addToCommunities(String _element) {
128: return theCommunities.add(_element);
129: }
130:
131: public CommunityPGImpl(CommunityPG original) {
132: setTimeSpan(original.getStartTime(), original.getEndTime());
133: theCommunities = original.getCommunities();
134: }
135:
136: public boolean equals(Object other) {
137:
138: if (!(other instanceof CommunityPG)) {
139: return false;
140: }
141:
142: CommunityPG otherCommunityPG = (CommunityPG) other;
143:
144: if (getCommunities() == null) {
145: if (otherCommunityPG.getCommunities() != null) {
146: return false;
147: }
148: } else if (!(getCommunities().equals(otherCommunityPG
149: .getCommunities()))) {
150: return false;
151: }
152:
153: return true;
154: }
155:
156: public final boolean hasDataQuality() {
157: return false;
158: }
159:
160: private transient CommunityPG _locked = null;
161:
162: public PropertyGroup lock(Object key) {
163: if (_locked == null)
164: _locked = new _Locked(key);
165: return _locked;
166: }
167:
168: public PropertyGroup lock() {
169: return lock(null);
170: }
171:
172: public NewPropertyGroup unlock(Object key) {
173: return this ;
174: }
175:
176: public Object clone() throws CloneNotSupportedException {
177: return new CommunityPGImpl(CommunityPGImpl.this );
178: }
179:
180: public PropertyGroup copy() {
181: try {
182: return (PropertyGroup) clone();
183: } catch (CloneNotSupportedException cnse) {
184: return null;
185: }
186: }
187:
188: public Class getPrimaryClass() {
189: return primaryClass;
190: }
191:
192: public String getAssetGetMethod() {
193: return assetGetter;
194: }
195:
196: public String getAssetSetMethod() {
197: return assetSetter;
198: }
199:
200: private final static PropertyDescriptor properties[] = new PropertyDescriptor[3];
201: static {
202: try {
203: properties[0] = new IndexedPropertyDescriptor(
204: "communities", CommunityPG.class,
205: "getCommunitiesAsArray", null,
206: "getIndexedCommunities", null);
207: properties[1] = new PropertyDescriptor("start_time",
208: CommunityPG.class, "getStartTime", null);
209: properties[2] = new PropertyDescriptor("end_time",
210: CommunityPG.class, "getEndTime", null);
211: } catch (Exception e) {
212: org.cougaar.util.log.Logging.getLogger(CommunityPG.class)
213: .error("Caught exception", e);
214: }
215: }
216:
217: public PropertyDescriptor[] getPropertyDescriptors() {
218: return properties;
219: }
220:
221: private final class _Locked extends java.beans.SimpleBeanInfo
222: implements CommunityPG, Cloneable, LockedPG {
223: private transient Object theKey = null;
224:
225: _Locked(Object key) {
226: if (this .theKey == null)
227: this .theKey = key;
228: }
229:
230: public _Locked() {
231: }
232:
233: public PropertyGroup lock() {
234: return this ;
235: }
236:
237: public PropertyGroup lock(Object o) {
238: return this ;
239: }
240:
241: public NewPropertyGroup unlock(Object key)
242: throws IllegalAccessException {
243: if (theKey.equals(key)) {
244: return CommunityPGImpl.this ;
245: } else {
246: throw new IllegalAccessException(
247: "unlock: mismatched internal and provided keys!");
248: }
249: }
250:
251: public PropertyGroup copy() {
252: try {
253: return (PropertyGroup) clone();
254: } catch (CloneNotSupportedException cnse) {
255: return null;
256: }
257: }
258:
259: public Object clone() throws CloneNotSupportedException {
260: return new CommunityPGImpl(CommunityPGImpl.this );
261: }
262:
263: public long getStartTime() {
264: return CommunityPGImpl.this .getStartTime();
265: }
266:
267: public long getEndTime() {
268: return CommunityPGImpl.this .getEndTime();
269: }
270:
271: public boolean equals(Object object) {
272: return CommunityPGImpl.this .equals(object);
273: }
274:
275: public Collection getCommunities() {
276: return CommunityPGImpl.this .getCommunities();
277: }
278:
279: public boolean inCommunities(String _element) {
280: return CommunityPGImpl.this .inCommunities(_element);
281: }
282:
283: public String[] getCommunitiesAsArray() {
284: return CommunityPGImpl.this .getCommunitiesAsArray();
285: }
286:
287: public String getIndexedCommunities(int _index) {
288: return CommunityPGImpl.this .getIndexedCommunities(_index);
289: }
290:
291: public final boolean hasDataQuality() {
292: return false;
293: }
294:
295: public Class getPrimaryClass() {
296: return primaryClass;
297: }
298:
299: public String getAssetGetMethod() {
300: return assetGetter;
301: }
302:
303: public String getAssetSetMethod() {
304: return assetSetter;
305: }
306:
307: public PropertyDescriptor[] getPropertyDescriptors() {
308: return properties;
309: }
310:
311: public Class getIntrospectionClass() {
312: return CommunityPGImpl.class;
313: }
314:
315: }
316:
317: }
|