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: package org.cougaar.glm.execution.common;
027:
028: import java.io.IOException;
029:
030: import org.cougaar.core.util.UID;
031:
032: public class FailureConsumptionRate extends EGObjectBase implements
033: EGObject {
034: public static class Rescind extends FailureConsumptionRate {
035: public Rescind() {
036: }
037:
038: public Rescind(UID aTaskUID) {
039: theTaskUID = aTaskUID;
040: }
041:
042: public boolean isRescind() {
043: return true;
044: }
045: }
046:
047: public boolean isRescind() {
048: return false;
049: }
050:
051: public UID theTaskUID;
052: public long theStartTime;
053: public long theEndTime;
054: public double theRateValue;
055: public String theItemIdentification = ""; // Insure non-null for Rescind
056: public String theItemName = "";
057: public String theRateUnits = ""; // Insure non-null for Rescind
058: public double theRateMultiplier;
059: public String theConsumer = ""; // What kind of asset is consuming this item
060: public String theConsumerId = ""; // The id of the asset consuming this item
061:
062: public FailureConsumptionRate(UID aTaskUID,
063: String anItemIdentification, String anItemName,
064: long aStartTime, long anEndTime, double aRateValue,
065: String aRateUnits, double aRateMultiplier,
066: String aConsumerId, String aConsumer) {
067: theTaskUID = aTaskUID;
068: theItemIdentification = anItemIdentification.intern();
069: theItemName = anItemName;
070: theStartTime = aStartTime;
071: theEndTime = anEndTime;
072: theRateValue = aRateValue;
073: theRateUnits = aRateUnits;
074: theRateMultiplier = aRateMultiplier;
075: theConsumerId = aConsumerId;
076: theConsumer = aConsumer;
077: }
078:
079: FailureConsumptionRate() {
080: }
081:
082: public FailureConsumptionRate(FailureConsumptionRate original) {
083: this (original.theTaskUID, original.theItemIdentification,
084: original.theItemName, original.theStartTime,
085: original.theEndTime, original.theRateValue,
086: original.theRateUnits, original.theRateMultiplier,
087: original.theConsumerId, original.theConsumer);
088: }
089:
090: public void write(LineWriter writer) throws IOException {
091: writer.writeUID(theTaskUID);
092: writer.writeUTF(theItemIdentification);
093: writer.writeUTF(theItemName);
094: writer.writeLong(theStartTime);
095: writer.writeLong(theEndTime);
096: writer.writeDouble(theRateValue);
097: writer.writeUTF(theRateUnits);
098: writer.writeDouble(theRateMultiplier);
099: writer.writeUTF(theConsumerId);
100: writer.writeUTF(theConsumer);
101: }
102:
103: public void read(LineReader reader) throws IOException {
104: theTaskUID = reader.readUID();
105: theItemIdentification = reader.readUTF().intern();
106: theItemName = reader.readUTF();
107: theStartTime = reader.readLong();
108: theEndTime = reader.readLong();
109: theRateValue = reader.readDouble();
110: theRateUnits = reader.readUTF();
111: theRateMultiplier = reader.readDouble();
112: theConsumerId = reader.readUTF();
113: theConsumer = reader.readUTF();
114: }
115: }
|