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.lib.param;
028:
029: import java.util.Vector;
030:
031: import org.cougaar.util.log.Logger;
032: import org.cougaar.util.log.LoggerFactory;
033:
034: /**
035: * Class that is used to test a ParamTable. The table consists of
036: * [name, com.bbn.tops.param.Parameter] pairs.
037: *
038: */
039: public class TestParam {
040: // this is OK since it's just for testing
041: private static Logger logger = LoggerFactory.getInstance()
042: .createLogger("TestParam");
043:
044: /**
045: * Test main function
046: */
047: public void main(String[] argv) {
048: Vector v = new Vector();
049: v.addElement("envDir={String}.");
050: v.addElement("envFile={String}testparam.xml");
051: ParamTable pt = new ParamTable(logger);
052: pt.addIniParameters(v);
053: boolean b = false;
054: short s = 20;
055: int i = 50;
056: float f = 1000;
057: double d = 1000.0;
058: String str = "empty";
059: long l = 50000;
060:
061: try {
062: b = pt.getBooleanParam("debug");
063: } catch (ParamException e) {
064: logger.error(e.getMessage());
065: }
066: logger.debug("debug = " + b);
067:
068: try {
069: b = pt.getBooleanParam("print");
070: } catch (ParamException e) {
071: logger.error(e.getMessage());
072: }
073: logger.debug("print = " + b);
074:
075: try {
076: b = pt.getBooleanParam("run");
077: } catch (ParamException e) {
078: logger.error(e.getMessage());
079: }
080: logger.debug("run = " + b);
081:
082: try {
083: b = pt.getBooleanParam("test");
084: } catch (ParamException e) {
085: logger.error(e.getMessage());
086: }
087: logger.debug("test = " + b);
088:
089: try {
090: str = pt.getStringParam("planeType");
091: } catch (ParamException e) {
092: logger.error(e.getMessage());
093: }
094: logger.debug("planeType = " + str);
095:
096: try {
097: s = pt.getShortParam("testShort");
098: } catch (ParamException e) {
099: logger.error(e.getMessage());
100: }
101: logger.debug("testShort = " + s);
102:
103: try {
104: f = pt.getFloatParam("testFloat");
105: } catch (ParamException e) {
106: logger.error(e.getMessage());
107: }
108: logger.debug("testFloat = " + f);
109:
110: try {
111: l = pt.getLongParam("testLong");
112: } catch (ParamException e) {
113: logger.error(e.getMessage());
114: }
115: logger.debug("testLong = " + l);
116:
117: try {
118: d = pt.getDoubleParam("testDouble");
119: } catch (ParamException e) {
120: logger.error(e.getMessage());
121: }
122: logger.debug("testDouble = " + d);
123:
124: try {
125: i = pt.getIntParam("numPlanes");
126: } catch (ParamException e) {
127: logger.error(e.getMessage());
128: }
129: logger.debug("numPlanes = " + i);
130: }
131: }
|