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 RateScheduleElement is an encapsulation of temporal relationships
36: * and a rate over that time interval.
37: **/
38:
39: public class RateScheduleElementImpl extends ScheduleElementImpl
40: implements RateScheduleElement, NewRateScheduleElement {
41:
42: private double rate = -999.0;
43:
44: /** no-arg constructor */
45: public RateScheduleElementImpl() {
46: super ();
47: }
48:
49: /** constructor for factory use that takes the start and end dates and a rate(double)*/
50: public RateScheduleElementImpl(Date start, Date end, double r) {
51: super (start, end);
52: rate = r;
53: }
54:
55: /** constructor for factory use that takes the start and end longs and a rate(double)*/
56: public RateScheduleElementImpl(long start, long end, double r) {
57: super (start, end);
58: rate = r;
59: }
60:
61: /** @return double rate of schedule element */
62: public double getRate() {
63: return rate;
64: }
65:
66: /** simple clone*/
67: public Object clone() {
68: return new RateScheduleElementImpl(stime, etime, rate);
69: }
70:
71: // NewRateScheduleElement interface implementations
72:
73: /** @param aRate Set rate of the schedule element */
74: public void setRate(double aRate) {
75: rate = aRate;
76: }
77:
78: public String toString() {
79: String super string = super .toString();
80: return "<" + super string + "-" + rate + ">" + "\n";
81: }
82:
83: public double getValue() {
84: return rate;
85: }
86:
87: public ScheduleElementWithValue newElement(long start, long end,
88: double value) {
89: return new RateScheduleElementImpl(start, end, value);
90: }
91:
92: }
|