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 EntityPG.
029: * @see EntityPG
030: * @see NewEntityPG
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 java.util.*;
037:
038: import java.io.ObjectOutputStream;
039: import java.io.ObjectInputStream;
040: import java.io.IOException;
041: import java.beans.PropertyDescriptor;
042: import java.beans.IndexedPropertyDescriptor;
043:
044: public final class EntityPGImpl extends java.beans.SimpleBeanInfo
045: implements NewEntityPG, Cloneable {
046: public EntityPGImpl() {
047: }
048:
049: // Slots
050:
051: private Collection theRoles = new ArrayList();
052:
053: public Collection getRoles() {
054: return theRoles;
055: }
056:
057: public boolean inRoles(Role _element) {
058: return (theRoles == null) ? false : (theRoles
059: .contains(_element));
060: }
061:
062: public Role[] getRolesAsArray() {
063: if (theRoles == null)
064: return new Role[0];
065: int l = theRoles.size();
066: Role[] v = new Role[l];
067: int i = 0;
068: for (Iterator n = theRoles.iterator(); n.hasNext();) {
069: v[i] = (Role) n.next();
070: i++;
071: }
072: return v;
073: }
074:
075: public Role getIndexedRoles(int _index) {
076: if (theRoles == null)
077: return null;
078: for (Iterator _i = theRoles.iterator(); _i.hasNext();) {
079: Role _e = (Role) _i.next();
080: if (_index == 0)
081: return _e;
082: _index--;
083: }
084: return null;
085: }
086:
087: public void setRoles(Collection roles) {
088: theRoles = roles;
089: }
090:
091: public void clearRoles() {
092: theRoles.clear();
093: }
094:
095: public boolean removeFromRoles(Role _element) {
096: return theRoles.remove(_element);
097: }
098:
099: public boolean addToRoles(Role _element) {
100: return theRoles.add(_element);
101: }
102:
103: public EntityPGImpl(EntityPG original) {
104: theRoles = original.getRoles();
105: }
106:
107: public boolean equals(Object other) {
108:
109: if (!(other instanceof EntityPG)) {
110: return false;
111: }
112:
113: EntityPG otherEntityPG = (EntityPG) other;
114:
115: if (getRoles() == null) {
116: if (otherEntityPG.getRoles() != null) {
117: return false;
118: }
119: } else if (!(getRoles().equals(otherEntityPG.getRoles()))) {
120: return false;
121: }
122:
123: return true;
124: }
125:
126: public final boolean hasDataQuality() {
127: return false;
128: }
129:
130: private transient EntityPG _locked = null;
131:
132: public PropertyGroup lock(Object key) {
133: if (_locked == null)
134: _locked = new _Locked(key);
135: return _locked;
136: }
137:
138: public PropertyGroup lock() {
139: return lock(null);
140: }
141:
142: public NewPropertyGroup unlock(Object key) {
143: return this ;
144: }
145:
146: public Object clone() throws CloneNotSupportedException {
147: return new EntityPGImpl(EntityPGImpl.this );
148: }
149:
150: public PropertyGroup copy() {
151: try {
152: return (PropertyGroup) clone();
153: } catch (CloneNotSupportedException cnse) {
154: return null;
155: }
156: }
157:
158: public Class getPrimaryClass() {
159: return primaryClass;
160: }
161:
162: public String getAssetGetMethod() {
163: return assetGetter;
164: }
165:
166: public String getAssetSetMethod() {
167: return assetSetter;
168: }
169:
170: private final static PropertyDescriptor properties[] = new PropertyDescriptor[1];
171: static {
172: try {
173: properties[0] = new IndexedPropertyDescriptor("roles",
174: EntityPG.class, "getRolesAsArray", null,
175: "getIndexedRoles", null);
176: } catch (Exception e) {
177: org.cougaar.util.log.Logging.getLogger(EntityPG.class)
178: .error("Caught exception", e);
179: }
180: }
181:
182: public PropertyDescriptor[] getPropertyDescriptors() {
183: return properties;
184: }
185:
186: private final class _Locked extends java.beans.SimpleBeanInfo
187: implements EntityPG, Cloneable, LockedPG {
188: private transient Object theKey = null;
189:
190: _Locked(Object key) {
191: if (this .theKey == null)
192: this .theKey = key;
193: }
194:
195: public _Locked() {
196: }
197:
198: public PropertyGroup lock() {
199: return this ;
200: }
201:
202: public PropertyGroup lock(Object o) {
203: return this ;
204: }
205:
206: public NewPropertyGroup unlock(Object key)
207: throws IllegalAccessException {
208: if (theKey.equals(key)) {
209: return EntityPGImpl.this ;
210: } else {
211: throw new IllegalAccessException(
212: "unlock: mismatched internal and provided keys!");
213: }
214: }
215:
216: public PropertyGroup copy() {
217: try {
218: return (PropertyGroup) clone();
219: } catch (CloneNotSupportedException cnse) {
220: return null;
221: }
222: }
223:
224: public Object clone() throws CloneNotSupportedException {
225: return new EntityPGImpl(EntityPGImpl.this );
226: }
227:
228: public boolean equals(Object object) {
229: return EntityPGImpl.this .equals(object);
230: }
231:
232: public Collection getRoles() {
233: return EntityPGImpl.this .getRoles();
234: }
235:
236: public boolean inRoles(Role _element) {
237: return EntityPGImpl.this .inRoles(_element);
238: }
239:
240: public Role[] getRolesAsArray() {
241: return EntityPGImpl.this .getRolesAsArray();
242: }
243:
244: public Role getIndexedRoles(int _index) {
245: return EntityPGImpl.this .getIndexedRoles(_index);
246: }
247:
248: public final boolean hasDataQuality() {
249: return false;
250: }
251:
252: public Class getPrimaryClass() {
253: return primaryClass;
254: }
255:
256: public String getAssetGetMethod() {
257: return assetGetter;
258: }
259:
260: public String getAssetSetMethod() {
261: return assetSetter;
262: }
263:
264: public PropertyDescriptor[] getPropertyDescriptors() {
265: return properties;
266: }
267:
268: public Class getIntrospectionClass() {
269: return EntityPGImpl.class;
270: }
271:
272: }
273:
274: }
|