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.glm.ldm.policy;
028:
029: import org.cougaar.planning.ldm.policy.BooleanRuleParameter;
030: import org.cougaar.planning.ldm.policy.IntegerRuleParameter;
031: import org.cougaar.planning.ldm.policy.Policy;
032: import org.cougaar.planning.ldm.policy.RuleParameterIllegalValueException;
033:
034: /**
035: * StockLevelPolicy
036: *
037: *
038: */
039:
040: public class StockageLevelPolicy extends Policy {
041:
042: public static final String DaysOfSupply = "DaysOfSupply";
043: public static final String HostNation = "HostNation";
044: public static final String WarReserves = "WarReserves";
045: public static final String PrepositionStock = "PrepositionStock";
046:
047: public StockageLevelPolicy() {
048: super ("StockageLevelPolicy");
049:
050: IntegerRuleParameter irp = new IntegerRuleParameter(
051: DaysOfSupply, 0, 365);
052: try {
053: irp.setValue(new Integer(2));
054: } catch (RuleParameterIllegalValueException ex) {
055: System.out.println(ex);
056: }
057: Add(irp);
058:
059: BooleanRuleParameter brp = new BooleanRuleParameter(HostNation);
060: Boolean bv = new Boolean(false);
061: try {
062: brp.setValue(bv);
063: } catch (RuleParameterIllegalValueException ex) {
064: System.out.println(ex);
065: }
066: Add(brp);
067:
068: brp = new BooleanRuleParameter(WarReserves);
069: bv = new Boolean(false);
070: try {
071: brp.setValue(bv);
072: } catch (RuleParameterIllegalValueException ex) {
073: System.out.println(ex);
074: }
075: Add(brp);
076:
077: brp = new BooleanRuleParameter(PrepositionStock);
078: bv = new Boolean(false);
079: try {
080: brp.setValue(bv);
081: } catch (RuleParameterIllegalValueException ex) {
082: System.out.println(ex);
083: }
084: Add(brp);
085: }
086:
087: public int getDaysOfSupply() {
088: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysOfSupply);
089: return ((Integer) (param.getValue())).intValue();
090: }
091:
092: public void setDaysOfSupply(int days) {
093: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysOfSupply);
094: try {
095: param.setValue(new Integer(days));
096: } catch (RuleParameterIllegalValueException ex) {
097: System.out.println(ex);
098: }
099: }
100:
101: public boolean getHostNation() {
102: BooleanRuleParameter param = (BooleanRuleParameter) Lookup(HostNation);
103: return ((Boolean) (param.getValue())).booleanValue();
104: }
105:
106: public void setHostNation(boolean value) {
107: BooleanRuleParameter param = (BooleanRuleParameter) Lookup(HostNation);
108: try {
109:
110: param.setValue(new Boolean(value));
111: } catch (RuleParameterIllegalValueException ex) {
112: System.out.println(ex);
113: }
114: }
115:
116: public boolean getWarReserves() {
117: BooleanRuleParameter param = (BooleanRuleParameter) Lookup(WarReserves);
118: return ((Boolean) (param.getValue())).booleanValue();
119: }
120:
121: public void setWarReserves(boolean value) {
122: BooleanRuleParameter param = (BooleanRuleParameter) Lookup(WarReserves);
123: try {
124: param.setValue(new Boolean(value));
125: } catch (RuleParameterIllegalValueException ex) {
126: System.out.println(ex);
127: }
128: }
129:
130: public boolean getPrepositionStock() {
131: BooleanRuleParameter param = (BooleanRuleParameter) Lookup(PrepositionStock);
132: return ((Boolean) (param.getValue())).booleanValue();
133: }
134:
135: public void setPrepositionStock(boolean value) {
136: BooleanRuleParameter param = (BooleanRuleParameter) Lookup(PrepositionStock);
137: try {
138: param.setValue(new Boolean(value));
139: } catch (RuleParameterIllegalValueException ex) {
140: System.out.println(ex);
141: }
142: }
143:
144: }
|