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.EnumerationRuleParameter;
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: * The PolicyPlugin
036: *
037: *
038: */
039:
040: public class ShipPolicy extends Policy {
041:
042: public static final String ShipDays = "ShipDays";
043: public static final String ShipMode = "ShipMode";
044: public static final String Ground = "Ground";
045: public static final String Air = "Air";
046: public static final String Sea = "Sea";
047:
048: public ShipPolicy() {
049: super ("ShipPolicy");
050:
051: IntegerRuleParameter irp = new IntegerRuleParameter(ShipDays,
052: 1, 10);
053: try {
054: irp.setValue(new Integer(2));
055: } catch (RuleParameterIllegalValueException ex) {
056: System.out.println(ex);
057: }
058: Add(irp);
059:
060: String modes[] = new String[3];
061: modes[0] = Ground;
062: modes[1] = Sea;
063: modes[2] = Air;
064: EnumerationRuleParameter erp = new EnumerationRuleParameter(
065: ShipMode, modes);
066: try {
067: erp.setValue(Ground);
068: } catch (RuleParameterIllegalValueException ex) {
069: System.out.println(ex);
070: }
071: Add(erp);
072: }
073:
074: public int getShipDays() {
075: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(ShipDays);
076: return ((Integer) (param.getValue())).intValue();
077: }
078:
079: public void setShipDays(int days) {
080: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(ShipDays);
081: try {
082: param.setValue(new Integer(days));
083: } catch (RuleParameterIllegalValueException ex) {
084: System.out.println(ex);
085: }
086: }
087:
088: public String getShipMode() {
089: EnumerationRuleParameter param = (EnumerationRuleParameter) Lookup(ShipMode);
090: return ((String) param.getValue());
091: }
092:
093: public void setShipMode(String mode) {
094: EnumerationRuleParameter param = (EnumerationRuleParameter) Lookup(ShipMode);
095: try {
096: param.setValue(mode);
097: } catch (RuleParameterIllegalValueException ex) {
098: System.out.println(ex);
099: }
100: }
101: }
|