01: /*
02: * <copyright>
03: *
04: * Copyright 1997-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.glm.ldm.plan;
28:
29: import java.util.Date;
30:
31: import org.cougaar.planning.ldm.plan.ScheduleElementImpl;
32: import org.cougaar.planning.ldm.plan.ScheduleElementWithValue;
33:
34: /**
35: * A QuantityScheduleElement is an encapsulation of temporal relationships
36: * and a quantity over that interval.
37: **/
38:
39: public class QuantityScheduleElementImpl extends ScheduleElementImpl
40: implements QuantityScheduleElement, NewQuantityScheduleElement {
41:
42: private double quantity = -999.0;
43:
44: /** no-arg constructor */
45: public QuantityScheduleElementImpl() {
46: super ();
47: }
48:
49: /** constructor for factory use that takes the start and end dates
50: * and a quantity(double)
51: **/
52: public QuantityScheduleElementImpl(Date start, Date end, double q) {
53: super (start, end);
54: quantity = q;
55: }
56:
57: /** constructor that takes longs instead of dates */
58: public QuantityScheduleElementImpl(long start, long end, double q) {
59: super (start, end);
60: quantity = q;
61: }
62:
63: /** @return double quantity of schedule element */
64: public double getQuantity() {
65: return quantity;
66: }
67:
68: /** simple clone*/
69: public Object clone() {
70: return new QuantityScheduleElementImpl(stime, etime, quantity);
71: }
72:
73: // NewQuantityScheduleElement interface implementations
74:
75: /** @param aQuantity Set quantity of the schedule element */
76: public void setQuantity(double aQuantity) {
77: quantity = aQuantity;
78: }
79:
80: public String toString() {
81: String super string = super .toString();
82: return "<" + super string + " = " + quantity + ">" + "\n";
83: }
84:
85: public double getValue() {
86: return quantity;
87: }
88:
89: public ScheduleElementWithValue newElement(long start, long end,
90: double value) {
91: return new QuantityScheduleElementImpl(start, end, value);
92: }
93: }
|