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:21:47 EDT 2007 from /u01/builds/cougaar/B12_4/B12_4/070927151721/src/glm/src/org/cougaar/glm/ldm/asset/alpprops.def - DO NOT HAND EDIT */
028: /** Implementation of AssignedPG.
029: * @see AssignedPG
030: * @see NewAssignedPG
031: **/package org.cougaar.glm.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 java.util.*;
037:
038: import org.cougaar.glm.ldm.plan.*;
039: import org.cougaar.glm.ldm.oplan.*;
040: import org.cougaar.glm.ldm.policy.*;
041: import org.cougaar.core.mts.MessageAddress;
042: import org.cougaar.glm.execution.common.InventoryReport;
043:
044: import java.io.ObjectOutputStream;
045: import java.io.ObjectInputStream;
046: import java.io.IOException;
047: import java.beans.PropertyDescriptor;
048: import java.beans.IndexedPropertyDescriptor;
049:
050: public class AssignedPGImpl extends java.beans.SimpleBeanInfo implements
051: NewAssignedPG, Cloneable {
052: public AssignedPGImpl() {
053: }
054:
055: // Slots
056:
057: private Collection theRoles = new ArrayList();
058:
059: public Collection getRoles() {
060: return theRoles;
061: }
062:
063: public boolean inRoles(Role _element) {
064: return (theRoles == null) ? false : (theRoles
065: .contains(_element));
066: }
067:
068: public Role[] getRolesAsArray() {
069: if (theRoles == null)
070: return new Role[0];
071: int l = theRoles.size();
072: Role[] v = new Role[l];
073: int i = 0;
074: for (Iterator n = theRoles.iterator(); n.hasNext();) {
075: v[i] = (Role) n.next();
076: i++;
077: }
078: return v;
079: }
080:
081: public Role getIndexedRoles(int _index) {
082: if (theRoles == null)
083: return null;
084: for (Iterator _i = theRoles.iterator(); _i.hasNext();) {
085: Role _e = (Role) _i.next();
086: if (_index == 0)
087: return _e;
088: _index--;
089: }
090: return null;
091: }
092:
093: public void setRoles(Collection roles) {
094: theRoles = roles;
095: }
096:
097: public void clearRoles() {
098: theRoles.clear();
099: }
100:
101: public boolean removeFromRoles(Role _element) {
102: return theRoles.remove(_element);
103: }
104:
105: public boolean addToRoles(Role _element) {
106: return theRoles.add(_element);
107: }
108:
109: public AssignedPGImpl(AssignedPG original) {
110: theRoles = original.getRoles();
111: }
112:
113: public boolean equals(Object other) {
114:
115: if (!(other instanceof AssignedPG)) {
116: return false;
117: }
118:
119: AssignedPG otherAssignedPG = (AssignedPG) other;
120:
121: if (getRoles() == null) {
122: if (otherAssignedPG.getRoles() != null) {
123: return false;
124: }
125: } else if (!(getRoles().equals(otherAssignedPG.getRoles()))) {
126: return false;
127: }
128:
129: return true;
130: }
131:
132: public boolean hasDataQuality() {
133: return false;
134: }
135:
136: public org.cougaar.planning.ldm.dq.DataQuality getDataQuality() {
137: return null;
138: }
139:
140: // static inner extension class for real DataQuality Support
141: public final static class DQ extends AssignedPGImpl implements
142: org.cougaar.planning.ldm.dq.NewHasDataQuality {
143: public DQ() {
144: super ();
145: }
146:
147: public DQ(AssignedPG original) {
148: super (original);
149: }
150:
151: public Object clone() {
152: return new DQ(this );
153: }
154:
155: private transient org.cougaar.planning.ldm.dq.DataQuality _dq = null;
156:
157: public boolean hasDataQuality() {
158: return (_dq != null);
159: }
160:
161: public org.cougaar.planning.ldm.dq.DataQuality getDataQuality() {
162: return _dq;
163: }
164:
165: public void setDataQuality(
166: org.cougaar.planning.ldm.dq.DataQuality dq) {
167: _dq = dq;
168: }
169:
170: private void writeObject(ObjectOutputStream out)
171: throws IOException {
172: out.defaultWriteObject();
173: if (out instanceof org.cougaar.core.persist.PersistenceOutputStream)
174: out.writeObject(_dq);
175: }
176:
177: private void readObject(ObjectInputStream in)
178: throws ClassNotFoundException, IOException {
179: in.defaultReadObject();
180: if (in instanceof org.cougaar.core.persist.PersistenceInputStream)
181: _dq = (org.cougaar.planning.ldm.dq.DataQuality) in
182: .readObject();
183: }
184:
185: private final static PropertyDescriptor properties[] = new PropertyDescriptor[1];
186: static {
187: try {
188: properties[0] = new PropertyDescriptor("dataQuality",
189: DQ.class, "getDataQuality", null);
190: } catch (Exception e) {
191: e.printStackTrace();
192: }
193: }
194:
195: public PropertyDescriptor[] getPropertyDescriptors() {
196: PropertyDescriptor[] pds = super .properties;
197: PropertyDescriptor[] ps = new PropertyDescriptor[pds.length
198: + properties.length];
199: System.arraycopy(pds, 0, ps, 0, pds.length);
200: System.arraycopy(properties, 0, ps, pds.length,
201: properties.length);
202: return ps;
203: }
204: }
205:
206: private transient AssignedPG _locked = null;
207:
208: public PropertyGroup lock(Object key) {
209: if (_locked == null)
210: _locked = new _Locked(key);
211: return _locked;
212: }
213:
214: public PropertyGroup lock() {
215: return lock(null);
216: }
217:
218: public NewPropertyGroup unlock(Object key) {
219: return this ;
220: }
221:
222: public Object clone() throws CloneNotSupportedException {
223: return new AssignedPGImpl(AssignedPGImpl.this );
224: }
225:
226: public PropertyGroup copy() {
227: try {
228: return (PropertyGroup) clone();
229: } catch (CloneNotSupportedException cnse) {
230: return null;
231: }
232: }
233:
234: public Class getPrimaryClass() {
235: return primaryClass;
236: }
237:
238: public String getAssetGetMethod() {
239: return assetGetter;
240: }
241:
242: public String getAssetSetMethod() {
243: return assetSetter;
244: }
245:
246: private final static PropertyDescriptor properties[] = new PropertyDescriptor[1];
247: static {
248: try {
249: properties[0] = new IndexedPropertyDescriptor("roles",
250: AssignedPG.class, "getRolesAsArray", null,
251: "getIndexedRoles", null);
252: } catch (Exception e) {
253: org.cougaar.util.log.Logging.getLogger(AssignedPG.class)
254: .error("Caught exception", e);
255: }
256: }
257:
258: public PropertyDescriptor[] getPropertyDescriptors() {
259: return properties;
260: }
261:
262: private final class _Locked extends java.beans.SimpleBeanInfo
263: implements AssignedPG, Cloneable, LockedPG {
264: private transient Object theKey = null;
265:
266: _Locked(Object key) {
267: if (this .theKey == null)
268: this .theKey = key;
269: }
270:
271: public _Locked() {
272: }
273:
274: public PropertyGroup lock() {
275: return this ;
276: }
277:
278: public PropertyGroup lock(Object o) {
279: return this ;
280: }
281:
282: public NewPropertyGroup unlock(Object key)
283: throws IllegalAccessException {
284: if (theKey.equals(key)) {
285: return AssignedPGImpl.this ;
286: } else {
287: throw new IllegalAccessException(
288: "unlock: mismatched internal and provided keys!");
289: }
290: }
291:
292: public PropertyGroup copy() {
293: try {
294: return (PropertyGroup) clone();
295: } catch (CloneNotSupportedException cnse) {
296: return null;
297: }
298: }
299:
300: public Object clone() throws CloneNotSupportedException {
301: return new AssignedPGImpl(AssignedPGImpl.this );
302: }
303:
304: public boolean equals(Object object) {
305: return AssignedPGImpl.this .equals(object);
306: }
307:
308: public Collection getRoles() {
309: return AssignedPGImpl.this .getRoles();
310: }
311:
312: public boolean inRoles(Role _element) {
313: return AssignedPGImpl.this .inRoles(_element);
314: }
315:
316: public Role[] getRolesAsArray() {
317: return AssignedPGImpl.this .getRolesAsArray();
318: }
319:
320: public Role getIndexedRoles(int _index) {
321: return AssignedPGImpl.this .getIndexedRoles(_index);
322: }
323:
324: public final boolean hasDataQuality() {
325: return AssignedPGImpl.this .hasDataQuality();
326: }
327:
328: public final org.cougaar.planning.ldm.dq.DataQuality getDataQuality() {
329: return AssignedPGImpl.this .getDataQuality();
330: }
331:
332: public Class getPrimaryClass() {
333: return primaryClass;
334: }
335:
336: public String getAssetGetMethod() {
337: return assetGetter;
338: }
339:
340: public String getAssetSetMethod() {
341: return assetSetter;
342: }
343:
344: public PropertyDescriptor[] getPropertyDescriptors() {
345: return properties;
346: }
347:
348: public Class getIntrospectionClass() {
349: return AssignedPGImpl.class;
350: }
351:
352: }
353:
354: }
|