001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 SRA International
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:
028: package org.cougaar.logistics.plugin.policy;
029:
030: import org.cougaar.planning.ldm.policy.Policy;
031: import org.cougaar.planning.ldm.policy.RuleParameter;
032: import org.cougaar.planning.ldm.policy.BooleanRuleParameter;
033: import org.cougaar.planning.ldm.policy.RuleParameterIllegalValueException;
034: import org.cougaar.planning.ldm.policy.RangeRuleParameter;
035: import org.cougaar.planning.ldm.policy.StringRuleParameter;
036: import org.cougaar.planning.ldm.policy.KeyRuleParameter;
037: import org.cougaar.planning.ldm.policy.KeyRuleParameterEntry;
038: import org.cougaar.planning.ldm.policy.RangeRuleParameterEntry;
039: import java.util.Arrays;
040:
041: public class LogClassIPolicy extends Policy {
042: public static final String MEAL_POLICY = "MealPolicy";
043: public static final String A_RATION_POLICY = "A-RationPolicy";
044: public static final String ENHANCEMENTS_POLICY = "EnhancementsPolicy";
045: public static final String BOTTLEDWATER_POLICY = "BottledWaterPolicy";
046:
047: /**
048: * SubsistencePolicy constructor comment.
049: */
050: public LogClassIPolicy() {
051: }
052:
053: /**
054: * Insert the method's description here.
055: * Creation date: (3/2/01 9:03:51 AM)
056: */
057: public RangeRuleParameterEntry[] getARationPolicyRanges() {
058: RangeRuleParameter param = (RangeRuleParameter) Lookup(A_RATION_POLICY);
059: return (RangeRuleParameterEntry[]) param.getRanges();
060:
061: }
062:
063: /**
064: * Insert the method's description here.
065: * Creation date: (3/2/01 9:03:51 AM)
066: */
067: public RangeRuleParameterEntry[] getEnhancementsPolicyRanges() {
068: RangeRuleParameter param = (RangeRuleParameter) Lookup(ENHANCEMENTS_POLICY);
069: return (RangeRuleParameterEntry[]) param.getRanges();
070:
071: }
072:
073: /**
074: * Insert the method's description here.
075: * Creation date: (3/2/01 9:03:51 AM)
076: */
077: public RangeRuleParameterEntry[] getMealPolicyRanges() {
078: RangeRuleParameter param = (RangeRuleParameter) Lookup(MEAL_POLICY);
079: return (RangeRuleParameterEntry[]) param.getRanges();
080:
081: }
082:
083: /**
084: * Insert the method's description here.
085: * Creation date: (3/2/01 9:03:51 AM)
086: */
087: public RangeRuleParameterEntry[] getWaterPolicyRanges() {
088: RangeRuleParameter param = (RangeRuleParameter) Lookup(BOTTLEDWATER_POLICY);
089: return (RangeRuleParameterEntry[]) param.getRanges();
090:
091: }
092:
093: /**
094: * Insert the method's description here.
095: * Creation date: (3/2/01 9:03:51 AM)
096: */
097: public void setARationPolicyRanges(RangeRuleParameterEntry[] ranges) {
098: RangeRuleParameter param = (RangeRuleParameter) Lookup(A_RATION_POLICY);
099: param.setRanges(ranges);
100: }
101:
102: /**
103: * Insert the method's description here.
104: * Creation date: (3/2/01 9:03:51 AM)
105: */
106: public void setEnhancementsPolicyRanges(
107: RangeRuleParameterEntry[] ranges) {
108: RangeRuleParameter param = (RangeRuleParameter) Lookup(ENHANCEMENTS_POLICY);
109: param.setRanges(ranges);
110: }
111:
112: /**
113: * Insert the method's description here.
114: * Creation date: (3/2/01 9:03:51 AM)
115: */
116: public void setMealPolicyRanges(RangeRuleParameterEntry[] ranges) {
117: RangeRuleParameter param = (RangeRuleParameter) Lookup(MEAL_POLICY);
118: param.setRanges(ranges);
119: }
120:
121: /**
122: * Insert the method's description here.
123: * Creation date: (3/2/01 9:03:51 AM)
124: */
125: public void setWaterPolicyRanges(RangeRuleParameterEntry[] ranges) {
126: RangeRuleParameter param = (RangeRuleParameter) Lookup(BOTTLEDWATER_POLICY);
127: param.setRanges(ranges);
128: }
129:
130: public static final String RULES = "Rules";
131:
132: /**
133: * Insert the method's description here.
134: * Creation date: (4/16/01 9:01:45 AM)
135: */
136: public KeyRuleParameterEntry[] getActionKeys(
137: RangeRuleParameter theRule) {
138: if (theRule != null) {
139: RangeRuleParameterEntry[] rule = (RangeRuleParameterEntry[]) theRule
140: .getRanges();
141: if (rule != null) {
142: KeyRuleParameter theAction = (KeyRuleParameter) rule[1]
143: .getValue();
144: if (theAction != null)
145: return theAction.getKeys();
146: }
147: }
148: return null;
149: }
150:
151: /**
152: * Insert the method's description here.
153: * Creation date: (4/16/01 9:01:45 AM)
154: */
155: public KeyRuleParameterEntry[] getConditionKeys(
156: RangeRuleParameter theRule) {
157: if (theRule != null) {
158: RangeRuleParameterEntry[] rule = (RangeRuleParameterEntry[]) theRule
159: .getRanges();
160: if (rule != null) {
161: KeyRuleParameter theCondition = (KeyRuleParameter) rule[0]
162: .getValue();
163: if (theCondition != null)
164: return theCondition.getKeys();
165: }
166: }
167: return null;
168: }
169:
170: /**
171: * Insert the method's description here.
172: * Creation date: (4/11/01 9:45:39 AM)
173: */
174: public KeyRuleParameterEntry[] getEnhancementsKeys(int range) {
175: RangeRuleParameterEntry[] enhancements = getEnhancementsPolicyRanges();
176: if (enhancements != null) {
177: KeyRuleParameter krp = (KeyRuleParameter) enhancements[range]
178: .getValue();
179: if (krp != null)
180: return krp.getKeys();
181: }
182: return new KeyRuleParameterEntry[0];
183: }
184:
185: /**
186: * Insert the method's description here.
187: * Creation date: (4/11/01 9:45:39 AM)
188: */
189: public KeyRuleParameterEntry[] getMealKeys(int range) {
190: RangeRuleParameterEntry[] meals = getMealPolicyRanges();
191: if (meals != null) {
192: KeyRuleParameter krp = (KeyRuleParameter) meals[range]
193: .getValue();
194: if (krp != null)
195: return krp.getKeys();
196: }
197: return new KeyRuleParameterEntry[0];
198: }
199:
200: /**
201: * Insert the method's description here.
202: * Creation date: (4/11/01 9:45:39 AM)
203: */
204: public KeyRuleParameterEntry[] getRangeKeys(
205: RangeRuleParameterEntry range) {
206: if (range != null) {
207: KeyRuleParameter krp = (KeyRuleParameter) range.getValue();
208: if (krp != null)
209: return krp.getKeys();
210: }
211: return new KeyRuleParameterEntry[0];
212: }
213:
214: /**
215: * Insert the method's description here.
216: * Creation date: (3/2/01 9:03:51 AM)
217: */
218: public RangeRuleParameterEntry[] getRules() {
219: RangeRuleParameter param = (RangeRuleParameter) Lookup(RULES);
220: return (RangeRuleParameterEntry[]) param.getRanges();
221:
222: }
223:
224: /**
225: * Insert the method's description here.
226: * Creation date: (4/11/01 9:45:39 AM)
227: */
228: public KeyRuleParameterEntry[] getWaterKeys(int range) {
229: RangeRuleParameterEntry[] water = getWaterPolicyRanges();
230: if (water != null) {
231: KeyRuleParameter krp = (KeyRuleParameter) water[range]
232: .getValue();
233: if (krp != null)
234: return krp.getKeys();
235: }
236: return new KeyRuleParameterEntry[0];
237: }
238:
239: /**
240: * Insert the method's description here.
241: * Creation date: (4/16/01 9:01:45 AM)
242: */
243: void newMethod() {
244: }
245: }
|