0001: /*
0002: * <copyright>
0003: *
0004: * Copyright 1997-2004 BBNT Solutions, LLC
0005: * under sponsorship of the Defense Advanced Research Projects
0006: * Agency (DARPA).
0007: *
0008: * You can redistribute this software and/or modify it under the
0009: * terms of the Cougaar Open Source License as published on the
0010: * Cougaar Open Source Website (www.cougaar.org).
0011: *
0012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0023: *
0024: * </copyright>
0025: */
0026:
0027: /* @generated Thu Sep 27 15:20:43 EDT 2007 from /u01/builds/cougaar/B12_4/B12_4/070927151721/src/planning/src/org/cougaar/planning/ldm/measure/measures.def - DO NOT HAND EDIT */
0028: /** Immutable implementation of CountRate.
0029: **/package org.cougaar.planning.ldm.measure;
0030:
0031: import java.io.*;
0032:
0033: public final class CountRate extends AbstractMeasure implements
0034: Externalizable, Derivative, Rate {
0035: // the value is stored as units/second
0036: private double theValue;
0037:
0038: /** No-arg constructor is only for use by serialization **/
0039: public CountRate() {
0040: }
0041:
0042: // private constructor
0043: private CountRate(double v) {
0044: theValue = v;
0045: }
0046:
0047: /** @param unit One of the constant units of CountRate **/
0048: public CountRate(double v, int unit) {
0049: if (unit >= 0 && unit <= MAXUNIT)
0050: theValue = v / getConvFactor(unit);
0051: else
0052: throw new UnknownUnitException();
0053: }
0054:
0055: /** @param unit1 One of the constant units of Count
0056: * @param unit2 One of the constant units of Duration
0057: **/
0058: public CountRate(double v, int unit1, int unit2) {
0059: if (unit1 >= 0 && unit1 <= Count.MAXUNIT && unit2 >= 0
0060: && unit2 <= Duration.MAXUNIT)
0061: theValue = v * Count.getConvFactor(unit1)
0062: / Duration.getConvFactor(unit2);
0063: else
0064: throw new UnknownUnitException();
0065: }
0066:
0067: /** @param num An instance of Count to use as numerator
0068: * @param den An instance of Durationto use as denominator
0069: **/
0070: public CountRate(Count num, Duration den) {
0071: theValue = num.getValue(0) / den.getValue(0);
0072: }
0073:
0074: /** takes strings of the form "Number unit" **/
0075: public CountRate(String s) {
0076: int i = indexOfType(s);
0077: if (i < 0)
0078: throw new UnknownUnitException();
0079: double n = Double.valueOf(s.substring(0, i).trim())
0080: .doubleValue();
0081: String u = s.substring(i).trim().toLowerCase();
0082: if (u.equals("unitspersecond"))
0083: theValue = n / (1.0d / 1.0d);
0084: else if (u.equals("unitsperminute"))
0085: theValue = n / (1.0d / (1.0d / 60));
0086: else if (u.equals("unitsperhour"))
0087: theValue = n / (1.0d / (1.0d / 3600));
0088: else if (u.equals("unitsperday"))
0089: theValue = n / (1.0d / (1.0d / 86400));
0090: else if (u.equals("unitsperweek"))
0091: theValue = n / (1.0d / (1.0d / 604800));
0092: else if (u.equals("unitspermillisecond"))
0093: theValue = n / (1.0d / 1000);
0094: else if (u.equals("unitsperkilosecond"))
0095: theValue = n / (1.0d / (1.0d / 1000));
0096: else if (u.equals("unitspermonth"))
0097: theValue = n / (1.0d / (1.0d / 2629743.8));
0098: else if (u.equals("unitsperyear"))
0099: theValue = n / (1.0d / (1.0d / 31556926));
0100: else if (u.equals("unitsperfortnight"))
0101: theValue = n / (1.0d / (1.0d / 1209600));
0102: else if (u.equals("eachespersecond"))
0103: theValue = n / (1.0 / 1.0d);
0104: else if (u.equals("eachesperminute"))
0105: theValue = n / (1.0 / (1.0d / 60));
0106: else if (u.equals("eachesperhour"))
0107: theValue = n / (1.0 / (1.0d / 3600));
0108: else if (u.equals("eachesperday"))
0109: theValue = n / (1.0 / (1.0d / 86400));
0110: else if (u.equals("eachesperweek"))
0111: theValue = n / (1.0 / (1.0d / 604800));
0112: else if (u.equals("eachespermillisecond"))
0113: theValue = n / (1.0 / 1000);
0114: else if (u.equals("eachesperkilosecond"))
0115: theValue = n / (1.0 / (1.0d / 1000));
0116: else if (u.equals("eachespermonth"))
0117: theValue = n / (1.0 / (1.0d / 2629743.8));
0118: else if (u.equals("eachesperyear"))
0119: theValue = n / (1.0 / (1.0d / 31556926));
0120: else if (u.equals("eachesperfortnight"))
0121: theValue = n / (1.0 / (1.0d / 1209600));
0122: else if (u.equals("dozenpersecond"))
0123: theValue = n / ((1.0d / 12) / 1.0d);
0124: else if (u.equals("dozenperminute"))
0125: theValue = n / ((1.0d / 12) / (1.0d / 60));
0126: else if (u.equals("dozenperhour"))
0127: theValue = n / ((1.0d / 12) / (1.0d / 3600));
0128: else if (u.equals("dozenperday"))
0129: theValue = n / ((1.0d / 12) / (1.0d / 86400));
0130: else if (u.equals("dozenperweek"))
0131: theValue = n / ((1.0d / 12) / (1.0d / 604800));
0132: else if (u.equals("dozenpermillisecond"))
0133: theValue = n / ((1.0d / 12) / 1000);
0134: else if (u.equals("dozenperkilosecond"))
0135: theValue = n / ((1.0d / 12) / (1.0d / 1000));
0136: else if (u.equals("dozenpermonth"))
0137: theValue = n / ((1.0d / 12) / (1.0d / 2629743.8));
0138: else if (u.equals("dozenperyear"))
0139: theValue = n / ((1.0d / 12) / (1.0d / 31556926));
0140: else if (u.equals("dozenperfortnight"))
0141: theValue = n / ((1.0d / 12) / (1.0d / 1209600));
0142: else if (u.equals("hundredpersecond"))
0143: theValue = n / ((1.0d / 100) / 1.0d);
0144: else if (u.equals("hundredperminute"))
0145: theValue = n / ((1.0d / 100) / (1.0d / 60));
0146: else if (u.equals("hundredperhour"))
0147: theValue = n / ((1.0d / 100) / (1.0d / 3600));
0148: else if (u.equals("hundredperday"))
0149: theValue = n / ((1.0d / 100) / (1.0d / 86400));
0150: else if (u.equals("hundredperweek"))
0151: theValue = n / ((1.0d / 100) / (1.0d / 604800));
0152: else if (u.equals("hundredpermillisecond"))
0153: theValue = n / ((1.0d / 100) / 1000);
0154: else if (u.equals("hundredperkilosecond"))
0155: theValue = n / ((1.0d / 100) / (1.0d / 1000));
0156: else if (u.equals("hundredpermonth"))
0157: theValue = n / ((1.0d / 100) / (1.0d / 2629743.8));
0158: else if (u.equals("hundredperyear"))
0159: theValue = n / ((1.0d / 100) / (1.0d / 31556926));
0160: else if (u.equals("hundredperfortnight"))
0161: theValue = n / ((1.0d / 100) / (1.0d / 1209600));
0162: else if (u.equals("grosspersecond"))
0163: theValue = n / ((1.0d / 144) / 1.0d);
0164: else if (u.equals("grossperminute"))
0165: theValue = n / ((1.0d / 144) / (1.0d / 60));
0166: else if (u.equals("grossperhour"))
0167: theValue = n / ((1.0d / 144) / (1.0d / 3600));
0168: else if (u.equals("grossperday"))
0169: theValue = n / ((1.0d / 144) / (1.0d / 86400));
0170: else if (u.equals("grossperweek"))
0171: theValue = n / ((1.0d / 144) / (1.0d / 604800));
0172: else if (u.equals("grosspermillisecond"))
0173: theValue = n / ((1.0d / 144) / 1000);
0174: else if (u.equals("grossperkilosecond"))
0175: theValue = n / ((1.0d / 144) / (1.0d / 1000));
0176: else if (u.equals("grosspermonth"))
0177: theValue = n / ((1.0d / 144) / (1.0d / 2629743.8));
0178: else if (u.equals("grossperyear"))
0179: theValue = n / ((1.0d / 144) / (1.0d / 31556926));
0180: else if (u.equals("grossperfortnight"))
0181: theValue = n / ((1.0d / 144) / (1.0d / 1209600));
0182: else if (u.equals("millionpersecond"))
0183: theValue = n / ((1.0d / 1000000) / 1.0d);
0184: else if (u.equals("millionperminute"))
0185: theValue = n / ((1.0d / 1000000) / (1.0d / 60));
0186: else if (u.equals("millionperhour"))
0187: theValue = n / ((1.0d / 1000000) / (1.0d / 3600));
0188: else if (u.equals("millionperday"))
0189: theValue = n / ((1.0d / 1000000) / (1.0d / 86400));
0190: else if (u.equals("millionperweek"))
0191: theValue = n / ((1.0d / 1000000) / (1.0d / 604800));
0192: else if (u.equals("millionpermillisecond"))
0193: theValue = n / ((1.0d / 1000000) / 1000);
0194: else if (u.equals("millionperkilosecond"))
0195: theValue = n / ((1.0d / 1000000) / (1.0d / 1000));
0196: else if (u.equals("millionpermonth"))
0197: theValue = n / ((1.0d / 1000000) / (1.0d / 2629743.8));
0198: else if (u.equals("millionperyear"))
0199: theValue = n / ((1.0d / 1000000) / (1.0d / 31556926));
0200: else if (u.equals("millionperfortnight"))
0201: theValue = n / ((1.0d / 1000000) / (1.0d / 1209600));
0202: else
0203: throw new UnknownUnitException();
0204: }
0205:
0206: // TypeNamed factory methods
0207: public static final CountRate newUnitsPerSecond(double v) {
0208: return new CountRate(v * (1.0d / (1.0d / 1.0d)));
0209: }
0210:
0211: public static final CountRate newUnitsPerSecond(String s) {
0212: return new CountRate((Double.valueOf(s).doubleValue())
0213: * (1.0d / (1.0d / 1.0d)));
0214: }
0215:
0216: public static final CountRate newUnitsPerMinute(double v) {
0217: return new CountRate(v * (1.0d / (1.0d / (1.0d / 60))));
0218: }
0219:
0220: public static final CountRate newUnitsPerMinute(String s) {
0221: return new CountRate((Double.valueOf(s).doubleValue())
0222: * (1.0d / (1.0d / (1.0d / 60))));
0223: }
0224:
0225: public static final CountRate newUnitsPerHour(double v) {
0226: return new CountRate(v * (1.0d / (1.0d / (1.0d / 3600))));
0227: }
0228:
0229: public static final CountRate newUnitsPerHour(String s) {
0230: return new CountRate((Double.valueOf(s).doubleValue())
0231: * (1.0d / (1.0d / (1.0d / 3600))));
0232: }
0233:
0234: public static final CountRate newUnitsPerDay(double v) {
0235: return new CountRate(v * (1.0d / (1.0d / (1.0d / 86400))));
0236: }
0237:
0238: public static final CountRate newUnitsPerDay(String s) {
0239: return new CountRate((Double.valueOf(s).doubleValue())
0240: * (1.0d / (1.0d / (1.0d / 86400))));
0241: }
0242:
0243: public static final CountRate newUnitsPerWeek(double v) {
0244: return new CountRate(v * (1.0d / (1.0d / (1.0d / 604800))));
0245: }
0246:
0247: public static final CountRate newUnitsPerWeek(String s) {
0248: return new CountRate((Double.valueOf(s).doubleValue())
0249: * (1.0d / (1.0d / (1.0d / 604800))));
0250: }
0251:
0252: public static final CountRate newUnitsPerMillisecond(double v) {
0253: return new CountRate(v * (1.0d / (1.0d / 1000)));
0254: }
0255:
0256: public static final CountRate newUnitsPerMillisecond(String s) {
0257: return new CountRate((Double.valueOf(s).doubleValue())
0258: * (1.0d / (1.0d / 1000)));
0259: }
0260:
0261: public static final CountRate newUnitsPerKilosecond(double v) {
0262: return new CountRate(v * (1.0d / (1.0d / (1.0d / 1000))));
0263: }
0264:
0265: public static final CountRate newUnitsPerKilosecond(String s) {
0266: return new CountRate((Double.valueOf(s).doubleValue())
0267: * (1.0d / (1.0d / (1.0d / 1000))));
0268: }
0269:
0270: public static final CountRate newUnitsPerMonth(double v) {
0271: return new CountRate(v * (1.0d / (1.0d / (1.0d / 2629743.8))));
0272: }
0273:
0274: public static final CountRate newUnitsPerMonth(String s) {
0275: return new CountRate((Double.valueOf(s).doubleValue())
0276: * (1.0d / (1.0d / (1.0d / 2629743.8))));
0277: }
0278:
0279: public static final CountRate newUnitsPerYear(double v) {
0280: return new CountRate(v * (1.0d / (1.0d / (1.0d / 31556926))));
0281: }
0282:
0283: public static final CountRate newUnitsPerYear(String s) {
0284: return new CountRate((Double.valueOf(s).doubleValue())
0285: * (1.0d / (1.0d / (1.0d / 31556926))));
0286: }
0287:
0288: public static final CountRate newUnitsPerFortnight(double v) {
0289: return new CountRate(v * (1.0d / (1.0d / (1.0d / 1209600))));
0290: }
0291:
0292: public static final CountRate newUnitsPerFortnight(String s) {
0293: return new CountRate((Double.valueOf(s).doubleValue())
0294: * (1.0d / (1.0d / (1.0d / 1209600))));
0295: }
0296:
0297: public static final CountRate newEachesPerSecond(double v) {
0298: return new CountRate(v * (1.0d / (1.0 / 1.0d)));
0299: }
0300:
0301: public static final CountRate newEachesPerSecond(String s) {
0302: return new CountRate((Double.valueOf(s).doubleValue())
0303: * (1.0d / (1.0 / 1.0d)));
0304: }
0305:
0306: public static final CountRate newEachesPerMinute(double v) {
0307: return new CountRate(v * (1.0d / (1.0 / (1.0d / 60))));
0308: }
0309:
0310: public static final CountRate newEachesPerMinute(String s) {
0311: return new CountRate((Double.valueOf(s).doubleValue())
0312: * (1.0d / (1.0 / (1.0d / 60))));
0313: }
0314:
0315: public static final CountRate newEachesPerHour(double v) {
0316: return new CountRate(v * (1.0d / (1.0 / (1.0d / 3600))));
0317: }
0318:
0319: public static final CountRate newEachesPerHour(String s) {
0320: return new CountRate((Double.valueOf(s).doubleValue())
0321: * (1.0d / (1.0 / (1.0d / 3600))));
0322: }
0323:
0324: public static final CountRate newEachesPerDay(double v) {
0325: return new CountRate(v * (1.0d / (1.0 / (1.0d / 86400))));
0326: }
0327:
0328: public static final CountRate newEachesPerDay(String s) {
0329: return new CountRate((Double.valueOf(s).doubleValue())
0330: * (1.0d / (1.0 / (1.0d / 86400))));
0331: }
0332:
0333: public static final CountRate newEachesPerWeek(double v) {
0334: return new CountRate(v * (1.0d / (1.0 / (1.0d / 604800))));
0335: }
0336:
0337: public static final CountRate newEachesPerWeek(String s) {
0338: return new CountRate((Double.valueOf(s).doubleValue())
0339: * (1.0d / (1.0 / (1.0d / 604800))));
0340: }
0341:
0342: public static final CountRate newEachesPerMillisecond(double v) {
0343: return new CountRate(v * (1.0d / (1.0 / 1000)));
0344: }
0345:
0346: public static final CountRate newEachesPerMillisecond(String s) {
0347: return new CountRate((Double.valueOf(s).doubleValue())
0348: * (1.0d / (1.0 / 1000)));
0349: }
0350:
0351: public static final CountRate newEachesPerKilosecond(double v) {
0352: return new CountRate(v * (1.0d / (1.0 / (1.0d / 1000))));
0353: }
0354:
0355: public static final CountRate newEachesPerKilosecond(String s) {
0356: return new CountRate((Double.valueOf(s).doubleValue())
0357: * (1.0d / (1.0 / (1.0d / 1000))));
0358: }
0359:
0360: public static final CountRate newEachesPerMonth(double v) {
0361: return new CountRate(v * (1.0d / (1.0 / (1.0d / 2629743.8))));
0362: }
0363:
0364: public static final CountRate newEachesPerMonth(String s) {
0365: return new CountRate((Double.valueOf(s).doubleValue())
0366: * (1.0d / (1.0 / (1.0d / 2629743.8))));
0367: }
0368:
0369: public static final CountRate newEachesPerYear(double v) {
0370: return new CountRate(v * (1.0d / (1.0 / (1.0d / 31556926))));
0371: }
0372:
0373: public static final CountRate newEachesPerYear(String s) {
0374: return new CountRate((Double.valueOf(s).doubleValue())
0375: * (1.0d / (1.0 / (1.0d / 31556926))));
0376: }
0377:
0378: public static final CountRate newEachesPerFortnight(double v) {
0379: return new CountRate(v * (1.0d / (1.0 / (1.0d / 1209600))));
0380: }
0381:
0382: public static final CountRate newEachesPerFortnight(String s) {
0383: return new CountRate((Double.valueOf(s).doubleValue())
0384: * (1.0d / (1.0 / (1.0d / 1209600))));
0385: }
0386:
0387: public static final CountRate newDozenPerSecond(double v) {
0388: return new CountRate(v * (1.0d / ((1.0d / 12) / 1.0d)));
0389: }
0390:
0391: public static final CountRate newDozenPerSecond(String s) {
0392: return new CountRate((Double.valueOf(s).doubleValue())
0393: * (1.0d / ((1.0d / 12) / 1.0d)));
0394: }
0395:
0396: public static final CountRate newDozenPerMinute(double v) {
0397: return new CountRate(v * (1.0d / ((1.0d / 12) / (1.0d / 60))));
0398: }
0399:
0400: public static final CountRate newDozenPerMinute(String s) {
0401: return new CountRate((Double.valueOf(s).doubleValue())
0402: * (1.0d / ((1.0d / 12) / (1.0d / 60))));
0403: }
0404:
0405: public static final CountRate newDozenPerHour(double v) {
0406: return new CountRate(v * (1.0d / ((1.0d / 12) / (1.0d / 3600))));
0407: }
0408:
0409: public static final CountRate newDozenPerHour(String s) {
0410: return new CountRate((Double.valueOf(s).doubleValue())
0411: * (1.0d / ((1.0d / 12) / (1.0d / 3600))));
0412: }
0413:
0414: public static final CountRate newDozenPerDay(double v) {
0415: return new CountRate(v
0416: * (1.0d / ((1.0d / 12) / (1.0d / 86400))));
0417: }
0418:
0419: public static final CountRate newDozenPerDay(String s) {
0420: return new CountRate((Double.valueOf(s).doubleValue())
0421: * (1.0d / ((1.0d / 12) / (1.0d / 86400))));
0422: }
0423:
0424: public static final CountRate newDozenPerWeek(double v) {
0425: return new CountRate(v
0426: * (1.0d / ((1.0d / 12) / (1.0d / 604800))));
0427: }
0428:
0429: public static final CountRate newDozenPerWeek(String s) {
0430: return new CountRate((Double.valueOf(s).doubleValue())
0431: * (1.0d / ((1.0d / 12) / (1.0d / 604800))));
0432: }
0433:
0434: public static final CountRate newDozenPerMillisecond(double v) {
0435: return new CountRate(v * (1.0d / ((1.0d / 12) / 1000)));
0436: }
0437:
0438: public static final CountRate newDozenPerMillisecond(String s) {
0439: return new CountRate((Double.valueOf(s).doubleValue())
0440: * (1.0d / ((1.0d / 12) / 1000)));
0441: }
0442:
0443: public static final CountRate newDozenPerKilosecond(double v) {
0444: return new CountRate(v * (1.0d / ((1.0d / 12) / (1.0d / 1000))));
0445: }
0446:
0447: public static final CountRate newDozenPerKilosecond(String s) {
0448: return new CountRate((Double.valueOf(s).doubleValue())
0449: * (1.0d / ((1.0d / 12) / (1.0d / 1000))));
0450: }
0451:
0452: public static final CountRate newDozenPerMonth(double v) {
0453: return new CountRate(v
0454: * (1.0d / ((1.0d / 12) / (1.0d / 2629743.8))));
0455: }
0456:
0457: public static final CountRate newDozenPerMonth(String s) {
0458: return new CountRate((Double.valueOf(s).doubleValue())
0459: * (1.0d / ((1.0d / 12) / (1.0d / 2629743.8))));
0460: }
0461:
0462: public static final CountRate newDozenPerYear(double v) {
0463: return new CountRate(v
0464: * (1.0d / ((1.0d / 12) / (1.0d / 31556926))));
0465: }
0466:
0467: public static final CountRate newDozenPerYear(String s) {
0468: return new CountRate((Double.valueOf(s).doubleValue())
0469: * (1.0d / ((1.0d / 12) / (1.0d / 31556926))));
0470: }
0471:
0472: public static final CountRate newDozenPerFortnight(double v) {
0473: return new CountRate(v
0474: * (1.0d / ((1.0d / 12) / (1.0d / 1209600))));
0475: }
0476:
0477: public static final CountRate newDozenPerFortnight(String s) {
0478: return new CountRate((Double.valueOf(s).doubleValue())
0479: * (1.0d / ((1.0d / 12) / (1.0d / 1209600))));
0480: }
0481:
0482: public static final CountRate newHundredPerSecond(double v) {
0483: return new CountRate(v * (1.0d / ((1.0d / 100) / 1.0d)));
0484: }
0485:
0486: public static final CountRate newHundredPerSecond(String s) {
0487: return new CountRate((Double.valueOf(s).doubleValue())
0488: * (1.0d / ((1.0d / 100) / 1.0d)));
0489: }
0490:
0491: public static final CountRate newHundredPerMinute(double v) {
0492: return new CountRate(v * (1.0d / ((1.0d / 100) / (1.0d / 60))));
0493: }
0494:
0495: public static final CountRate newHundredPerMinute(String s) {
0496: return new CountRate((Double.valueOf(s).doubleValue())
0497: * (1.0d / ((1.0d / 100) / (1.0d / 60))));
0498: }
0499:
0500: public static final CountRate newHundredPerHour(double v) {
0501: return new CountRate(v
0502: * (1.0d / ((1.0d / 100) / (1.0d / 3600))));
0503: }
0504:
0505: public static final CountRate newHundredPerHour(String s) {
0506: return new CountRate((Double.valueOf(s).doubleValue())
0507: * (1.0d / ((1.0d / 100) / (1.0d / 3600))));
0508: }
0509:
0510: public static final CountRate newHundredPerDay(double v) {
0511: return new CountRate(v
0512: * (1.0d / ((1.0d / 100) / (1.0d / 86400))));
0513: }
0514:
0515: public static final CountRate newHundredPerDay(String s) {
0516: return new CountRate((Double.valueOf(s).doubleValue())
0517: * (1.0d / ((1.0d / 100) / (1.0d / 86400))));
0518: }
0519:
0520: public static final CountRate newHundredPerWeek(double v) {
0521: return new CountRate(v
0522: * (1.0d / ((1.0d / 100) / (1.0d / 604800))));
0523: }
0524:
0525: public static final CountRate newHundredPerWeek(String s) {
0526: return new CountRate((Double.valueOf(s).doubleValue())
0527: * (1.0d / ((1.0d / 100) / (1.0d / 604800))));
0528: }
0529:
0530: public static final CountRate newHundredPerMillisecond(double v) {
0531: return new CountRate(v * (1.0d / ((1.0d / 100) / 1000)));
0532: }
0533:
0534: public static final CountRate newHundredPerMillisecond(String s) {
0535: return new CountRate((Double.valueOf(s).doubleValue())
0536: * (1.0d / ((1.0d / 100) / 1000)));
0537: }
0538:
0539: public static final CountRate newHundredPerKilosecond(double v) {
0540: return new CountRate(v
0541: * (1.0d / ((1.0d / 100) / (1.0d / 1000))));
0542: }
0543:
0544: public static final CountRate newHundredPerKilosecond(String s) {
0545: return new CountRate((Double.valueOf(s).doubleValue())
0546: * (1.0d / ((1.0d / 100) / (1.0d / 1000))));
0547: }
0548:
0549: public static final CountRate newHundredPerMonth(double v) {
0550: return new CountRate(v
0551: * (1.0d / ((1.0d / 100) / (1.0d / 2629743.8))));
0552: }
0553:
0554: public static final CountRate newHundredPerMonth(String s) {
0555: return new CountRate((Double.valueOf(s).doubleValue())
0556: * (1.0d / ((1.0d / 100) / (1.0d / 2629743.8))));
0557: }
0558:
0559: public static final CountRate newHundredPerYear(double v) {
0560: return new CountRate(v
0561: * (1.0d / ((1.0d / 100) / (1.0d / 31556926))));
0562: }
0563:
0564: public static final CountRate newHundredPerYear(String s) {
0565: return new CountRate((Double.valueOf(s).doubleValue())
0566: * (1.0d / ((1.0d / 100) / (1.0d / 31556926))));
0567: }
0568:
0569: public static final CountRate newHundredPerFortnight(double v) {
0570: return new CountRate(v
0571: * (1.0d / ((1.0d / 100) / (1.0d / 1209600))));
0572: }
0573:
0574: public static final CountRate newHundredPerFortnight(String s) {
0575: return new CountRate((Double.valueOf(s).doubleValue())
0576: * (1.0d / ((1.0d / 100) / (1.0d / 1209600))));
0577: }
0578:
0579: public static final CountRate newGrossPerSecond(double v) {
0580: return new CountRate(v * (1.0d / ((1.0d / 144) / 1.0d)));
0581: }
0582:
0583: public static final CountRate newGrossPerSecond(String s) {
0584: return new CountRate((Double.valueOf(s).doubleValue())
0585: * (1.0d / ((1.0d / 144) / 1.0d)));
0586: }
0587:
0588: public static final CountRate newGrossPerMinute(double v) {
0589: return new CountRate(v * (1.0d / ((1.0d / 144) / (1.0d / 60))));
0590: }
0591:
0592: public static final CountRate newGrossPerMinute(String s) {
0593: return new CountRate((Double.valueOf(s).doubleValue())
0594: * (1.0d / ((1.0d / 144) / (1.0d / 60))));
0595: }
0596:
0597: public static final CountRate newGrossPerHour(double v) {
0598: return new CountRate(v
0599: * (1.0d / ((1.0d / 144) / (1.0d / 3600))));
0600: }
0601:
0602: public static final CountRate newGrossPerHour(String s) {
0603: return new CountRate((Double.valueOf(s).doubleValue())
0604: * (1.0d / ((1.0d / 144) / (1.0d / 3600))));
0605: }
0606:
0607: public static final CountRate newGrossPerDay(double v) {
0608: return new CountRate(v
0609: * (1.0d / ((1.0d / 144) / (1.0d / 86400))));
0610: }
0611:
0612: public static final CountRate newGrossPerDay(String s) {
0613: return new CountRate((Double.valueOf(s).doubleValue())
0614: * (1.0d / ((1.0d / 144) / (1.0d / 86400))));
0615: }
0616:
0617: public static final CountRate newGrossPerWeek(double v) {
0618: return new CountRate(v
0619: * (1.0d / ((1.0d / 144) / (1.0d / 604800))));
0620: }
0621:
0622: public static final CountRate newGrossPerWeek(String s) {
0623: return new CountRate((Double.valueOf(s).doubleValue())
0624: * (1.0d / ((1.0d / 144) / (1.0d / 604800))));
0625: }
0626:
0627: public static final CountRate newGrossPerMillisecond(double v) {
0628: return new CountRate(v * (1.0d / ((1.0d / 144) / 1000)));
0629: }
0630:
0631: public static final CountRate newGrossPerMillisecond(String s) {
0632: return new CountRate((Double.valueOf(s).doubleValue())
0633: * (1.0d / ((1.0d / 144) / 1000)));
0634: }
0635:
0636: public static final CountRate newGrossPerKilosecond(double v) {
0637: return new CountRate(v
0638: * (1.0d / ((1.0d / 144) / (1.0d / 1000))));
0639: }
0640:
0641: public static final CountRate newGrossPerKilosecond(String s) {
0642: return new CountRate((Double.valueOf(s).doubleValue())
0643: * (1.0d / ((1.0d / 144) / (1.0d / 1000))));
0644: }
0645:
0646: public static final CountRate newGrossPerMonth(double v) {
0647: return new CountRate(v
0648: * (1.0d / ((1.0d / 144) / (1.0d / 2629743.8))));
0649: }
0650:
0651: public static final CountRate newGrossPerMonth(String s) {
0652: return new CountRate((Double.valueOf(s).doubleValue())
0653: * (1.0d / ((1.0d / 144) / (1.0d / 2629743.8))));
0654: }
0655:
0656: public static final CountRate newGrossPerYear(double v) {
0657: return new CountRate(v
0658: * (1.0d / ((1.0d / 144) / (1.0d / 31556926))));
0659: }
0660:
0661: public static final CountRate newGrossPerYear(String s) {
0662: return new CountRate((Double.valueOf(s).doubleValue())
0663: * (1.0d / ((1.0d / 144) / (1.0d / 31556926))));
0664: }
0665:
0666: public static final CountRate newGrossPerFortnight(double v) {
0667: return new CountRate(v
0668: * (1.0d / ((1.0d / 144) / (1.0d / 1209600))));
0669: }
0670:
0671: public static final CountRate newGrossPerFortnight(String s) {
0672: return new CountRate((Double.valueOf(s).doubleValue())
0673: * (1.0d / ((1.0d / 144) / (1.0d / 1209600))));
0674: }
0675:
0676: public static final CountRate newMillionPerSecond(double v) {
0677: return new CountRate(v * (1.0d / ((1.0d / 1000000) / 1.0d)));
0678: }
0679:
0680: public static final CountRate newMillionPerSecond(String s) {
0681: return new CountRate((Double.valueOf(s).doubleValue())
0682: * (1.0d / ((1.0d / 1000000) / 1.0d)));
0683: }
0684:
0685: public static final CountRate newMillionPerMinute(double v) {
0686: return new CountRate(v
0687: * (1.0d / ((1.0d / 1000000) / (1.0d / 60))));
0688: }
0689:
0690: public static final CountRate newMillionPerMinute(String s) {
0691: return new CountRate((Double.valueOf(s).doubleValue())
0692: * (1.0d / ((1.0d / 1000000) / (1.0d / 60))));
0693: }
0694:
0695: public static final CountRate newMillionPerHour(double v) {
0696: return new CountRate(v
0697: * (1.0d / ((1.0d / 1000000) / (1.0d / 3600))));
0698: }
0699:
0700: public static final CountRate newMillionPerHour(String s) {
0701: return new CountRate((Double.valueOf(s).doubleValue())
0702: * (1.0d / ((1.0d / 1000000) / (1.0d / 3600))));
0703: }
0704:
0705: public static final CountRate newMillionPerDay(double v) {
0706: return new CountRate(v
0707: * (1.0d / ((1.0d / 1000000) / (1.0d / 86400))));
0708: }
0709:
0710: public static final CountRate newMillionPerDay(String s) {
0711: return new CountRate((Double.valueOf(s).doubleValue())
0712: * (1.0d / ((1.0d / 1000000) / (1.0d / 86400))));
0713: }
0714:
0715: public static final CountRate newMillionPerWeek(double v) {
0716: return new CountRate(v
0717: * (1.0d / ((1.0d / 1000000) / (1.0d / 604800))));
0718: }
0719:
0720: public static final CountRate newMillionPerWeek(String s) {
0721: return new CountRate((Double.valueOf(s).doubleValue())
0722: * (1.0d / ((1.0d / 1000000) / (1.0d / 604800))));
0723: }
0724:
0725: public static final CountRate newMillionPerMillisecond(double v) {
0726: return new CountRate(v * (1.0d / ((1.0d / 1000000) / 1000)));
0727: }
0728:
0729: public static final CountRate newMillionPerMillisecond(String s) {
0730: return new CountRate((Double.valueOf(s).doubleValue())
0731: * (1.0d / ((1.0d / 1000000) / 1000)));
0732: }
0733:
0734: public static final CountRate newMillionPerKilosecond(double v) {
0735: return new CountRate(v
0736: * (1.0d / ((1.0d / 1000000) / (1.0d / 1000))));
0737: }
0738:
0739: public static final CountRate newMillionPerKilosecond(String s) {
0740: return new CountRate((Double.valueOf(s).doubleValue())
0741: * (1.0d / ((1.0d / 1000000) / (1.0d / 1000))));
0742: }
0743:
0744: public static final CountRate newMillionPerMonth(double v) {
0745: return new CountRate(v
0746: * (1.0d / ((1.0d / 1000000) / (1.0d / 2629743.8))));
0747: }
0748:
0749: public static final CountRate newMillionPerMonth(String s) {
0750: return new CountRate((Double.valueOf(s).doubleValue())
0751: * (1.0d / ((1.0d / 1000000) / (1.0d / 2629743.8))));
0752: }
0753:
0754: public static final CountRate newMillionPerYear(double v) {
0755: return new CountRate(v
0756: * (1.0d / ((1.0d / 1000000) / (1.0d / 31556926))));
0757: }
0758:
0759: public static final CountRate newMillionPerYear(String s) {
0760: return new CountRate((Double.valueOf(s).doubleValue())
0761: * (1.0d / ((1.0d / 1000000) / (1.0d / 31556926))));
0762: }
0763:
0764: public static final CountRate newMillionPerFortnight(double v) {
0765: return new CountRate(v
0766: * (1.0d / ((1.0d / 1000000) / (1.0d / 1209600))));
0767: }
0768:
0769: public static final CountRate newMillionPerFortnight(String s) {
0770: return new CountRate((Double.valueOf(s).doubleValue())
0771: * (1.0d / ((1.0d / 1000000) / (1.0d / 1209600))));
0772: }
0773:
0774: public int getCommonUnit() {
0775: return 0;
0776: }
0777:
0778: public int getMaxUnit() {
0779: return MAXUNIT;
0780: }
0781:
0782: // unit names for getUnitName
0783: private static final String unitNames[] = { "units/second",
0784: "units/minute", "units/hour", "units/day", "units/week",
0785: "units/millisecond", "units/kilosecond", "units/month",
0786: "units/year", "units/fortnight", "eaches/second",
0787: "eaches/minute", "eaches/hour", "eaches/day",
0788: "eaches/week", "eaches/millisecond", "eaches/kilosecond",
0789: "eaches/month", "eaches/year", "eaches/fortnight",
0790: "dozen/second", "dozen/minute", "dozen/hour", "dozen/day",
0791: "dozen/week", "dozen/millisecond", "dozen/kilosecond",
0792: "dozen/month", "dozen/year", "dozen/fortnight",
0793: "hundred/second", "hundred/minute", "hundred/hour",
0794: "hundred/day", "hundred/week", "hundred/millisecond",
0795: "hundred/kilosecond", "hundred/month", "hundred/year",
0796: "hundred/fortnight", "gross/second", "gross/minute",
0797: "gross/hour", "gross/day", "gross/week",
0798: "gross/millisecond", "gross/kilosecond", "gross/month",
0799: "gross/year", "gross/fortnight", "million/second",
0800: "million/minute", "million/hour", "million/day",
0801: "million/week", "million/millisecond",
0802: "million/kilosecond", "million/month", "million/year",
0803: "million/fortnight", };
0804:
0805: /** @param unit One of the constant units of CountRate **/
0806: public final String getUnitName(int unit) {
0807: return unitNames[unit];
0808: }
0809:
0810: // Index Typed factory methods
0811: static final double convFactor[] = { (1.0d / 1.0d),
0812: (1.0d / (1.0d / 60)), (1.0d / (1.0d / 3600)),
0813: (1.0d / (1.0d / 86400)), (1.0d / (1.0d / 604800)),
0814: (1.0d / 1000), (1.0d / (1.0d / 1000)),
0815: (1.0d / (1.0d / 2629743.8)), (1.0d / (1.0d / 31556926)),
0816: (1.0d / (1.0d / 1209600)), (1.0 / 1.0d),
0817: (1.0 / (1.0d / 60)), (1.0 / (1.0d / 3600)),
0818: (1.0 / (1.0d / 86400)), (1.0 / (1.0d / 604800)),
0819: (1.0 / 1000), (1.0 / (1.0d / 1000)),
0820: (1.0 / (1.0d / 2629743.8)), (1.0 / (1.0d / 31556926)),
0821: (1.0 / (1.0d / 1209600)), ((1.0d / 12) / 1.0d),
0822: ((1.0d / 12) / (1.0d / 60)), ((1.0d / 12) / (1.0d / 3600)),
0823: ((1.0d / 12) / (1.0d / 86400)),
0824: ((1.0d / 12) / (1.0d / 604800)), ((1.0d / 12) / 1000),
0825: ((1.0d / 12) / (1.0d / 1000)),
0826: ((1.0d / 12) / (1.0d / 2629743.8)),
0827: ((1.0d / 12) / (1.0d / 31556926)),
0828: ((1.0d / 12) / (1.0d / 1209600)), ((1.0d / 100) / 1.0d),
0829: ((1.0d / 100) / (1.0d / 60)),
0830: ((1.0d / 100) / (1.0d / 3600)),
0831: ((1.0d / 100) / (1.0d / 86400)),
0832: ((1.0d / 100) / (1.0d / 604800)), ((1.0d / 100) / 1000),
0833: ((1.0d / 100) / (1.0d / 1000)),
0834: ((1.0d / 100) / (1.0d / 2629743.8)),
0835: ((1.0d / 100) / (1.0d / 31556926)),
0836: ((1.0d / 100) / (1.0d / 1209600)), ((1.0d / 144) / 1.0d),
0837: ((1.0d / 144) / (1.0d / 60)),
0838: ((1.0d / 144) / (1.0d / 3600)),
0839: ((1.0d / 144) / (1.0d / 86400)),
0840: ((1.0d / 144) / (1.0d / 604800)), ((1.0d / 144) / 1000),
0841: ((1.0d / 144) / (1.0d / 1000)),
0842: ((1.0d / 144) / (1.0d / 2629743.8)),
0843: ((1.0d / 144) / (1.0d / 31556926)),
0844: ((1.0d / 144) / (1.0d / 1209600)),
0845: ((1.0d / 1000000) / 1.0d),
0846: ((1.0d / 1000000) / (1.0d / 60)),
0847: ((1.0d / 1000000) / (1.0d / 3600)),
0848: ((1.0d / 1000000) / (1.0d / 86400)),
0849: ((1.0d / 1000000) / (1.0d / 604800)),
0850: ((1.0d / 1000000) / 1000),
0851: ((1.0d / 1000000) / (1.0d / 1000)),
0852: ((1.0d / 1000000) / (1.0d / 2629743.8)),
0853: ((1.0d / 1000000) / (1.0d / 31556926)),
0854: ((1.0d / 1000000) / (1.0d / 1209600)), };
0855:
0856: public static final double getConvFactor(int i) {
0857: return convFactor[i];
0858: }
0859:
0860: // indexes into factor array
0861: public static final int UNITS_PER_SECOND = 0;
0862: public static final int UNITS_PER_MINUTE = 1;
0863: public static final int UNITS_PER_HOUR = 2;
0864: public static final int UNITS_PER_DAY = 3;
0865: public static final int UNITS_PER_WEEK = 4;
0866: public static final int UNITS_PER_MILLISECOND = 5;
0867: public static final int UNITS_PER_KILOSECOND = 6;
0868: public static final int UNITS_PER_MONTH = 7;
0869: public static final int UNITS_PER_YEAR = 8;
0870: public static final int UNITS_PER_FORTNIGHT = 9;
0871: public static final int EACHES_PER_SECOND = 10;
0872: public static final int EACHES_PER_MINUTE = 11;
0873: public static final int EACHES_PER_HOUR = 12;
0874: public static final int EACHES_PER_DAY = 13;
0875: public static final int EACHES_PER_WEEK = 14;
0876: public static final int EACHES_PER_MILLISECOND = 15;
0877: public static final int EACHES_PER_KILOSECOND = 16;
0878: public static final int EACHES_PER_MONTH = 17;
0879: public static final int EACHES_PER_YEAR = 18;
0880: public static final int EACHES_PER_FORTNIGHT = 19;
0881: public static final int DOZEN_PER_SECOND = 20;
0882: public static final int DOZEN_PER_MINUTE = 21;
0883: public static final int DOZEN_PER_HOUR = 22;
0884: public static final int DOZEN_PER_DAY = 23;
0885: public static final int DOZEN_PER_WEEK = 24;
0886: public static final int DOZEN_PER_MILLISECOND = 25;
0887: public static final int DOZEN_PER_KILOSECOND = 26;
0888: public static final int DOZEN_PER_MONTH = 27;
0889: public static final int DOZEN_PER_YEAR = 28;
0890: public static final int DOZEN_PER_FORTNIGHT = 29;
0891: public static final int HUNDRED_PER_SECOND = 30;
0892: public static final int HUNDRED_PER_MINUTE = 31;
0893: public static final int HUNDRED_PER_HOUR = 32;
0894: public static final int HUNDRED_PER_DAY = 33;
0895: public static final int HUNDRED_PER_WEEK = 34;
0896: public static final int HUNDRED_PER_MILLISECOND = 35;
0897: public static final int HUNDRED_PER_KILOSECOND = 36;
0898: public static final int HUNDRED_PER_MONTH = 37;
0899: public static final int HUNDRED_PER_YEAR = 38;
0900: public static final int HUNDRED_PER_FORTNIGHT = 39;
0901: public static final int GROSS_PER_SECOND = 40;
0902: public static final int GROSS_PER_MINUTE = 41;
0903: public static final int GROSS_PER_HOUR = 42;
0904: public static final int GROSS_PER_DAY = 43;
0905: public static final int GROSS_PER_WEEK = 44;
0906: public static final int GROSS_PER_MILLISECOND = 45;
0907: public static final int GROSS_PER_KILOSECOND = 46;
0908: public static final int GROSS_PER_MONTH = 47;
0909: public static final int GROSS_PER_YEAR = 48;
0910: public static final int GROSS_PER_FORTNIGHT = 49;
0911: public static final int MILLION_PER_SECOND = 50;
0912: public static final int MILLION_PER_MINUTE = 51;
0913: public static final int MILLION_PER_HOUR = 52;
0914: public static final int MILLION_PER_DAY = 53;
0915: public static final int MILLION_PER_WEEK = 54;
0916: public static final int MILLION_PER_MILLISECOND = 55;
0917: public static final int MILLION_PER_KILOSECOND = 56;
0918: public static final int MILLION_PER_MONTH = 57;
0919: public static final int MILLION_PER_YEAR = 58;
0920: public static final int MILLION_PER_FORTNIGHT = 59;
0921: static final int MAXUNIT = 59;
0922:
0923: // Index Typed factory methods
0924: /** @param unit One of the constant units of CountRate **/
0925: public static final CountRate newCountRate(double v, int unit) {
0926: if (unit >= 0 && unit <= MAXUNIT)
0927: return new CountRate(v * getConvFactor(unit));
0928: else
0929: throw new UnknownUnitException();
0930: }
0931:
0932: /** @param unit One of the constant units of CountRate **/
0933: public static final CountRate newCountRate(String s, int unit) {
0934: if (unit >= 0 && unit <= MAXUNIT)
0935: return new CountRate((Double.valueOf(s).doubleValue())
0936: * getConvFactor(unit));
0937: else
0938: throw new UnknownUnitException();
0939: }
0940:
0941: // Index Typed factory methods
0942: /** @param unit1 One of the constant units of Count
0943: * @param unit2 One of the constant units of Duration
0944: **/
0945: public static final CountRate newCountRate(double v, int unit1,
0946: int unit2) {
0947: if (unit1 >= 0 && unit1 <= Count.MAXUNIT && unit2 >= 0
0948: && unit2 <= Duration.MAXUNIT)
0949: return new CountRate(v * Count.getConvFactor(unit1)
0950: / Duration.getConvFactor(unit2));
0951: else
0952: throw new UnknownUnitException();
0953: }
0954:
0955: /** @param num An instance of Count to use as numerator
0956: * @param den An instance of Durationto use as denominator
0957: **/
0958: public static final CountRate newCountRate(Count num, Duration den) {
0959: return new CountRate(num.getValue(0) / den.getValue(0));
0960: }
0961:
0962: /** @param unit1 One of the constant units of Count
0963: * @param unit2 One of the constant units of Duration
0964: **/
0965: public static final CountRate newCountRate(String s, int unit1,
0966: int unit2) {
0967: if (unit1 >= 0 && unit1 <= Count.MAXUNIT && unit2 >= 0
0968: && unit2 <= Duration.MAXUNIT)
0969: return new CountRate((Double.valueOf(s).doubleValue())
0970: * Count.getConvFactor(unit1)
0971: / Duration.getConvFactor(unit2));
0972: else
0973: throw new UnknownUnitException();
0974: }
0975:
0976: // Support for AbstractMeasure-level constructor
0977: public static final AbstractMeasure newMeasure(String s, int unit) {
0978: return newCountRate(s, unit);
0979: }
0980:
0981: public static final AbstractMeasure newMeasure(double v, int unit) {
0982: return newCountRate(v, unit);
0983: }
0984:
0985: // simple math : addition and subtraction
0986: public final Measure add(Measure toAdd) {
0987: if (!(toAdd instanceof CountRate))
0988: throw new IllegalArgumentException();
0989: return new CountRate(theValue + toAdd.getNativeValue());
0990: }
0991:
0992: public final Measure subtract(Measure toSubtract) {
0993: if (!(toSubtract instanceof CountRate))
0994: throw new IllegalArgumentException();
0995: return new CountRate(theValue - toSubtract.getNativeValue());
0996: }
0997:
0998: public final Measure scale(double scale) {
0999: return new CountRate(theValue * scale, 0);
1000: }
1001:
1002: public final Measure negate() {
1003: return newCountRate(-1 * theValue, 0);
1004: }
1005:
1006: public final Measure floor(int unit) {
1007: return newCountRate(Math.floor(getValue(unit)), 0);
1008: }
1009:
1010: public final Measure valueOf(double value) {
1011: return new CountRate(value);
1012: }
1013:
1014: public final Measure valueOf(double value, int unit) {
1015: return new CountRate(value, unit);
1016: }
1017:
1018: public final double getNativeValue() {
1019: return theValue;
1020: }
1021:
1022: public final int getNativeUnit() {
1023: return 0;
1024: }
1025:
1026: public final Duration divide(Rate toRate) {
1027: throw new IllegalArgumentException(
1028: "Call divideRate instead to divide one Rate by another.");
1029: }
1030:
1031: public final double divideRate(Rate toRate) {
1032: if (toRate.getCanonicalNumerator().getClass() != getCanonicalNumerator()
1033: .getClass()
1034: || toRate.getCanonicalDenominator().getClass() != getCanonicalDenominator()
1035: .getClass()) {
1036: throw new IllegalArgumentException("Expecting a CountRate"
1037: + ", got a "
1038: + toRate.getCanonicalNumerator().getClass() + "/"
1039: + toRate.getCanonicalDenominator().getClass());
1040: }
1041: return theValue / toRate.getNativeValue();
1042: }
1043:
1044: // Unit-based Reader methods
1045: public double getUnitsPerSecond() {
1046: return (theValue * (1.0d / 1.0d));
1047: }
1048:
1049: public double getUnitsPerMinute() {
1050: return (theValue * (1.0d / (1.0d / 60)));
1051: }
1052:
1053: public double getUnitsPerHour() {
1054: return (theValue * (1.0d / (1.0d / 3600)));
1055: }
1056:
1057: public double getUnitsPerDay() {
1058: return (theValue * (1.0d / (1.0d / 86400)));
1059: }
1060:
1061: public double getUnitsPerWeek() {
1062: return (theValue * (1.0d / (1.0d / 604800)));
1063: }
1064:
1065: public double getUnitsPerMillisecond() {
1066: return (theValue * (1.0d / 1000));
1067: }
1068:
1069: public double getUnitsPerKilosecond() {
1070: return (theValue * (1.0d / (1.0d / 1000)));
1071: }
1072:
1073: public double getUnitsPerMonth() {
1074: return (theValue * (1.0d / (1.0d / 2629743.8)));
1075: }
1076:
1077: public double getUnitsPerYear() {
1078: return (theValue * (1.0d / (1.0d / 31556926)));
1079: }
1080:
1081: public double getUnitsPerFortnight() {
1082: return (theValue * (1.0d / (1.0d / 1209600)));
1083: }
1084:
1085: public double getEachesPerSecond() {
1086: return (theValue * (1.0 / 1.0d));
1087: }
1088:
1089: public double getEachesPerMinute() {
1090: return (theValue * (1.0 / (1.0d / 60)));
1091: }
1092:
1093: public double getEachesPerHour() {
1094: return (theValue * (1.0 / (1.0d / 3600)));
1095: }
1096:
1097: public double getEachesPerDay() {
1098: return (theValue * (1.0 / (1.0d / 86400)));
1099: }
1100:
1101: public double getEachesPerWeek() {
1102: return (theValue * (1.0 / (1.0d / 604800)));
1103: }
1104:
1105: public double getEachesPerMillisecond() {
1106: return (theValue * (1.0 / 1000));
1107: }
1108:
1109: public double getEachesPerKilosecond() {
1110: return (theValue * (1.0 / (1.0d / 1000)));
1111: }
1112:
1113: public double getEachesPerMonth() {
1114: return (theValue * (1.0 / (1.0d / 2629743.8)));
1115: }
1116:
1117: public double getEachesPerYear() {
1118: return (theValue * (1.0 / (1.0d / 31556926)));
1119: }
1120:
1121: public double getEachesPerFortnight() {
1122: return (theValue * (1.0 / (1.0d / 1209600)));
1123: }
1124:
1125: public double getDozenPerSecond() {
1126: return (theValue * ((1.0d / 12) / 1.0d));
1127: }
1128:
1129: public double getDozenPerMinute() {
1130: return (theValue * ((1.0d / 12) / (1.0d / 60)));
1131: }
1132:
1133: public double getDozenPerHour() {
1134: return (theValue * ((1.0d / 12) / (1.0d / 3600)));
1135: }
1136:
1137: public double getDozenPerDay() {
1138: return (theValue * ((1.0d / 12) / (1.0d / 86400)));
1139: }
1140:
1141: public double getDozenPerWeek() {
1142: return (theValue * ((1.0d / 12) / (1.0d / 604800)));
1143: }
1144:
1145: public double getDozenPerMillisecond() {
1146: return (theValue * ((1.0d / 12) / 1000));
1147: }
1148:
1149: public double getDozenPerKilosecond() {
1150: return (theValue * ((1.0d / 12) / (1.0d / 1000)));
1151: }
1152:
1153: public double getDozenPerMonth() {
1154: return (theValue * ((1.0d / 12) / (1.0d / 2629743.8)));
1155: }
1156:
1157: public double getDozenPerYear() {
1158: return (theValue * ((1.0d / 12) / (1.0d / 31556926)));
1159: }
1160:
1161: public double getDozenPerFortnight() {
1162: return (theValue * ((1.0d / 12) / (1.0d / 1209600)));
1163: }
1164:
1165: public double getHundredPerSecond() {
1166: return (theValue * ((1.0d / 100) / 1.0d));
1167: }
1168:
1169: public double getHundredPerMinute() {
1170: return (theValue * ((1.0d / 100) / (1.0d / 60)));
1171: }
1172:
1173: public double getHundredPerHour() {
1174: return (theValue * ((1.0d / 100) / (1.0d / 3600)));
1175: }
1176:
1177: public double getHundredPerDay() {
1178: return (theValue * ((1.0d / 100) / (1.0d / 86400)));
1179: }
1180:
1181: public double getHundredPerWeek() {
1182: return (theValue * ((1.0d / 100) / (1.0d / 604800)));
1183: }
1184:
1185: public double getHundredPerMillisecond() {
1186: return (theValue * ((1.0d / 100) / 1000));
1187: }
1188:
1189: public double getHundredPerKilosecond() {
1190: return (theValue * ((1.0d / 100) / (1.0d / 1000)));
1191: }
1192:
1193: public double getHundredPerMonth() {
1194: return (theValue * ((1.0d / 100) / (1.0d / 2629743.8)));
1195: }
1196:
1197: public double getHundredPerYear() {
1198: return (theValue * ((1.0d / 100) / (1.0d / 31556926)));
1199: }
1200:
1201: public double getHundredPerFortnight() {
1202: return (theValue * ((1.0d / 100) / (1.0d / 1209600)));
1203: }
1204:
1205: public double getGrossPerSecond() {
1206: return (theValue * ((1.0d / 144) / 1.0d));
1207: }
1208:
1209: public double getGrossPerMinute() {
1210: return (theValue * ((1.0d / 144) / (1.0d / 60)));
1211: }
1212:
1213: public double getGrossPerHour() {
1214: return (theValue * ((1.0d / 144) / (1.0d / 3600)));
1215: }
1216:
1217: public double getGrossPerDay() {
1218: return (theValue * ((1.0d / 144) / (1.0d / 86400)));
1219: }
1220:
1221: public double getGrossPerWeek() {
1222: return (theValue * ((1.0d / 144) / (1.0d / 604800)));
1223: }
1224:
1225: public double getGrossPerMillisecond() {
1226: return (theValue * ((1.0d / 144) / 1000));
1227: }
1228:
1229: public double getGrossPerKilosecond() {
1230: return (theValue * ((1.0d / 144) / (1.0d / 1000)));
1231: }
1232:
1233: public double getGrossPerMonth() {
1234: return (theValue * ((1.0d / 144) / (1.0d / 2629743.8)));
1235: }
1236:
1237: public double getGrossPerYear() {
1238: return (theValue * ((1.0d / 144) / (1.0d / 31556926)));
1239: }
1240:
1241: public double getGrossPerFortnight() {
1242: return (theValue * ((1.0d / 144) / (1.0d / 1209600)));
1243: }
1244:
1245: public double getMillionPerSecond() {
1246: return (theValue * ((1.0d / 1000000) / 1.0d));
1247: }
1248:
1249: public double getMillionPerMinute() {
1250: return (theValue * ((1.0d / 1000000) / (1.0d / 60)));
1251: }
1252:
1253: public double getMillionPerHour() {
1254: return (theValue * ((1.0d / 1000000) / (1.0d / 3600)));
1255: }
1256:
1257: public double getMillionPerDay() {
1258: return (theValue * ((1.0d / 1000000) / (1.0d / 86400)));
1259: }
1260:
1261: public double getMillionPerWeek() {
1262: return (theValue * ((1.0d / 1000000) / (1.0d / 604800)));
1263: }
1264:
1265: public double getMillionPerMillisecond() {
1266: return (theValue * ((1.0d / 1000000) / 1000));
1267: }
1268:
1269: public double getMillionPerKilosecond() {
1270: return (theValue * ((1.0d / 1000000) / (1.0d / 1000)));
1271: }
1272:
1273: public double getMillionPerMonth() {
1274: return (theValue * ((1.0d / 1000000) / (1.0d / 2629743.8)));
1275: }
1276:
1277: public double getMillionPerYear() {
1278: return (theValue * ((1.0d / 1000000) / (1.0d / 31556926)));
1279: }
1280:
1281: public double getMillionPerFortnight() {
1282: return (theValue * ((1.0d / 1000000) / (1.0d / 1209600)));
1283: }
1284:
1285: /** @param unit One of the constant units of CountRate **/
1286: public double getValue(int unit) {
1287: if (unit >= 0 && unit <= MAXUNIT)
1288: return (theValue * getConvFactor(unit));
1289: else
1290: throw new UnknownUnitException();
1291: }
1292:
1293: /** @param unit1 One of the constant units of Count
1294: * @param unit2 One of the constant units of Duration
1295: **/
1296: public double getValue(int unit1, int unit2) {
1297: if (unit1 >= 0 && unit1 <= Count.MAXUNIT && unit2 >= 0
1298: && unit2 <= Duration.MAXUNIT)
1299: return (theValue * Duration.getConvFactor(unit2) / Count
1300: .getConvFactor(unit1));
1301: else
1302: throw new UnknownUnitException();
1303: }
1304:
1305: public boolean equals(Object o) {
1306: return (o instanceof CountRate && theValue == ((CountRate) o).theValue);
1307: }
1308:
1309: public String toString() {
1310: return Double.toString(theValue) + "units/s";
1311: }
1312:
1313: public int hashCode() {
1314: return (new Double(theValue)).hashCode();
1315: }
1316:
1317: // Derivative
1318: public final Class getNumeratorClass() {
1319: return Count.class;
1320: }
1321:
1322: public final Class getDenominatorClass() {
1323: return Duration.class;
1324: }
1325:
1326: private final static Count can_num = new Count(0.0, 0);
1327:
1328: public final Measure getCanonicalNumerator() {
1329: return can_num;
1330: }
1331:
1332: private final static Duration can_den = new Duration(0.0, 0);
1333:
1334: public final Measure getCanonicalDenominator() {
1335: return can_den;
1336: }
1337:
1338: public final Measure computeNumerator(Measure den) {
1339: if (!(den instanceof Duration))
1340: throw new IllegalArgumentException();
1341: return new Count(theValue * den.getValue(0), 0);
1342: }
1343:
1344: public final Measure computeDenominator(Measure num) {
1345: if (!(num instanceof Count))
1346: throw new IllegalArgumentException();
1347: return new Duration(num.getValue(0) / theValue, 0);
1348: }
1349:
1350: // serialization
1351: public void writeExternal(ObjectOutput out) throws IOException {
1352: out.writeDouble(theValue);
1353: }
1354:
1355: public void readExternal(ObjectInput in) throws IOException {
1356: theValue = in.readDouble();
1357: }
1358: }
|