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: package org.cougaar.planning.ldm.plan;
028:
029: import java.io.IOException;
030: import java.io.ObjectInputStream;
031: import java.io.ObjectOutputStream;
032:
033: import org.cougaar.core.mts.MessageAddress;
034: import org.cougaar.planning.ldm.asset.Asset;
035:
036: /** AssetRescind implementation
037: * AssetRescind allows a asset to be rescinded from the Plan.
038: **/
039:
040: public class AssetRescindImpl extends PlanningDirectiveImpl implements
041: AssetRescind, NewAssetRescind {
042:
043: private transient Asset rescindedAsset;
044: private transient Asset rescindeeAsset;
045: private Schedule rescindedSchedule;
046:
047: public AssetRescindImpl(MessageAddress src, MessageAddress dest,
048: Plan plan, Asset rescindedAsset, Asset rescindeeAsset,
049: Schedule rescindSchedule) {
050: setSource(src);
051: setDestination(dest);
052: super .setPlan(plan);
053:
054: setAsset(rescindedAsset);
055: setRescindee(rescindeeAsset);
056: setSchedule(rescindSchedule);
057: }
058:
059: /**
060: * Returns the asset to be rescinded
061: * @return Asset
062: **/
063:
064: public Asset getAsset() {
065: return rescindedAsset;
066: }
067:
068: /**
069: * Sets the asset to be rescinded
070: **/
071:
072: public void setAsset(Asset asset) {
073: rescindedAsset = asset;
074: }
075:
076: public Asset getRescindee() {
077: return rescindeeAsset;
078: }
079:
080: public void setRescindee(Asset newRescindeeAsset) {
081: rescindeeAsset = newRescindeeAsset;
082: }
083:
084: public Schedule getSchedule() {
085: return rescindedSchedule;
086: }
087:
088: public void setSchedule(Schedule sched) {
089: rescindedSchedule = sched;
090: }
091:
092: public String toString() {
093: String scheduleDescr = "(Null RescindedSchedule)";
094: if (rescindedSchedule != null)
095: scheduleDescr = rescindedSchedule.toString();
096: String assetDescr = "(Null RescindedAsset)";
097: if (rescindedAsset != null)
098: assetDescr = rescindedAsset.toString();
099: String toAssetDescr = "(Null RescindeeAsset)";
100: if (rescindeeAsset != null)
101: toAssetDescr = rescindeeAsset.toString();
102:
103: return "<AssetRescind " + assetDescr + ", " + scheduleDescr
104: + " to " + toAssetDescr + ">" + super .toString();
105: }
106:
107: private void writeObject(ObjectOutputStream stream)
108: throws IOException {
109:
110: /** ----------
111: * WRITE handlers common to Persistence and
112: * Network serialization. NOte that these
113: * cannot be references to Persistable objects.
114: * defaultWriteObject() is likely to belong here...
115: * ---------- **/
116: stream.defaultWriteObject();
117:
118: stream.writeObject(rescindedAsset);
119: stream.writeObject(rescindeeAsset);
120: }
121:
122: private void readObject(ObjectInputStream stream)
123: throws ClassNotFoundException, IOException {
124:
125: stream.defaultReadObject();
126:
127: rescindedAsset = (Asset) stream.readObject();
128: rescindeeAsset = (Asset) stream.readObject();
129: }
130:
131: }
|