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 Speed.
0029: **/package org.cougaar.planning.ldm.measure;
0030:
0031: import java.io.*;
0032:
0033: public final class Speed extends AbstractMeasure implements
0034: Externalizable, Derivative, Rate {
0035: // the value is stored as meters/second
0036: private double theValue;
0037:
0038: /** No-arg constructor is only for use by serialization **/
0039: public Speed() {
0040: }
0041:
0042: // private constructor
0043: private Speed(double v) {
0044: theValue = v;
0045: }
0046:
0047: /** @param unit One of the constant units of Speed **/
0048: public Speed(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 Distance
0056: * @param unit2 One of the constant units of Duration
0057: **/
0058: public Speed(double v, int unit1, int unit2) {
0059: if (unit1 >= 0 && unit1 <= Distance.MAXUNIT && unit2 >= 0
0060: && unit2 <= Duration.MAXUNIT)
0061: theValue = v * Distance.getConvFactor(unit1)
0062: / Duration.getConvFactor(unit2);
0063: else
0064: throw new UnknownUnitException();
0065: }
0066:
0067: /** @param num An instance of Distance to use as numerator
0068: * @param den An instance of Durationto use as denominator
0069: **/
0070: public Speed(Distance num, Duration den) {
0071: theValue = num.getValue(0) / den.getValue(0);
0072: }
0073:
0074: /** takes strings of the form "Number unit" **/
0075: public Speed(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("meterspersecond"))
0083: theValue = n / (1.0d / 1.0d);
0084: else if (u.equals("metersperminute"))
0085: theValue = n / (1.0d / (1.0d / 60));
0086: else if (u.equals("metersperhour"))
0087: theValue = n / (1.0d / (1.0d / 3600));
0088: else if (u.equals("metersperday"))
0089: theValue = n / (1.0d / (1.0d / 86400));
0090: else if (u.equals("metersperweek"))
0091: theValue = n / (1.0d / (1.0d / 604800));
0092: else if (u.equals("meterspermillisecond"))
0093: theValue = n / (1.0d / 1000);
0094: else if (u.equals("metersperkilosecond"))
0095: theValue = n / (1.0d / (1.0d / 1000));
0096: else if (u.equals("meterspermonth"))
0097: theValue = n / (1.0d / (1.0d / 2629743.8));
0098: else if (u.equals("metersperyear"))
0099: theValue = n / (1.0d / (1.0d / 31556926));
0100: else if (u.equals("metersperfortnight"))
0101: theValue = n / (1.0d / (1.0d / 1209600));
0102: else if (u.equals("milespersecond"))
0103: theValue = n / ((1.0d / 1609.344) / 1.0d);
0104: else if (u.equals("milesperminute"))
0105: theValue = n / ((1.0d / 1609.344) / (1.0d / 60));
0106: else if (u.equals("milesperhour"))
0107: theValue = n / ((1.0d / 1609.344) / (1.0d / 3600));
0108: else if (u.equals("milesperday"))
0109: theValue = n / ((1.0d / 1609.344) / (1.0d / 86400));
0110: else if (u.equals("milesperweek"))
0111: theValue = n / ((1.0d / 1609.344) / (1.0d / 604800));
0112: else if (u.equals("milespermillisecond"))
0113: theValue = n / ((1.0d / 1609.344) / 1000);
0114: else if (u.equals("milesperkilosecond"))
0115: theValue = n / ((1.0d / 1609.344) / (1.0d / 1000));
0116: else if (u.equals("milespermonth"))
0117: theValue = n / ((1.0d / 1609.344) / (1.0d / 2629743.8));
0118: else if (u.equals("milesperyear"))
0119: theValue = n / ((1.0d / 1609.344) / (1.0d / 31556926));
0120: else if (u.equals("milesperfortnight"))
0121: theValue = n / ((1.0d / 1609.344) / (1.0d / 1209600));
0122: else if (u.equals("nauticalmilespersecond"))
0123: theValue = n / ((1.0d / 1852.0) / 1.0d);
0124: else if (u.equals("nauticalmilesperminute"))
0125: theValue = n / ((1.0d / 1852.0) / (1.0d / 60));
0126: else if (u.equals("nauticalmilesperhour"))
0127: theValue = n / ((1.0d / 1852.0) / (1.0d / 3600));
0128: else if (u.equals("nauticalmilesperday"))
0129: theValue = n / ((1.0d / 1852.0) / (1.0d / 86400));
0130: else if (u.equals("nauticalmilesperweek"))
0131: theValue = n / ((1.0d / 1852.0) / (1.0d / 604800));
0132: else if (u.equals("nauticalmilespermillisecond"))
0133: theValue = n / ((1.0d / 1852.0) / 1000);
0134: else if (u.equals("nauticalmilesperkilosecond"))
0135: theValue = n / ((1.0d / 1852.0) / (1.0d / 1000));
0136: else if (u.equals("nauticalmilespermonth"))
0137: theValue = n / ((1.0d / 1852.0) / (1.0d / 2629743.8));
0138: else if (u.equals("nauticalmilesperyear"))
0139: theValue = n / ((1.0d / 1852.0) / (1.0d / 31556926));
0140: else if (u.equals("nauticalmilesperfortnight"))
0141: theValue = n / ((1.0d / 1852.0) / (1.0d / 1209600));
0142: else if (u.equals("yardspersecond"))
0143: theValue = n / ((1.0d / 0.9414) / 1.0d);
0144: else if (u.equals("yardsperminute"))
0145: theValue = n / ((1.0d / 0.9414) / (1.0d / 60));
0146: else if (u.equals("yardsperhour"))
0147: theValue = n / ((1.0d / 0.9414) / (1.0d / 3600));
0148: else if (u.equals("yardsperday"))
0149: theValue = n / ((1.0d / 0.9414) / (1.0d / 86400));
0150: else if (u.equals("yardsperweek"))
0151: theValue = n / ((1.0d / 0.9414) / (1.0d / 604800));
0152: else if (u.equals("yardspermillisecond"))
0153: theValue = n / ((1.0d / 0.9414) / 1000);
0154: else if (u.equals("yardsperkilosecond"))
0155: theValue = n / ((1.0d / 0.9414) / (1.0d / 1000));
0156: else if (u.equals("yardspermonth"))
0157: theValue = n / ((1.0d / 0.9414) / (1.0d / 2629743.8));
0158: else if (u.equals("yardsperyear"))
0159: theValue = n / ((1.0d / 0.9414) / (1.0d / 31556926));
0160: else if (u.equals("yardsperfortnight"))
0161: theValue = n / ((1.0d / 0.9414) / (1.0d / 1209600));
0162: else if (u.equals("feetpersecond"))
0163: theValue = n / ((1.0d / 0.3048) / 1.0d);
0164: else if (u.equals("feetperminute"))
0165: theValue = n / ((1.0d / 0.3048) / (1.0d / 60));
0166: else if (u.equals("feetperhour"))
0167: theValue = n / ((1.0d / 0.3048) / (1.0d / 3600));
0168: else if (u.equals("feetperday"))
0169: theValue = n / ((1.0d / 0.3048) / (1.0d / 86400));
0170: else if (u.equals("feetperweek"))
0171: theValue = n / ((1.0d / 0.3048) / (1.0d / 604800));
0172: else if (u.equals("feetpermillisecond"))
0173: theValue = n / ((1.0d / 0.3048) / 1000);
0174: else if (u.equals("feetperkilosecond"))
0175: theValue = n / ((1.0d / 0.3048) / (1.0d / 1000));
0176: else if (u.equals("feetpermonth"))
0177: theValue = n / ((1.0d / 0.3048) / (1.0d / 2629743.8));
0178: else if (u.equals("feetperyear"))
0179: theValue = n / ((1.0d / 0.3048) / (1.0d / 31556926));
0180: else if (u.equals("feetperfortnight"))
0181: theValue = n / ((1.0d / 0.3048) / (1.0d / 1209600));
0182: else if (u.equals("inchespersecond"))
0183: theValue = n / ((1.0d / 0.0254) / 1.0d);
0184: else if (u.equals("inchesperminute"))
0185: theValue = n / ((1.0d / 0.0254) / (1.0d / 60));
0186: else if (u.equals("inchesperhour"))
0187: theValue = n / ((1.0d / 0.0254) / (1.0d / 3600));
0188: else if (u.equals("inchesperday"))
0189: theValue = n / ((1.0d / 0.0254) / (1.0d / 86400));
0190: else if (u.equals("inchesperweek"))
0191: theValue = n / ((1.0d / 0.0254) / (1.0d / 604800));
0192: else if (u.equals("inchespermillisecond"))
0193: theValue = n / ((1.0d / 0.0254) / 1000);
0194: else if (u.equals("inchesperkilosecond"))
0195: theValue = n / ((1.0d / 0.0254) / (1.0d / 1000));
0196: else if (u.equals("inchespermonth"))
0197: theValue = n / ((1.0d / 0.0254) / (1.0d / 2629743.8));
0198: else if (u.equals("inchesperyear"))
0199: theValue = n / ((1.0d / 0.0254) / (1.0d / 31556926));
0200: else if (u.equals("inchesperfortnight"))
0201: theValue = n / ((1.0d / 0.0254) / (1.0d / 1209600));
0202: else if (u.equals("kilometerspersecond"))
0203: theValue = n / ((1.0d / 1000.0) / 1.0d);
0204: else if (u.equals("kilometersperminute"))
0205: theValue = n / ((1.0d / 1000.0) / (1.0d / 60));
0206: else if (u.equals("kilometersperhour"))
0207: theValue = n / ((1.0d / 1000.0) / (1.0d / 3600));
0208: else if (u.equals("kilometersperday"))
0209: theValue = n / ((1.0d / 1000.0) / (1.0d / 86400));
0210: else if (u.equals("kilometersperweek"))
0211: theValue = n / ((1.0d / 1000.0) / (1.0d / 604800));
0212: else if (u.equals("kilometerspermillisecond"))
0213: theValue = n / ((1.0d / 1000.0) / 1000);
0214: else if (u.equals("kilometersperkilosecond"))
0215: theValue = n / ((1.0d / 1000.0) / (1.0d / 1000));
0216: else if (u.equals("kilometerspermonth"))
0217: theValue = n / ((1.0d / 1000.0) / (1.0d / 2629743.8));
0218: else if (u.equals("kilometersperyear"))
0219: theValue = n / ((1.0d / 1000.0) / (1.0d / 31556926));
0220: else if (u.equals("kilometersperfortnight"))
0221: theValue = n / ((1.0d / 1000.0) / (1.0d / 1209600));
0222: else if (u.equals("centimeterspersecond"))
0223: theValue = n / (100 / 1.0d);
0224: else if (u.equals("centimetersperminute"))
0225: theValue = n / (100 / (1.0d / 60));
0226: else if (u.equals("centimetersperhour"))
0227: theValue = n / (100 / (1.0d / 3600));
0228: else if (u.equals("centimetersperday"))
0229: theValue = n / (100 / (1.0d / 86400));
0230: else if (u.equals("centimetersperweek"))
0231: theValue = n / (100 / (1.0d / 604800));
0232: else if (u.equals("centimeterspermillisecond"))
0233: theValue = n / (100 / 1000);
0234: else if (u.equals("centimetersperkilosecond"))
0235: theValue = n / (100 / (1.0d / 1000));
0236: else if (u.equals("centimeterspermonth"))
0237: theValue = n / (100 / (1.0d / 2629743.8));
0238: else if (u.equals("centimetersperyear"))
0239: theValue = n / (100 / (1.0d / 31556926));
0240: else if (u.equals("centimetersperfortnight"))
0241: theValue = n / (100 / (1.0d / 1209600));
0242: else if (u.equals("millimeterspersecond"))
0243: theValue = n / (1000 / 1.0d);
0244: else if (u.equals("millimetersperminute"))
0245: theValue = n / (1000 / (1.0d / 60));
0246: else if (u.equals("millimetersperhour"))
0247: theValue = n / (1000 / (1.0d / 3600));
0248: else if (u.equals("millimetersperday"))
0249: theValue = n / (1000 / (1.0d / 86400));
0250: else if (u.equals("millimetersperweek"))
0251: theValue = n / (1000 / (1.0d / 604800));
0252: else if (u.equals("millimeterspermillisecond"))
0253: theValue = n / (1000 / 1000);
0254: else if (u.equals("millimetersperkilosecond"))
0255: theValue = n / (1000 / (1.0d / 1000));
0256: else if (u.equals("millimeterspermonth"))
0257: theValue = n / (1000 / (1.0d / 2629743.8));
0258: else if (u.equals("millimetersperyear"))
0259: theValue = n / (1000 / (1.0d / 31556926));
0260: else if (u.equals("millimetersperfortnight"))
0261: theValue = n / (1000 / (1.0d / 1209600));
0262: else if (u.equals("furlongspersecond"))
0263: theValue = n / ((1.0d / 201.168) / 1.0d);
0264: else if (u.equals("furlongsperminute"))
0265: theValue = n / ((1.0d / 201.168) / (1.0d / 60));
0266: else if (u.equals("furlongsperhour"))
0267: theValue = n / ((1.0d / 201.168) / (1.0d / 3600));
0268: else if (u.equals("furlongsperday"))
0269: theValue = n / ((1.0d / 201.168) / (1.0d / 86400));
0270: else if (u.equals("furlongsperweek"))
0271: theValue = n / ((1.0d / 201.168) / (1.0d / 604800));
0272: else if (u.equals("furlongspermillisecond"))
0273: theValue = n / ((1.0d / 201.168) / 1000);
0274: else if (u.equals("furlongsperkilosecond"))
0275: theValue = n / ((1.0d / 201.168) / (1.0d / 1000));
0276: else if (u.equals("furlongspermonth"))
0277: theValue = n / ((1.0d / 201.168) / (1.0d / 2629743.8));
0278: else if (u.equals("furlongsperyear"))
0279: theValue = n / ((1.0d / 201.168) / (1.0d / 31556926));
0280: else if (u.equals("furlongsperfortnight"))
0281: theValue = n / ((1.0d / 201.168) / (1.0d / 1209600));
0282: else
0283: throw new UnknownUnitException();
0284: }
0285:
0286: // TypeNamed factory methods
0287: public static final Speed newMetersPerSecond(double v) {
0288: return new Speed(v * (1.0d / (1.0d / 1.0d)));
0289: }
0290:
0291: public static final Speed newMetersPerSecond(String s) {
0292: return new Speed((Double.valueOf(s).doubleValue())
0293: * (1.0d / (1.0d / 1.0d)));
0294: }
0295:
0296: public static final Speed newMetersPerMinute(double v) {
0297: return new Speed(v * (1.0d / (1.0d / (1.0d / 60))));
0298: }
0299:
0300: public static final Speed newMetersPerMinute(String s) {
0301: return new Speed((Double.valueOf(s).doubleValue())
0302: * (1.0d / (1.0d / (1.0d / 60))));
0303: }
0304:
0305: public static final Speed newMetersPerHour(double v) {
0306: return new Speed(v * (1.0d / (1.0d / (1.0d / 3600))));
0307: }
0308:
0309: public static final Speed newMetersPerHour(String s) {
0310: return new Speed((Double.valueOf(s).doubleValue())
0311: * (1.0d / (1.0d / (1.0d / 3600))));
0312: }
0313:
0314: public static final Speed newMetersPerDay(double v) {
0315: return new Speed(v * (1.0d / (1.0d / (1.0d / 86400))));
0316: }
0317:
0318: public static final Speed newMetersPerDay(String s) {
0319: return new Speed((Double.valueOf(s).doubleValue())
0320: * (1.0d / (1.0d / (1.0d / 86400))));
0321: }
0322:
0323: public static final Speed newMetersPerWeek(double v) {
0324: return new Speed(v * (1.0d / (1.0d / (1.0d / 604800))));
0325: }
0326:
0327: public static final Speed newMetersPerWeek(String s) {
0328: return new Speed((Double.valueOf(s).doubleValue())
0329: * (1.0d / (1.0d / (1.0d / 604800))));
0330: }
0331:
0332: public static final Speed newMetersPerMillisecond(double v) {
0333: return new Speed(v * (1.0d / (1.0d / 1000)));
0334: }
0335:
0336: public static final Speed newMetersPerMillisecond(String s) {
0337: return new Speed((Double.valueOf(s).doubleValue())
0338: * (1.0d / (1.0d / 1000)));
0339: }
0340:
0341: public static final Speed newMetersPerKilosecond(double v) {
0342: return new Speed(v * (1.0d / (1.0d / (1.0d / 1000))));
0343: }
0344:
0345: public static final Speed newMetersPerKilosecond(String s) {
0346: return new Speed((Double.valueOf(s).doubleValue())
0347: * (1.0d / (1.0d / (1.0d / 1000))));
0348: }
0349:
0350: public static final Speed newMetersPerMonth(double v) {
0351: return new Speed(v * (1.0d / (1.0d / (1.0d / 2629743.8))));
0352: }
0353:
0354: public static final Speed newMetersPerMonth(String s) {
0355: return new Speed((Double.valueOf(s).doubleValue())
0356: * (1.0d / (1.0d / (1.0d / 2629743.8))));
0357: }
0358:
0359: public static final Speed newMetersPerYear(double v) {
0360: return new Speed(v * (1.0d / (1.0d / (1.0d / 31556926))));
0361: }
0362:
0363: public static final Speed newMetersPerYear(String s) {
0364: return new Speed((Double.valueOf(s).doubleValue())
0365: * (1.0d / (1.0d / (1.0d / 31556926))));
0366: }
0367:
0368: public static final Speed newMetersPerFortnight(double v) {
0369: return new Speed(v * (1.0d / (1.0d / (1.0d / 1209600))));
0370: }
0371:
0372: public static final Speed newMetersPerFortnight(String s) {
0373: return new Speed((Double.valueOf(s).doubleValue())
0374: * (1.0d / (1.0d / (1.0d / 1209600))));
0375: }
0376:
0377: public static final Speed newMilesPerSecond(double v) {
0378: return new Speed(v * (1.0d / ((1.0d / 1609.344) / 1.0d)));
0379: }
0380:
0381: public static final Speed newMilesPerSecond(String s) {
0382: return new Speed((Double.valueOf(s).doubleValue())
0383: * (1.0d / ((1.0d / 1609.344) / 1.0d)));
0384: }
0385:
0386: public static final Speed newMilesPerMinute(double v) {
0387: return new Speed(v * (1.0d / ((1.0d / 1609.344) / (1.0d / 60))));
0388: }
0389:
0390: public static final Speed newMilesPerMinute(String s) {
0391: return new Speed((Double.valueOf(s).doubleValue())
0392: * (1.0d / ((1.0d / 1609.344) / (1.0d / 60))));
0393: }
0394:
0395: public static final Speed newMilesPerHour(double v) {
0396: return new Speed(v
0397: * (1.0d / ((1.0d / 1609.344) / (1.0d / 3600))));
0398: }
0399:
0400: public static final Speed newMilesPerHour(String s) {
0401: return new Speed((Double.valueOf(s).doubleValue())
0402: * (1.0d / ((1.0d / 1609.344) / (1.0d / 3600))));
0403: }
0404:
0405: public static final Speed newMilesPerDay(double v) {
0406: return new Speed(v
0407: * (1.0d / ((1.0d / 1609.344) / (1.0d / 86400))));
0408: }
0409:
0410: public static final Speed newMilesPerDay(String s) {
0411: return new Speed((Double.valueOf(s).doubleValue())
0412: * (1.0d / ((1.0d / 1609.344) / (1.0d / 86400))));
0413: }
0414:
0415: public static final Speed newMilesPerWeek(double v) {
0416: return new Speed(v
0417: * (1.0d / ((1.0d / 1609.344) / (1.0d / 604800))));
0418: }
0419:
0420: public static final Speed newMilesPerWeek(String s) {
0421: return new Speed((Double.valueOf(s).doubleValue())
0422: * (1.0d / ((1.0d / 1609.344) / (1.0d / 604800))));
0423: }
0424:
0425: public static final Speed newMilesPerMillisecond(double v) {
0426: return new Speed(v * (1.0d / ((1.0d / 1609.344) / 1000)));
0427: }
0428:
0429: public static final Speed newMilesPerMillisecond(String s) {
0430: return new Speed((Double.valueOf(s).doubleValue())
0431: * (1.0d / ((1.0d / 1609.344) / 1000)));
0432: }
0433:
0434: public static final Speed newMilesPerKilosecond(double v) {
0435: return new Speed(v
0436: * (1.0d / ((1.0d / 1609.344) / (1.0d / 1000))));
0437: }
0438:
0439: public static final Speed newMilesPerKilosecond(String s) {
0440: return new Speed((Double.valueOf(s).doubleValue())
0441: * (1.0d / ((1.0d / 1609.344) / (1.0d / 1000))));
0442: }
0443:
0444: public static final Speed newMilesPerMonth(double v) {
0445: return new Speed(v
0446: * (1.0d / ((1.0d / 1609.344) / (1.0d / 2629743.8))));
0447: }
0448:
0449: public static final Speed newMilesPerMonth(String s) {
0450: return new Speed((Double.valueOf(s).doubleValue())
0451: * (1.0d / ((1.0d / 1609.344) / (1.0d / 2629743.8))));
0452: }
0453:
0454: public static final Speed newMilesPerYear(double v) {
0455: return new Speed(v
0456: * (1.0d / ((1.0d / 1609.344) / (1.0d / 31556926))));
0457: }
0458:
0459: public static final Speed newMilesPerYear(String s) {
0460: return new Speed((Double.valueOf(s).doubleValue())
0461: * (1.0d / ((1.0d / 1609.344) / (1.0d / 31556926))));
0462: }
0463:
0464: public static final Speed newMilesPerFortnight(double v) {
0465: return new Speed(v
0466: * (1.0d / ((1.0d / 1609.344) / (1.0d / 1209600))));
0467: }
0468:
0469: public static final Speed newMilesPerFortnight(String s) {
0470: return new Speed((Double.valueOf(s).doubleValue())
0471: * (1.0d / ((1.0d / 1609.344) / (1.0d / 1209600))));
0472: }
0473:
0474: public static final Speed newNauticalMilesPerSecond(double v) {
0475: return new Speed(v * (1.0d / ((1.0d / 1852.0) / 1.0d)));
0476: }
0477:
0478: public static final Speed newNauticalMilesPerSecond(String s) {
0479: return new Speed((Double.valueOf(s).doubleValue())
0480: * (1.0d / ((1.0d / 1852.0) / 1.0d)));
0481: }
0482:
0483: public static final Speed newNauticalMilesPerMinute(double v) {
0484: return new Speed(v * (1.0d / ((1.0d / 1852.0) / (1.0d / 60))));
0485: }
0486:
0487: public static final Speed newNauticalMilesPerMinute(String s) {
0488: return new Speed((Double.valueOf(s).doubleValue())
0489: * (1.0d / ((1.0d / 1852.0) / (1.0d / 60))));
0490: }
0491:
0492: public static final Speed newNauticalMilesPerHour(double v) {
0493: return new Speed(v * (1.0d / ((1.0d / 1852.0) / (1.0d / 3600))));
0494: }
0495:
0496: public static final Speed newNauticalMilesPerHour(String s) {
0497: return new Speed((Double.valueOf(s).doubleValue())
0498: * (1.0d / ((1.0d / 1852.0) / (1.0d / 3600))));
0499: }
0500:
0501: public static final Speed newNauticalMilesPerDay(double v) {
0502: return new Speed(v
0503: * (1.0d / ((1.0d / 1852.0) / (1.0d / 86400))));
0504: }
0505:
0506: public static final Speed newNauticalMilesPerDay(String s) {
0507: return new Speed((Double.valueOf(s).doubleValue())
0508: * (1.0d / ((1.0d / 1852.0) / (1.0d / 86400))));
0509: }
0510:
0511: public static final Speed newNauticalMilesPerWeek(double v) {
0512: return new Speed(v
0513: * (1.0d / ((1.0d / 1852.0) / (1.0d / 604800))));
0514: }
0515:
0516: public static final Speed newNauticalMilesPerWeek(String s) {
0517: return new Speed((Double.valueOf(s).doubleValue())
0518: * (1.0d / ((1.0d / 1852.0) / (1.0d / 604800))));
0519: }
0520:
0521: public static final Speed newNauticalMilesPerMillisecond(double v) {
0522: return new Speed(v * (1.0d / ((1.0d / 1852.0) / 1000)));
0523: }
0524:
0525: public static final Speed newNauticalMilesPerMillisecond(String s) {
0526: return new Speed((Double.valueOf(s).doubleValue())
0527: * (1.0d / ((1.0d / 1852.0) / 1000)));
0528: }
0529:
0530: public static final Speed newNauticalMilesPerKilosecond(double v) {
0531: return new Speed(v * (1.0d / ((1.0d / 1852.0) / (1.0d / 1000))));
0532: }
0533:
0534: public static final Speed newNauticalMilesPerKilosecond(String s) {
0535: return new Speed((Double.valueOf(s).doubleValue())
0536: * (1.0d / ((1.0d / 1852.0) / (1.0d / 1000))));
0537: }
0538:
0539: public static final Speed newNauticalMilesPerMonth(double v) {
0540: return new Speed(v
0541: * (1.0d / ((1.0d / 1852.0) / (1.0d / 2629743.8))));
0542: }
0543:
0544: public static final Speed newNauticalMilesPerMonth(String s) {
0545: return new Speed((Double.valueOf(s).doubleValue())
0546: * (1.0d / ((1.0d / 1852.0) / (1.0d / 2629743.8))));
0547: }
0548:
0549: public static final Speed newNauticalMilesPerYear(double v) {
0550: return new Speed(v
0551: * (1.0d / ((1.0d / 1852.0) / (1.0d / 31556926))));
0552: }
0553:
0554: public static final Speed newNauticalMilesPerYear(String s) {
0555: return new Speed((Double.valueOf(s).doubleValue())
0556: * (1.0d / ((1.0d / 1852.0) / (1.0d / 31556926))));
0557: }
0558:
0559: public static final Speed newNauticalMilesPerFortnight(double v) {
0560: return new Speed(v
0561: * (1.0d / ((1.0d / 1852.0) / (1.0d / 1209600))));
0562: }
0563:
0564: public static final Speed newNauticalMilesPerFortnight(String s) {
0565: return new Speed((Double.valueOf(s).doubleValue())
0566: * (1.0d / ((1.0d / 1852.0) / (1.0d / 1209600))));
0567: }
0568:
0569: public static final Speed newYardsPerSecond(double v) {
0570: return new Speed(v * (1.0d / ((1.0d / 0.9414) / 1.0d)));
0571: }
0572:
0573: public static final Speed newYardsPerSecond(String s) {
0574: return new Speed((Double.valueOf(s).doubleValue())
0575: * (1.0d / ((1.0d / 0.9414) / 1.0d)));
0576: }
0577:
0578: public static final Speed newYardsPerMinute(double v) {
0579: return new Speed(v * (1.0d / ((1.0d / 0.9414) / (1.0d / 60))));
0580: }
0581:
0582: public static final Speed newYardsPerMinute(String s) {
0583: return new Speed((Double.valueOf(s).doubleValue())
0584: * (1.0d / ((1.0d / 0.9414) / (1.0d / 60))));
0585: }
0586:
0587: public static final Speed newYardsPerHour(double v) {
0588: return new Speed(v * (1.0d / ((1.0d / 0.9414) / (1.0d / 3600))));
0589: }
0590:
0591: public static final Speed newYardsPerHour(String s) {
0592: return new Speed((Double.valueOf(s).doubleValue())
0593: * (1.0d / ((1.0d / 0.9414) / (1.0d / 3600))));
0594: }
0595:
0596: public static final Speed newYardsPerDay(double v) {
0597: return new Speed(v
0598: * (1.0d / ((1.0d / 0.9414) / (1.0d / 86400))));
0599: }
0600:
0601: public static final Speed newYardsPerDay(String s) {
0602: return new Speed((Double.valueOf(s).doubleValue())
0603: * (1.0d / ((1.0d / 0.9414) / (1.0d / 86400))));
0604: }
0605:
0606: public static final Speed newYardsPerWeek(double v) {
0607: return new Speed(v
0608: * (1.0d / ((1.0d / 0.9414) / (1.0d / 604800))));
0609: }
0610:
0611: public static final Speed newYardsPerWeek(String s) {
0612: return new Speed((Double.valueOf(s).doubleValue())
0613: * (1.0d / ((1.0d / 0.9414) / (1.0d / 604800))));
0614: }
0615:
0616: public static final Speed newYardsPerMillisecond(double v) {
0617: return new Speed(v * (1.0d / ((1.0d / 0.9414) / 1000)));
0618: }
0619:
0620: public static final Speed newYardsPerMillisecond(String s) {
0621: return new Speed((Double.valueOf(s).doubleValue())
0622: * (1.0d / ((1.0d / 0.9414) / 1000)));
0623: }
0624:
0625: public static final Speed newYardsPerKilosecond(double v) {
0626: return new Speed(v * (1.0d / ((1.0d / 0.9414) / (1.0d / 1000))));
0627: }
0628:
0629: public static final Speed newYardsPerKilosecond(String s) {
0630: return new Speed((Double.valueOf(s).doubleValue())
0631: * (1.0d / ((1.0d / 0.9414) / (1.0d / 1000))));
0632: }
0633:
0634: public static final Speed newYardsPerMonth(double v) {
0635: return new Speed(v
0636: * (1.0d / ((1.0d / 0.9414) / (1.0d / 2629743.8))));
0637: }
0638:
0639: public static final Speed newYardsPerMonth(String s) {
0640: return new Speed((Double.valueOf(s).doubleValue())
0641: * (1.0d / ((1.0d / 0.9414) / (1.0d / 2629743.8))));
0642: }
0643:
0644: public static final Speed newYardsPerYear(double v) {
0645: return new Speed(v
0646: * (1.0d / ((1.0d / 0.9414) / (1.0d / 31556926))));
0647: }
0648:
0649: public static final Speed newYardsPerYear(String s) {
0650: return new Speed((Double.valueOf(s).doubleValue())
0651: * (1.0d / ((1.0d / 0.9414) / (1.0d / 31556926))));
0652: }
0653:
0654: public static final Speed newYardsPerFortnight(double v) {
0655: return new Speed(v
0656: * (1.0d / ((1.0d / 0.9414) / (1.0d / 1209600))));
0657: }
0658:
0659: public static final Speed newYardsPerFortnight(String s) {
0660: return new Speed((Double.valueOf(s).doubleValue())
0661: * (1.0d / ((1.0d / 0.9414) / (1.0d / 1209600))));
0662: }
0663:
0664: public static final Speed newFeetPerSecond(double v) {
0665: return new Speed(v * (1.0d / ((1.0d / 0.3048) / 1.0d)));
0666: }
0667:
0668: public static final Speed newFeetPerSecond(String s) {
0669: return new Speed((Double.valueOf(s).doubleValue())
0670: * (1.0d / ((1.0d / 0.3048) / 1.0d)));
0671: }
0672:
0673: public static final Speed newFeetPerMinute(double v) {
0674: return new Speed(v * (1.0d / ((1.0d / 0.3048) / (1.0d / 60))));
0675: }
0676:
0677: public static final Speed newFeetPerMinute(String s) {
0678: return new Speed((Double.valueOf(s).doubleValue())
0679: * (1.0d / ((1.0d / 0.3048) / (1.0d / 60))));
0680: }
0681:
0682: public static final Speed newFeetPerHour(double v) {
0683: return new Speed(v * (1.0d / ((1.0d / 0.3048) / (1.0d / 3600))));
0684: }
0685:
0686: public static final Speed newFeetPerHour(String s) {
0687: return new Speed((Double.valueOf(s).doubleValue())
0688: * (1.0d / ((1.0d / 0.3048) / (1.0d / 3600))));
0689: }
0690:
0691: public static final Speed newFeetPerDay(double v) {
0692: return new Speed(v
0693: * (1.0d / ((1.0d / 0.3048) / (1.0d / 86400))));
0694: }
0695:
0696: public static final Speed newFeetPerDay(String s) {
0697: return new Speed((Double.valueOf(s).doubleValue())
0698: * (1.0d / ((1.0d / 0.3048) / (1.0d / 86400))));
0699: }
0700:
0701: public static final Speed newFeetPerWeek(double v) {
0702: return new Speed(v
0703: * (1.0d / ((1.0d / 0.3048) / (1.0d / 604800))));
0704: }
0705:
0706: public static final Speed newFeetPerWeek(String s) {
0707: return new Speed((Double.valueOf(s).doubleValue())
0708: * (1.0d / ((1.0d / 0.3048) / (1.0d / 604800))));
0709: }
0710:
0711: public static final Speed newFeetPerMillisecond(double v) {
0712: return new Speed(v * (1.0d / ((1.0d / 0.3048) / 1000)));
0713: }
0714:
0715: public static final Speed newFeetPerMillisecond(String s) {
0716: return new Speed((Double.valueOf(s).doubleValue())
0717: * (1.0d / ((1.0d / 0.3048) / 1000)));
0718: }
0719:
0720: public static final Speed newFeetPerKilosecond(double v) {
0721: return new Speed(v * (1.0d / ((1.0d / 0.3048) / (1.0d / 1000))));
0722: }
0723:
0724: public static final Speed newFeetPerKilosecond(String s) {
0725: return new Speed((Double.valueOf(s).doubleValue())
0726: * (1.0d / ((1.0d / 0.3048) / (1.0d / 1000))));
0727: }
0728:
0729: public static final Speed newFeetPerMonth(double v) {
0730: return new Speed(v
0731: * (1.0d / ((1.0d / 0.3048) / (1.0d / 2629743.8))));
0732: }
0733:
0734: public static final Speed newFeetPerMonth(String s) {
0735: return new Speed((Double.valueOf(s).doubleValue())
0736: * (1.0d / ((1.0d / 0.3048) / (1.0d / 2629743.8))));
0737: }
0738:
0739: public static final Speed newFeetPerYear(double v) {
0740: return new Speed(v
0741: * (1.0d / ((1.0d / 0.3048) / (1.0d / 31556926))));
0742: }
0743:
0744: public static final Speed newFeetPerYear(String s) {
0745: return new Speed((Double.valueOf(s).doubleValue())
0746: * (1.0d / ((1.0d / 0.3048) / (1.0d / 31556926))));
0747: }
0748:
0749: public static final Speed newFeetPerFortnight(double v) {
0750: return new Speed(v
0751: * (1.0d / ((1.0d / 0.3048) / (1.0d / 1209600))));
0752: }
0753:
0754: public static final Speed newFeetPerFortnight(String s) {
0755: return new Speed((Double.valueOf(s).doubleValue())
0756: * (1.0d / ((1.0d / 0.3048) / (1.0d / 1209600))));
0757: }
0758:
0759: public static final Speed newInchesPerSecond(double v) {
0760: return new Speed(v * (1.0d / ((1.0d / 0.0254) / 1.0d)));
0761: }
0762:
0763: public static final Speed newInchesPerSecond(String s) {
0764: return new Speed((Double.valueOf(s).doubleValue())
0765: * (1.0d / ((1.0d / 0.0254) / 1.0d)));
0766: }
0767:
0768: public static final Speed newInchesPerMinute(double v) {
0769: return new Speed(v * (1.0d / ((1.0d / 0.0254) / (1.0d / 60))));
0770: }
0771:
0772: public static final Speed newInchesPerMinute(String s) {
0773: return new Speed((Double.valueOf(s).doubleValue())
0774: * (1.0d / ((1.0d / 0.0254) / (1.0d / 60))));
0775: }
0776:
0777: public static final Speed newInchesPerHour(double v) {
0778: return new Speed(v * (1.0d / ((1.0d / 0.0254) / (1.0d / 3600))));
0779: }
0780:
0781: public static final Speed newInchesPerHour(String s) {
0782: return new Speed((Double.valueOf(s).doubleValue())
0783: * (1.0d / ((1.0d / 0.0254) / (1.0d / 3600))));
0784: }
0785:
0786: public static final Speed newInchesPerDay(double v) {
0787: return new Speed(v
0788: * (1.0d / ((1.0d / 0.0254) / (1.0d / 86400))));
0789: }
0790:
0791: public static final Speed newInchesPerDay(String s) {
0792: return new Speed((Double.valueOf(s).doubleValue())
0793: * (1.0d / ((1.0d / 0.0254) / (1.0d / 86400))));
0794: }
0795:
0796: public static final Speed newInchesPerWeek(double v) {
0797: return new Speed(v
0798: * (1.0d / ((1.0d / 0.0254) / (1.0d / 604800))));
0799: }
0800:
0801: public static final Speed newInchesPerWeek(String s) {
0802: return new Speed((Double.valueOf(s).doubleValue())
0803: * (1.0d / ((1.0d / 0.0254) / (1.0d / 604800))));
0804: }
0805:
0806: public static final Speed newInchesPerMillisecond(double v) {
0807: return new Speed(v * (1.0d / ((1.0d / 0.0254) / 1000)));
0808: }
0809:
0810: public static final Speed newInchesPerMillisecond(String s) {
0811: return new Speed((Double.valueOf(s).doubleValue())
0812: * (1.0d / ((1.0d / 0.0254) / 1000)));
0813: }
0814:
0815: public static final Speed newInchesPerKilosecond(double v) {
0816: return new Speed(v * (1.0d / ((1.0d / 0.0254) / (1.0d / 1000))));
0817: }
0818:
0819: public static final Speed newInchesPerKilosecond(String s) {
0820: return new Speed((Double.valueOf(s).doubleValue())
0821: * (1.0d / ((1.0d / 0.0254) / (1.0d / 1000))));
0822: }
0823:
0824: public static final Speed newInchesPerMonth(double v) {
0825: return new Speed(v
0826: * (1.0d / ((1.0d / 0.0254) / (1.0d / 2629743.8))));
0827: }
0828:
0829: public static final Speed newInchesPerMonth(String s) {
0830: return new Speed((Double.valueOf(s).doubleValue())
0831: * (1.0d / ((1.0d / 0.0254) / (1.0d / 2629743.8))));
0832: }
0833:
0834: public static final Speed newInchesPerYear(double v) {
0835: return new Speed(v
0836: * (1.0d / ((1.0d / 0.0254) / (1.0d / 31556926))));
0837: }
0838:
0839: public static final Speed newInchesPerYear(String s) {
0840: return new Speed((Double.valueOf(s).doubleValue())
0841: * (1.0d / ((1.0d / 0.0254) / (1.0d / 31556926))));
0842: }
0843:
0844: public static final Speed newInchesPerFortnight(double v) {
0845: return new Speed(v
0846: * (1.0d / ((1.0d / 0.0254) / (1.0d / 1209600))));
0847: }
0848:
0849: public static final Speed newInchesPerFortnight(String s) {
0850: return new Speed((Double.valueOf(s).doubleValue())
0851: * (1.0d / ((1.0d / 0.0254) / (1.0d / 1209600))));
0852: }
0853:
0854: public static final Speed newKilometersPerSecond(double v) {
0855: return new Speed(v * (1.0d / ((1.0d / 1000.0) / 1.0d)));
0856: }
0857:
0858: public static final Speed newKilometersPerSecond(String s) {
0859: return new Speed((Double.valueOf(s).doubleValue())
0860: * (1.0d / ((1.0d / 1000.0) / 1.0d)));
0861: }
0862:
0863: public static final Speed newKilometersPerMinute(double v) {
0864: return new Speed(v * (1.0d / ((1.0d / 1000.0) / (1.0d / 60))));
0865: }
0866:
0867: public static final Speed newKilometersPerMinute(String s) {
0868: return new Speed((Double.valueOf(s).doubleValue())
0869: * (1.0d / ((1.0d / 1000.0) / (1.0d / 60))));
0870: }
0871:
0872: public static final Speed newKilometersPerHour(double v) {
0873: return new Speed(v * (1.0d / ((1.0d / 1000.0) / (1.0d / 3600))));
0874: }
0875:
0876: public static final Speed newKilometersPerHour(String s) {
0877: return new Speed((Double.valueOf(s).doubleValue())
0878: * (1.0d / ((1.0d / 1000.0) / (1.0d / 3600))));
0879: }
0880:
0881: public static final Speed newKilometersPerDay(double v) {
0882: return new Speed(v
0883: * (1.0d / ((1.0d / 1000.0) / (1.0d / 86400))));
0884: }
0885:
0886: public static final Speed newKilometersPerDay(String s) {
0887: return new Speed((Double.valueOf(s).doubleValue())
0888: * (1.0d / ((1.0d / 1000.0) / (1.0d / 86400))));
0889: }
0890:
0891: public static final Speed newKilometersPerWeek(double v) {
0892: return new Speed(v
0893: * (1.0d / ((1.0d / 1000.0) / (1.0d / 604800))));
0894: }
0895:
0896: public static final Speed newKilometersPerWeek(String s) {
0897: return new Speed((Double.valueOf(s).doubleValue())
0898: * (1.0d / ((1.0d / 1000.0) / (1.0d / 604800))));
0899: }
0900:
0901: public static final Speed newKilometersPerMillisecond(double v) {
0902: return new Speed(v * (1.0d / ((1.0d / 1000.0) / 1000)));
0903: }
0904:
0905: public static final Speed newKilometersPerMillisecond(String s) {
0906: return new Speed((Double.valueOf(s).doubleValue())
0907: * (1.0d / ((1.0d / 1000.0) / 1000)));
0908: }
0909:
0910: public static final Speed newKilometersPerKilosecond(double v) {
0911: return new Speed(v * (1.0d / ((1.0d / 1000.0) / (1.0d / 1000))));
0912: }
0913:
0914: public static final Speed newKilometersPerKilosecond(String s) {
0915: return new Speed((Double.valueOf(s).doubleValue())
0916: * (1.0d / ((1.0d / 1000.0) / (1.0d / 1000))));
0917: }
0918:
0919: public static final Speed newKilometersPerMonth(double v) {
0920: return new Speed(v
0921: * (1.0d / ((1.0d / 1000.0) / (1.0d / 2629743.8))));
0922: }
0923:
0924: public static final Speed newKilometersPerMonth(String s) {
0925: return new Speed((Double.valueOf(s).doubleValue())
0926: * (1.0d / ((1.0d / 1000.0) / (1.0d / 2629743.8))));
0927: }
0928:
0929: public static final Speed newKilometersPerYear(double v) {
0930: return new Speed(v
0931: * (1.0d / ((1.0d / 1000.0) / (1.0d / 31556926))));
0932: }
0933:
0934: public static final Speed newKilometersPerYear(String s) {
0935: return new Speed((Double.valueOf(s).doubleValue())
0936: * (1.0d / ((1.0d / 1000.0) / (1.0d / 31556926))));
0937: }
0938:
0939: public static final Speed newKilometersPerFortnight(double v) {
0940: return new Speed(v
0941: * (1.0d / ((1.0d / 1000.0) / (1.0d / 1209600))));
0942: }
0943:
0944: public static final Speed newKilometersPerFortnight(String s) {
0945: return new Speed((Double.valueOf(s).doubleValue())
0946: * (1.0d / ((1.0d / 1000.0) / (1.0d / 1209600))));
0947: }
0948:
0949: public static final Speed newCentimetersPerSecond(double v) {
0950: return new Speed(v * (1.0d / (100 / 1.0d)));
0951: }
0952:
0953: public static final Speed newCentimetersPerSecond(String s) {
0954: return new Speed((Double.valueOf(s).doubleValue())
0955: * (1.0d / (100 / 1.0d)));
0956: }
0957:
0958: public static final Speed newCentimetersPerMinute(double v) {
0959: return new Speed(v * (1.0d / (100 / (1.0d / 60))));
0960: }
0961:
0962: public static final Speed newCentimetersPerMinute(String s) {
0963: return new Speed((Double.valueOf(s).doubleValue())
0964: * (1.0d / (100 / (1.0d / 60))));
0965: }
0966:
0967: public static final Speed newCentimetersPerHour(double v) {
0968: return new Speed(v * (1.0d / (100 / (1.0d / 3600))));
0969: }
0970:
0971: public static final Speed newCentimetersPerHour(String s) {
0972: return new Speed((Double.valueOf(s).doubleValue())
0973: * (1.0d / (100 / (1.0d / 3600))));
0974: }
0975:
0976: public static final Speed newCentimetersPerDay(double v) {
0977: return new Speed(v * (1.0d / (100 / (1.0d / 86400))));
0978: }
0979:
0980: public static final Speed newCentimetersPerDay(String s) {
0981: return new Speed((Double.valueOf(s).doubleValue())
0982: * (1.0d / (100 / (1.0d / 86400))));
0983: }
0984:
0985: public static final Speed newCentimetersPerWeek(double v) {
0986: return new Speed(v * (1.0d / (100 / (1.0d / 604800))));
0987: }
0988:
0989: public static final Speed newCentimetersPerWeek(String s) {
0990: return new Speed((Double.valueOf(s).doubleValue())
0991: * (1.0d / (100 / (1.0d / 604800))));
0992: }
0993:
0994: public static final Speed newCentimetersPerMillisecond(double v) {
0995: return new Speed(v * (1.0d / (100 / 1000)));
0996: }
0997:
0998: public static final Speed newCentimetersPerMillisecond(String s) {
0999: return new Speed((Double.valueOf(s).doubleValue())
1000: * (1.0d / (100 / 1000)));
1001: }
1002:
1003: public static final Speed newCentimetersPerKilosecond(double v) {
1004: return new Speed(v * (1.0d / (100 / (1.0d / 1000))));
1005: }
1006:
1007: public static final Speed newCentimetersPerKilosecond(String s) {
1008: return new Speed((Double.valueOf(s).doubleValue())
1009: * (1.0d / (100 / (1.0d / 1000))));
1010: }
1011:
1012: public static final Speed newCentimetersPerMonth(double v) {
1013: return new Speed(v * (1.0d / (100 / (1.0d / 2629743.8))));
1014: }
1015:
1016: public static final Speed newCentimetersPerMonth(String s) {
1017: return new Speed((Double.valueOf(s).doubleValue())
1018: * (1.0d / (100 / (1.0d / 2629743.8))));
1019: }
1020:
1021: public static final Speed newCentimetersPerYear(double v) {
1022: return new Speed(v * (1.0d / (100 / (1.0d / 31556926))));
1023: }
1024:
1025: public static final Speed newCentimetersPerYear(String s) {
1026: return new Speed((Double.valueOf(s).doubleValue())
1027: * (1.0d / (100 / (1.0d / 31556926))));
1028: }
1029:
1030: public static final Speed newCentimetersPerFortnight(double v) {
1031: return new Speed(v * (1.0d / (100 / (1.0d / 1209600))));
1032: }
1033:
1034: public static final Speed newCentimetersPerFortnight(String s) {
1035: return new Speed((Double.valueOf(s).doubleValue())
1036: * (1.0d / (100 / (1.0d / 1209600))));
1037: }
1038:
1039: public static final Speed newMillimetersPerSecond(double v) {
1040: return new Speed(v * (1.0d / (1000 / 1.0d)));
1041: }
1042:
1043: public static final Speed newMillimetersPerSecond(String s) {
1044: return new Speed((Double.valueOf(s).doubleValue())
1045: * (1.0d / (1000 / 1.0d)));
1046: }
1047:
1048: public static final Speed newMillimetersPerMinute(double v) {
1049: return new Speed(v * (1.0d / (1000 / (1.0d / 60))));
1050: }
1051:
1052: public static final Speed newMillimetersPerMinute(String s) {
1053: return new Speed((Double.valueOf(s).doubleValue())
1054: * (1.0d / (1000 / (1.0d / 60))));
1055: }
1056:
1057: public static final Speed newMillimetersPerHour(double v) {
1058: return new Speed(v * (1.0d / (1000 / (1.0d / 3600))));
1059: }
1060:
1061: public static final Speed newMillimetersPerHour(String s) {
1062: return new Speed((Double.valueOf(s).doubleValue())
1063: * (1.0d / (1000 / (1.0d / 3600))));
1064: }
1065:
1066: public static final Speed newMillimetersPerDay(double v) {
1067: return new Speed(v * (1.0d / (1000 / (1.0d / 86400))));
1068: }
1069:
1070: public static final Speed newMillimetersPerDay(String s) {
1071: return new Speed((Double.valueOf(s).doubleValue())
1072: * (1.0d / (1000 / (1.0d / 86400))));
1073: }
1074:
1075: public static final Speed newMillimetersPerWeek(double v) {
1076: return new Speed(v * (1.0d / (1000 / (1.0d / 604800))));
1077: }
1078:
1079: public static final Speed newMillimetersPerWeek(String s) {
1080: return new Speed((Double.valueOf(s).doubleValue())
1081: * (1.0d / (1000 / (1.0d / 604800))));
1082: }
1083:
1084: public static final Speed newMillimetersPerMillisecond(double v) {
1085: return new Speed(v * (1.0d / (1000 / 1000)));
1086: }
1087:
1088: public static final Speed newMillimetersPerMillisecond(String s) {
1089: return new Speed((Double.valueOf(s).doubleValue())
1090: * (1.0d / (1000 / 1000)));
1091: }
1092:
1093: public static final Speed newMillimetersPerKilosecond(double v) {
1094: return new Speed(v * (1.0d / (1000 / (1.0d / 1000))));
1095: }
1096:
1097: public static final Speed newMillimetersPerKilosecond(String s) {
1098: return new Speed((Double.valueOf(s).doubleValue())
1099: * (1.0d / (1000 / (1.0d / 1000))));
1100: }
1101:
1102: public static final Speed newMillimetersPerMonth(double v) {
1103: return new Speed(v * (1.0d / (1000 / (1.0d / 2629743.8))));
1104: }
1105:
1106: public static final Speed newMillimetersPerMonth(String s) {
1107: return new Speed((Double.valueOf(s).doubleValue())
1108: * (1.0d / (1000 / (1.0d / 2629743.8))));
1109: }
1110:
1111: public static final Speed newMillimetersPerYear(double v) {
1112: return new Speed(v * (1.0d / (1000 / (1.0d / 31556926))));
1113: }
1114:
1115: public static final Speed newMillimetersPerYear(String s) {
1116: return new Speed((Double.valueOf(s).doubleValue())
1117: * (1.0d / (1000 / (1.0d / 31556926))));
1118: }
1119:
1120: public static final Speed newMillimetersPerFortnight(double v) {
1121: return new Speed(v * (1.0d / (1000 / (1.0d / 1209600))));
1122: }
1123:
1124: public static final Speed newMillimetersPerFortnight(String s) {
1125: return new Speed((Double.valueOf(s).doubleValue())
1126: * (1.0d / (1000 / (1.0d / 1209600))));
1127: }
1128:
1129: public static final Speed newFurlongsPerSecond(double v) {
1130: return new Speed(v * (1.0d / ((1.0d / 201.168) / 1.0d)));
1131: }
1132:
1133: public static final Speed newFurlongsPerSecond(String s) {
1134: return new Speed((Double.valueOf(s).doubleValue())
1135: * (1.0d / ((1.0d / 201.168) / 1.0d)));
1136: }
1137:
1138: public static final Speed newFurlongsPerMinute(double v) {
1139: return new Speed(v * (1.0d / ((1.0d / 201.168) / (1.0d / 60))));
1140: }
1141:
1142: public static final Speed newFurlongsPerMinute(String s) {
1143: return new Speed((Double.valueOf(s).doubleValue())
1144: * (1.0d / ((1.0d / 201.168) / (1.0d / 60))));
1145: }
1146:
1147: public static final Speed newFurlongsPerHour(double v) {
1148: return new Speed(v
1149: * (1.0d / ((1.0d / 201.168) / (1.0d / 3600))));
1150: }
1151:
1152: public static final Speed newFurlongsPerHour(String s) {
1153: return new Speed((Double.valueOf(s).doubleValue())
1154: * (1.0d / ((1.0d / 201.168) / (1.0d / 3600))));
1155: }
1156:
1157: public static final Speed newFurlongsPerDay(double v) {
1158: return new Speed(v
1159: * (1.0d / ((1.0d / 201.168) / (1.0d / 86400))));
1160: }
1161:
1162: public static final Speed newFurlongsPerDay(String s) {
1163: return new Speed((Double.valueOf(s).doubleValue())
1164: * (1.0d / ((1.0d / 201.168) / (1.0d / 86400))));
1165: }
1166:
1167: public static final Speed newFurlongsPerWeek(double v) {
1168: return new Speed(v
1169: * (1.0d / ((1.0d / 201.168) / (1.0d / 604800))));
1170: }
1171:
1172: public static final Speed newFurlongsPerWeek(String s) {
1173: return new Speed((Double.valueOf(s).doubleValue())
1174: * (1.0d / ((1.0d / 201.168) / (1.0d / 604800))));
1175: }
1176:
1177: public static final Speed newFurlongsPerMillisecond(double v) {
1178: return new Speed(v * (1.0d / ((1.0d / 201.168) / 1000)));
1179: }
1180:
1181: public static final Speed newFurlongsPerMillisecond(String s) {
1182: return new Speed((Double.valueOf(s).doubleValue())
1183: * (1.0d / ((1.0d / 201.168) / 1000)));
1184: }
1185:
1186: public static final Speed newFurlongsPerKilosecond(double v) {
1187: return new Speed(v
1188: * (1.0d / ((1.0d / 201.168) / (1.0d / 1000))));
1189: }
1190:
1191: public static final Speed newFurlongsPerKilosecond(String s) {
1192: return new Speed((Double.valueOf(s).doubleValue())
1193: * (1.0d / ((1.0d / 201.168) / (1.0d / 1000))));
1194: }
1195:
1196: public static final Speed newFurlongsPerMonth(double v) {
1197: return new Speed(v
1198: * (1.0d / ((1.0d / 201.168) / (1.0d / 2629743.8))));
1199: }
1200:
1201: public static final Speed newFurlongsPerMonth(String s) {
1202: return new Speed((Double.valueOf(s).doubleValue())
1203: * (1.0d / ((1.0d / 201.168) / (1.0d / 2629743.8))));
1204: }
1205:
1206: public static final Speed newFurlongsPerYear(double v) {
1207: return new Speed(v
1208: * (1.0d / ((1.0d / 201.168) / (1.0d / 31556926))));
1209: }
1210:
1211: public static final Speed newFurlongsPerYear(String s) {
1212: return new Speed((Double.valueOf(s).doubleValue())
1213: * (1.0d / ((1.0d / 201.168) / (1.0d / 31556926))));
1214: }
1215:
1216: public static final Speed newFurlongsPerFortnight(double v) {
1217: return new Speed(v
1218: * (1.0d / ((1.0d / 201.168) / (1.0d / 1209600))));
1219: }
1220:
1221: public static final Speed newFurlongsPerFortnight(String s) {
1222: return new Speed((Double.valueOf(s).doubleValue())
1223: * (1.0d / ((1.0d / 201.168) / (1.0d / 1209600))));
1224: }
1225:
1226: public int getCommonUnit() {
1227: return 12;
1228: }
1229:
1230: public int getMaxUnit() {
1231: return MAXUNIT;
1232: }
1233:
1234: // unit names for getUnitName
1235: private static final String unitNames[] = { "meters/second",
1236: "meters/minute", "meters/hour", "meters/day",
1237: "meters/week", "meters/millisecond", "meters/kilosecond",
1238: "meters/month", "meters/year", "meters/fortnight",
1239: "miles/second", "miles/minute", "miles/hour", "miles/day",
1240: "miles/week", "miles/millisecond", "miles/kilosecond",
1241: "miles/month", "miles/year", "miles/fortnight",
1242: "nautical_miles/second", "nautical_miles/minute",
1243: "nautical_miles/hour", "nautical_miles/day",
1244: "nautical_miles/week", "nautical_miles/millisecond",
1245: "nautical_miles/kilosecond", "nautical_miles/month",
1246: "nautical_miles/year", "nautical_miles/fortnight",
1247: "yards/second", "yards/minute", "yards/hour", "yards/day",
1248: "yards/week", "yards/millisecond", "yards/kilosecond",
1249: "yards/month", "yards/year", "yards/fortnight",
1250: "feet/second", "feet/minute", "feet/hour", "feet/day",
1251: "feet/week", "feet/millisecond", "feet/kilosecond",
1252: "feet/month", "feet/year", "feet/fortnight",
1253: "inches/second", "inches/minute", "inches/hour",
1254: "inches/day", "inches/week", "inches/millisecond",
1255: "inches/kilosecond", "inches/month", "inches/year",
1256: "inches/fortnight", "kilometers/second",
1257: "kilometers/minute", "kilometers/hour", "kilometers/day",
1258: "kilometers/week", "kilometers/millisecond",
1259: "kilometers/kilosecond", "kilometers/month",
1260: "kilometers/year", "kilometers/fortnight",
1261: "centimeters/second", "centimeters/minute",
1262: "centimeters/hour", "centimeters/day", "centimeters/week",
1263: "centimeters/millisecond", "centimeters/kilosecond",
1264: "centimeters/month", "centimeters/year",
1265: "centimeters/fortnight", "millimeters/second",
1266: "millimeters/minute", "millimeters/hour",
1267: "millimeters/day", "millimeters/week",
1268: "millimeters/millisecond", "millimeters/kilosecond",
1269: "millimeters/month", "millimeters/year",
1270: "millimeters/fortnight", "furlongs/second",
1271: "furlongs/minute", "furlongs/hour", "furlongs/day",
1272: "furlongs/week", "furlongs/millisecond",
1273: "furlongs/kilosecond", "furlongs/month", "furlongs/year",
1274: "furlongs/fortnight", };
1275:
1276: /** @param unit One of the constant units of Speed **/
1277: public final String getUnitName(int unit) {
1278: return unitNames[unit];
1279: }
1280:
1281: // Index Typed factory methods
1282: static final double convFactor[] = { (1.0d / 1.0d),
1283: (1.0d / (1.0d / 60)), (1.0d / (1.0d / 3600)),
1284: (1.0d / (1.0d / 86400)), (1.0d / (1.0d / 604800)),
1285: (1.0d / 1000), (1.0d / (1.0d / 1000)),
1286: (1.0d / (1.0d / 2629743.8)), (1.0d / (1.0d / 31556926)),
1287: (1.0d / (1.0d / 1209600)), ((1.0d / 1609.344) / 1.0d),
1288: ((1.0d / 1609.344) / (1.0d / 60)),
1289: ((1.0d / 1609.344) / (1.0d / 3600)),
1290: ((1.0d / 1609.344) / (1.0d / 86400)),
1291: ((1.0d / 1609.344) / (1.0d / 604800)),
1292: ((1.0d / 1609.344) / 1000),
1293: ((1.0d / 1609.344) / (1.0d / 1000)),
1294: ((1.0d / 1609.344) / (1.0d / 2629743.8)),
1295: ((1.0d / 1609.344) / (1.0d / 31556926)),
1296: ((1.0d / 1609.344) / (1.0d / 1209600)),
1297: ((1.0d / 1852.0) / 1.0d), ((1.0d / 1852.0) / (1.0d / 60)),
1298: ((1.0d / 1852.0) / (1.0d / 3600)),
1299: ((1.0d / 1852.0) / (1.0d / 86400)),
1300: ((1.0d / 1852.0) / (1.0d / 604800)),
1301: ((1.0d / 1852.0) / 1000),
1302: ((1.0d / 1852.0) / (1.0d / 1000)),
1303: ((1.0d / 1852.0) / (1.0d / 2629743.8)),
1304: ((1.0d / 1852.0) / (1.0d / 31556926)),
1305: ((1.0d / 1852.0) / (1.0d / 1209600)),
1306: ((1.0d / 0.9414) / 1.0d), ((1.0d / 0.9414) / (1.0d / 60)),
1307: ((1.0d / 0.9414) / (1.0d / 3600)),
1308: ((1.0d / 0.9414) / (1.0d / 86400)),
1309: ((1.0d / 0.9414) / (1.0d / 604800)),
1310: ((1.0d / 0.9414) / 1000),
1311: ((1.0d / 0.9414) / (1.0d / 1000)),
1312: ((1.0d / 0.9414) / (1.0d / 2629743.8)),
1313: ((1.0d / 0.9414) / (1.0d / 31556926)),
1314: ((1.0d / 0.9414) / (1.0d / 1209600)),
1315: ((1.0d / 0.3048) / 1.0d), ((1.0d / 0.3048) / (1.0d / 60)),
1316: ((1.0d / 0.3048) / (1.0d / 3600)),
1317: ((1.0d / 0.3048) / (1.0d / 86400)),
1318: ((1.0d / 0.3048) / (1.0d / 604800)),
1319: ((1.0d / 0.3048) / 1000),
1320: ((1.0d / 0.3048) / (1.0d / 1000)),
1321: ((1.0d / 0.3048) / (1.0d / 2629743.8)),
1322: ((1.0d / 0.3048) / (1.0d / 31556926)),
1323: ((1.0d / 0.3048) / (1.0d / 1209600)),
1324: ((1.0d / 0.0254) / 1.0d), ((1.0d / 0.0254) / (1.0d / 60)),
1325: ((1.0d / 0.0254) / (1.0d / 3600)),
1326: ((1.0d / 0.0254) / (1.0d / 86400)),
1327: ((1.0d / 0.0254) / (1.0d / 604800)),
1328: ((1.0d / 0.0254) / 1000),
1329: ((1.0d / 0.0254) / (1.0d / 1000)),
1330: ((1.0d / 0.0254) / (1.0d / 2629743.8)),
1331: ((1.0d / 0.0254) / (1.0d / 31556926)),
1332: ((1.0d / 0.0254) / (1.0d / 1209600)),
1333: ((1.0d / 1000.0) / 1.0d), ((1.0d / 1000.0) / (1.0d / 60)),
1334: ((1.0d / 1000.0) / (1.0d / 3600)),
1335: ((1.0d / 1000.0) / (1.0d / 86400)),
1336: ((1.0d / 1000.0) / (1.0d / 604800)),
1337: ((1.0d / 1000.0) / 1000),
1338: ((1.0d / 1000.0) / (1.0d / 1000)),
1339: ((1.0d / 1000.0) / (1.0d / 2629743.8)),
1340: ((1.0d / 1000.0) / (1.0d / 31556926)),
1341: ((1.0d / 1000.0) / (1.0d / 1209600)), (100 / 1.0d),
1342: (100 / (1.0d / 60)), (100 / (1.0d / 3600)),
1343: (100 / (1.0d / 86400)), (100 / (1.0d / 604800)),
1344: (100 / 1000), (100 / (1.0d / 1000)),
1345: (100 / (1.0d / 2629743.8)), (100 / (1.0d / 31556926)),
1346: (100 / (1.0d / 1209600)), (1000 / 1.0d),
1347: (1000 / (1.0d / 60)), (1000 / (1.0d / 3600)),
1348: (1000 / (1.0d / 86400)), (1000 / (1.0d / 604800)),
1349: (1000 / 1000), (1000 / (1.0d / 1000)),
1350: (1000 / (1.0d / 2629743.8)), (1000 / (1.0d / 31556926)),
1351: (1000 / (1.0d / 1209600)), ((1.0d / 201.168) / 1.0d),
1352: ((1.0d / 201.168) / (1.0d / 60)),
1353: ((1.0d / 201.168) / (1.0d / 3600)),
1354: ((1.0d / 201.168) / (1.0d / 86400)),
1355: ((1.0d / 201.168) / (1.0d / 604800)),
1356: ((1.0d / 201.168) / 1000),
1357: ((1.0d / 201.168) / (1.0d / 1000)),
1358: ((1.0d / 201.168) / (1.0d / 2629743.8)),
1359: ((1.0d / 201.168) / (1.0d / 31556926)),
1360: ((1.0d / 201.168) / (1.0d / 1209600)), };
1361:
1362: public static final double getConvFactor(int i) {
1363: return convFactor[i];
1364: }
1365:
1366: // indexes into factor array
1367: public static final int METERS_PER_SECOND = 0;
1368: public static final int METERS_PER_MINUTE = 1;
1369: public static final int METERS_PER_HOUR = 2;
1370: public static final int METERS_PER_DAY = 3;
1371: public static final int METERS_PER_WEEK = 4;
1372: public static final int METERS_PER_MILLISECOND = 5;
1373: public static final int METERS_PER_KILOSECOND = 6;
1374: public static final int METERS_PER_MONTH = 7;
1375: public static final int METERS_PER_YEAR = 8;
1376: public static final int METERS_PER_FORTNIGHT = 9;
1377: public static final int MILES_PER_SECOND = 10;
1378: public static final int MILES_PER_MINUTE = 11;
1379: public static final int MILES_PER_HOUR = 12;
1380: public static final int MILES_PER_DAY = 13;
1381: public static final int MILES_PER_WEEK = 14;
1382: public static final int MILES_PER_MILLISECOND = 15;
1383: public static final int MILES_PER_KILOSECOND = 16;
1384: public static final int MILES_PER_MONTH = 17;
1385: public static final int MILES_PER_YEAR = 18;
1386: public static final int MILES_PER_FORTNIGHT = 19;
1387: public static final int NAUTICAL_MILES_PER_SECOND = 20;
1388: public static final int NAUTICAL_MILES_PER_MINUTE = 21;
1389: public static final int NAUTICAL_MILES_PER_HOUR = 22;
1390: public static final int NAUTICAL_MILES_PER_DAY = 23;
1391: public static final int NAUTICAL_MILES_PER_WEEK = 24;
1392: public static final int NAUTICAL_MILES_PER_MILLISECOND = 25;
1393: public static final int NAUTICAL_MILES_PER_KILOSECOND = 26;
1394: public static final int NAUTICAL_MILES_PER_MONTH = 27;
1395: public static final int NAUTICAL_MILES_PER_YEAR = 28;
1396: public static final int NAUTICAL_MILES_PER_FORTNIGHT = 29;
1397: public static final int YARDS_PER_SECOND = 30;
1398: public static final int YARDS_PER_MINUTE = 31;
1399: public static final int YARDS_PER_HOUR = 32;
1400: public static final int YARDS_PER_DAY = 33;
1401: public static final int YARDS_PER_WEEK = 34;
1402: public static final int YARDS_PER_MILLISECOND = 35;
1403: public static final int YARDS_PER_KILOSECOND = 36;
1404: public static final int YARDS_PER_MONTH = 37;
1405: public static final int YARDS_PER_YEAR = 38;
1406: public static final int YARDS_PER_FORTNIGHT = 39;
1407: public static final int FEET_PER_SECOND = 40;
1408: public static final int FEET_PER_MINUTE = 41;
1409: public static final int FEET_PER_HOUR = 42;
1410: public static final int FEET_PER_DAY = 43;
1411: public static final int FEET_PER_WEEK = 44;
1412: public static final int FEET_PER_MILLISECOND = 45;
1413: public static final int FEET_PER_KILOSECOND = 46;
1414: public static final int FEET_PER_MONTH = 47;
1415: public static final int FEET_PER_YEAR = 48;
1416: public static final int FEET_PER_FORTNIGHT = 49;
1417: public static final int INCHES_PER_SECOND = 50;
1418: public static final int INCHES_PER_MINUTE = 51;
1419: public static final int INCHES_PER_HOUR = 52;
1420: public static final int INCHES_PER_DAY = 53;
1421: public static final int INCHES_PER_WEEK = 54;
1422: public static final int INCHES_PER_MILLISECOND = 55;
1423: public static final int INCHES_PER_KILOSECOND = 56;
1424: public static final int INCHES_PER_MONTH = 57;
1425: public static final int INCHES_PER_YEAR = 58;
1426: public static final int INCHES_PER_FORTNIGHT = 59;
1427: public static final int KILOMETERS_PER_SECOND = 60;
1428: public static final int KILOMETERS_PER_MINUTE = 61;
1429: public static final int KILOMETERS_PER_HOUR = 62;
1430: public static final int KILOMETERS_PER_DAY = 63;
1431: public static final int KILOMETERS_PER_WEEK = 64;
1432: public static final int KILOMETERS_PER_MILLISECOND = 65;
1433: public static final int KILOMETERS_PER_KILOSECOND = 66;
1434: public static final int KILOMETERS_PER_MONTH = 67;
1435: public static final int KILOMETERS_PER_YEAR = 68;
1436: public static final int KILOMETERS_PER_FORTNIGHT = 69;
1437: public static final int CENTIMETERS_PER_SECOND = 70;
1438: public static final int CENTIMETERS_PER_MINUTE = 71;
1439: public static final int CENTIMETERS_PER_HOUR = 72;
1440: public static final int CENTIMETERS_PER_DAY = 73;
1441: public static final int CENTIMETERS_PER_WEEK = 74;
1442: public static final int CENTIMETERS_PER_MILLISECOND = 75;
1443: public static final int CENTIMETERS_PER_KILOSECOND = 76;
1444: public static final int CENTIMETERS_PER_MONTH = 77;
1445: public static final int CENTIMETERS_PER_YEAR = 78;
1446: public static final int CENTIMETERS_PER_FORTNIGHT = 79;
1447: public static final int MILLIMETERS_PER_SECOND = 80;
1448: public static final int MILLIMETERS_PER_MINUTE = 81;
1449: public static final int MILLIMETERS_PER_HOUR = 82;
1450: public static final int MILLIMETERS_PER_DAY = 83;
1451: public static final int MILLIMETERS_PER_WEEK = 84;
1452: public static final int MILLIMETERS_PER_MILLISECOND = 85;
1453: public static final int MILLIMETERS_PER_KILOSECOND = 86;
1454: public static final int MILLIMETERS_PER_MONTH = 87;
1455: public static final int MILLIMETERS_PER_YEAR = 88;
1456: public static final int MILLIMETERS_PER_FORTNIGHT = 89;
1457: public static final int FURLONGS_PER_SECOND = 90;
1458: public static final int FURLONGS_PER_MINUTE = 91;
1459: public static final int FURLONGS_PER_HOUR = 92;
1460: public static final int FURLONGS_PER_DAY = 93;
1461: public static final int FURLONGS_PER_WEEK = 94;
1462: public static final int FURLONGS_PER_MILLISECOND = 95;
1463: public static final int FURLONGS_PER_KILOSECOND = 96;
1464: public static final int FURLONGS_PER_MONTH = 97;
1465: public static final int FURLONGS_PER_YEAR = 98;
1466: public static final int FURLONGS_PER_FORTNIGHT = 99;
1467: static final int MAXUNIT = 99;
1468:
1469: // Index Typed factory methods
1470: /** @param unit One of the constant units of Speed **/
1471: public static final Speed newSpeed(double v, int unit) {
1472: if (unit >= 0 && unit <= MAXUNIT)
1473: return new Speed(v * getConvFactor(unit));
1474: else
1475: throw new UnknownUnitException();
1476: }
1477:
1478: /** @param unit One of the constant units of Speed **/
1479: public static final Speed newSpeed(String s, int unit) {
1480: if (unit >= 0 && unit <= MAXUNIT)
1481: return new Speed((Double.valueOf(s).doubleValue())
1482: * getConvFactor(unit));
1483: else
1484: throw new UnknownUnitException();
1485: }
1486:
1487: // Index Typed factory methods
1488: /** @param unit1 One of the constant units of Distance
1489: * @param unit2 One of the constant units of Duration
1490: **/
1491: public static final Speed newSpeed(double v, int unit1, int unit2) {
1492: if (unit1 >= 0 && unit1 <= Distance.MAXUNIT && unit2 >= 0
1493: && unit2 <= Duration.MAXUNIT)
1494: return new Speed(v * Distance.getConvFactor(unit1)
1495: / Duration.getConvFactor(unit2));
1496: else
1497: throw new UnknownUnitException();
1498: }
1499:
1500: /** @param num An instance of Distance to use as numerator
1501: * @param den An instance of Durationto use as denominator
1502: **/
1503: public static final Speed newSpeed(Distance num, Duration den) {
1504: return new Speed(num.getValue(0) / den.getValue(0));
1505: }
1506:
1507: /** @param unit1 One of the constant units of Distance
1508: * @param unit2 One of the constant units of Duration
1509: **/
1510: public static final Speed newSpeed(String s, int unit1, int unit2) {
1511: if (unit1 >= 0 && unit1 <= Distance.MAXUNIT && unit2 >= 0
1512: && unit2 <= Duration.MAXUNIT)
1513: return new Speed((Double.valueOf(s).doubleValue())
1514: * Distance.getConvFactor(unit1)
1515: / Duration.getConvFactor(unit2));
1516: else
1517: throw new UnknownUnitException();
1518: }
1519:
1520: // Support for AbstractMeasure-level constructor
1521: public static final AbstractMeasure newMeasure(String s, int unit) {
1522: return newSpeed(s, unit);
1523: }
1524:
1525: public static final AbstractMeasure newMeasure(double v, int unit) {
1526: return newSpeed(v, unit);
1527: }
1528:
1529: // simple math : addition and subtraction
1530: public final Measure add(Measure toAdd) {
1531: if (!(toAdd instanceof Speed))
1532: throw new IllegalArgumentException();
1533: return new Speed(theValue + toAdd.getNativeValue());
1534: }
1535:
1536: public final Measure subtract(Measure toSubtract) {
1537: if (!(toSubtract instanceof Speed))
1538: throw new IllegalArgumentException();
1539: return new Speed(theValue - toSubtract.getNativeValue());
1540: }
1541:
1542: public final Measure scale(double scale) {
1543: return new Speed(theValue * scale, 0);
1544: }
1545:
1546: public final Measure negate() {
1547: return newSpeed(-1 * theValue, 0);
1548: }
1549:
1550: public final Measure floor(int unit) {
1551: return newSpeed(Math.floor(getValue(unit)), 0);
1552: }
1553:
1554: public final Measure valueOf(double value) {
1555: return new Speed(value);
1556: }
1557:
1558: public final Measure valueOf(double value, int unit) {
1559: return new Speed(value, unit);
1560: }
1561:
1562: public final double getNativeValue() {
1563: return theValue;
1564: }
1565:
1566: public final int getNativeUnit() {
1567: return 0;
1568: }
1569:
1570: public final Duration divide(Rate toRate) {
1571: throw new IllegalArgumentException(
1572: "Call divideRate instead to divide one Rate by another.");
1573: }
1574:
1575: public final double divideRate(Rate toRate) {
1576: if (toRate.getCanonicalNumerator().getClass() != getCanonicalNumerator()
1577: .getClass()
1578: || toRate.getCanonicalDenominator().getClass() != getCanonicalDenominator()
1579: .getClass()) {
1580: throw new IllegalArgumentException("Expecting a Speed"
1581: + ", got a "
1582: + toRate.getCanonicalNumerator().getClass() + "/"
1583: + toRate.getCanonicalDenominator().getClass());
1584: }
1585: return theValue / toRate.getNativeValue();
1586: }
1587:
1588: // Unit-based Reader methods
1589: public double getMetersPerSecond() {
1590: return (theValue * (1.0d / 1.0d));
1591: }
1592:
1593: public double getMetersPerMinute() {
1594: return (theValue * (1.0d / (1.0d / 60)));
1595: }
1596:
1597: public double getMetersPerHour() {
1598: return (theValue * (1.0d / (1.0d / 3600)));
1599: }
1600:
1601: public double getMetersPerDay() {
1602: return (theValue * (1.0d / (1.0d / 86400)));
1603: }
1604:
1605: public double getMetersPerWeek() {
1606: return (theValue * (1.0d / (1.0d / 604800)));
1607: }
1608:
1609: public double getMetersPerMillisecond() {
1610: return (theValue * (1.0d / 1000));
1611: }
1612:
1613: public double getMetersPerKilosecond() {
1614: return (theValue * (1.0d / (1.0d / 1000)));
1615: }
1616:
1617: public double getMetersPerMonth() {
1618: return (theValue * (1.0d / (1.0d / 2629743.8)));
1619: }
1620:
1621: public double getMetersPerYear() {
1622: return (theValue * (1.0d / (1.0d / 31556926)));
1623: }
1624:
1625: public double getMetersPerFortnight() {
1626: return (theValue * (1.0d / (1.0d / 1209600)));
1627: }
1628:
1629: public double getMilesPerSecond() {
1630: return (theValue * ((1.0d / 1609.344) / 1.0d));
1631: }
1632:
1633: public double getMilesPerMinute() {
1634: return (theValue * ((1.0d / 1609.344) / (1.0d / 60)));
1635: }
1636:
1637: public double getMilesPerHour() {
1638: return (theValue * ((1.0d / 1609.344) / (1.0d / 3600)));
1639: }
1640:
1641: public double getMilesPerDay() {
1642: return (theValue * ((1.0d / 1609.344) / (1.0d / 86400)));
1643: }
1644:
1645: public double getMilesPerWeek() {
1646: return (theValue * ((1.0d / 1609.344) / (1.0d / 604800)));
1647: }
1648:
1649: public double getMilesPerMillisecond() {
1650: return (theValue * ((1.0d / 1609.344) / 1000));
1651: }
1652:
1653: public double getMilesPerKilosecond() {
1654: return (theValue * ((1.0d / 1609.344) / (1.0d / 1000)));
1655: }
1656:
1657: public double getMilesPerMonth() {
1658: return (theValue * ((1.0d / 1609.344) / (1.0d / 2629743.8)));
1659: }
1660:
1661: public double getMilesPerYear() {
1662: return (theValue * ((1.0d / 1609.344) / (1.0d / 31556926)));
1663: }
1664:
1665: public double getMilesPerFortnight() {
1666: return (theValue * ((1.0d / 1609.344) / (1.0d / 1209600)));
1667: }
1668:
1669: public double getNauticalMilesPerSecond() {
1670: return (theValue * ((1.0d / 1852.0) / 1.0d));
1671: }
1672:
1673: public double getNauticalMilesPerMinute() {
1674: return (theValue * ((1.0d / 1852.0) / (1.0d / 60)));
1675: }
1676:
1677: public double getNauticalMilesPerHour() {
1678: return (theValue * ((1.0d / 1852.0) / (1.0d / 3600)));
1679: }
1680:
1681: public double getNauticalMilesPerDay() {
1682: return (theValue * ((1.0d / 1852.0) / (1.0d / 86400)));
1683: }
1684:
1685: public double getNauticalMilesPerWeek() {
1686: return (theValue * ((1.0d / 1852.0) / (1.0d / 604800)));
1687: }
1688:
1689: public double getNauticalMilesPerMillisecond() {
1690: return (theValue * ((1.0d / 1852.0) / 1000));
1691: }
1692:
1693: public double getNauticalMilesPerKilosecond() {
1694: return (theValue * ((1.0d / 1852.0) / (1.0d / 1000)));
1695: }
1696:
1697: public double getNauticalMilesPerMonth() {
1698: return (theValue * ((1.0d / 1852.0) / (1.0d / 2629743.8)));
1699: }
1700:
1701: public double getNauticalMilesPerYear() {
1702: return (theValue * ((1.0d / 1852.0) / (1.0d / 31556926)));
1703: }
1704:
1705: public double getNauticalMilesPerFortnight() {
1706: return (theValue * ((1.0d / 1852.0) / (1.0d / 1209600)));
1707: }
1708:
1709: public double getYardsPerSecond() {
1710: return (theValue * ((1.0d / 0.9414) / 1.0d));
1711: }
1712:
1713: public double getYardsPerMinute() {
1714: return (theValue * ((1.0d / 0.9414) / (1.0d / 60)));
1715: }
1716:
1717: public double getYardsPerHour() {
1718: return (theValue * ((1.0d / 0.9414) / (1.0d / 3600)));
1719: }
1720:
1721: public double getYardsPerDay() {
1722: return (theValue * ((1.0d / 0.9414) / (1.0d / 86400)));
1723: }
1724:
1725: public double getYardsPerWeek() {
1726: return (theValue * ((1.0d / 0.9414) / (1.0d / 604800)));
1727: }
1728:
1729: public double getYardsPerMillisecond() {
1730: return (theValue * ((1.0d / 0.9414) / 1000));
1731: }
1732:
1733: public double getYardsPerKilosecond() {
1734: return (theValue * ((1.0d / 0.9414) / (1.0d / 1000)));
1735: }
1736:
1737: public double getYardsPerMonth() {
1738: return (theValue * ((1.0d / 0.9414) / (1.0d / 2629743.8)));
1739: }
1740:
1741: public double getYardsPerYear() {
1742: return (theValue * ((1.0d / 0.9414) / (1.0d / 31556926)));
1743: }
1744:
1745: public double getYardsPerFortnight() {
1746: return (theValue * ((1.0d / 0.9414) / (1.0d / 1209600)));
1747: }
1748:
1749: public double getFeetPerSecond() {
1750: return (theValue * ((1.0d / 0.3048) / 1.0d));
1751: }
1752:
1753: public double getFeetPerMinute() {
1754: return (theValue * ((1.0d / 0.3048) / (1.0d / 60)));
1755: }
1756:
1757: public double getFeetPerHour() {
1758: return (theValue * ((1.0d / 0.3048) / (1.0d / 3600)));
1759: }
1760:
1761: public double getFeetPerDay() {
1762: return (theValue * ((1.0d / 0.3048) / (1.0d / 86400)));
1763: }
1764:
1765: public double getFeetPerWeek() {
1766: return (theValue * ((1.0d / 0.3048) / (1.0d / 604800)));
1767: }
1768:
1769: public double getFeetPerMillisecond() {
1770: return (theValue * ((1.0d / 0.3048) / 1000));
1771: }
1772:
1773: public double getFeetPerKilosecond() {
1774: return (theValue * ((1.0d / 0.3048) / (1.0d / 1000)));
1775: }
1776:
1777: public double getFeetPerMonth() {
1778: return (theValue * ((1.0d / 0.3048) / (1.0d / 2629743.8)));
1779: }
1780:
1781: public double getFeetPerYear() {
1782: return (theValue * ((1.0d / 0.3048) / (1.0d / 31556926)));
1783: }
1784:
1785: public double getFeetPerFortnight() {
1786: return (theValue * ((1.0d / 0.3048) / (1.0d / 1209600)));
1787: }
1788:
1789: public double getInchesPerSecond() {
1790: return (theValue * ((1.0d / 0.0254) / 1.0d));
1791: }
1792:
1793: public double getInchesPerMinute() {
1794: return (theValue * ((1.0d / 0.0254) / (1.0d / 60)));
1795: }
1796:
1797: public double getInchesPerHour() {
1798: return (theValue * ((1.0d / 0.0254) / (1.0d / 3600)));
1799: }
1800:
1801: public double getInchesPerDay() {
1802: return (theValue * ((1.0d / 0.0254) / (1.0d / 86400)));
1803: }
1804:
1805: public double getInchesPerWeek() {
1806: return (theValue * ((1.0d / 0.0254) / (1.0d / 604800)));
1807: }
1808:
1809: public double getInchesPerMillisecond() {
1810: return (theValue * ((1.0d / 0.0254) / 1000));
1811: }
1812:
1813: public double getInchesPerKilosecond() {
1814: return (theValue * ((1.0d / 0.0254) / (1.0d / 1000)));
1815: }
1816:
1817: public double getInchesPerMonth() {
1818: return (theValue * ((1.0d / 0.0254) / (1.0d / 2629743.8)));
1819: }
1820:
1821: public double getInchesPerYear() {
1822: return (theValue * ((1.0d / 0.0254) / (1.0d / 31556926)));
1823: }
1824:
1825: public double getInchesPerFortnight() {
1826: return (theValue * ((1.0d / 0.0254) / (1.0d / 1209600)));
1827: }
1828:
1829: public double getKilometersPerSecond() {
1830: return (theValue * ((1.0d / 1000.0) / 1.0d));
1831: }
1832:
1833: public double getKilometersPerMinute() {
1834: return (theValue * ((1.0d / 1000.0) / (1.0d / 60)));
1835: }
1836:
1837: public double getKilometersPerHour() {
1838: return (theValue * ((1.0d / 1000.0) / (1.0d / 3600)));
1839: }
1840:
1841: public double getKilometersPerDay() {
1842: return (theValue * ((1.0d / 1000.0) / (1.0d / 86400)));
1843: }
1844:
1845: public double getKilometersPerWeek() {
1846: return (theValue * ((1.0d / 1000.0) / (1.0d / 604800)));
1847: }
1848:
1849: public double getKilometersPerMillisecond() {
1850: return (theValue * ((1.0d / 1000.0) / 1000));
1851: }
1852:
1853: public double getKilometersPerKilosecond() {
1854: return (theValue * ((1.0d / 1000.0) / (1.0d / 1000)));
1855: }
1856:
1857: public double getKilometersPerMonth() {
1858: return (theValue * ((1.0d / 1000.0) / (1.0d / 2629743.8)));
1859: }
1860:
1861: public double getKilometersPerYear() {
1862: return (theValue * ((1.0d / 1000.0) / (1.0d / 31556926)));
1863: }
1864:
1865: public double getKilometersPerFortnight() {
1866: return (theValue * ((1.0d / 1000.0) / (1.0d / 1209600)));
1867: }
1868:
1869: public double getCentimetersPerSecond() {
1870: return (theValue * (100 / 1.0d));
1871: }
1872:
1873: public double getCentimetersPerMinute() {
1874: return (theValue * (100 / (1.0d / 60)));
1875: }
1876:
1877: public double getCentimetersPerHour() {
1878: return (theValue * (100 / (1.0d / 3600)));
1879: }
1880:
1881: public double getCentimetersPerDay() {
1882: return (theValue * (100 / (1.0d / 86400)));
1883: }
1884:
1885: public double getCentimetersPerWeek() {
1886: return (theValue * (100 / (1.0d / 604800)));
1887: }
1888:
1889: public double getCentimetersPerMillisecond() {
1890: return (theValue * (100 / 1000));
1891: }
1892:
1893: public double getCentimetersPerKilosecond() {
1894: return (theValue * (100 / (1.0d / 1000)));
1895: }
1896:
1897: public double getCentimetersPerMonth() {
1898: return (theValue * (100 / (1.0d / 2629743.8)));
1899: }
1900:
1901: public double getCentimetersPerYear() {
1902: return (theValue * (100 / (1.0d / 31556926)));
1903: }
1904:
1905: public double getCentimetersPerFortnight() {
1906: return (theValue * (100 / (1.0d / 1209600)));
1907: }
1908:
1909: public double getMillimetersPerSecond() {
1910: return (theValue * (1000 / 1.0d));
1911: }
1912:
1913: public double getMillimetersPerMinute() {
1914: return (theValue * (1000 / (1.0d / 60)));
1915: }
1916:
1917: public double getMillimetersPerHour() {
1918: return (theValue * (1000 / (1.0d / 3600)));
1919: }
1920:
1921: public double getMillimetersPerDay() {
1922: return (theValue * (1000 / (1.0d / 86400)));
1923: }
1924:
1925: public double getMillimetersPerWeek() {
1926: return (theValue * (1000 / (1.0d / 604800)));
1927: }
1928:
1929: public double getMillimetersPerMillisecond() {
1930: return (theValue * (1000 / 1000));
1931: }
1932:
1933: public double getMillimetersPerKilosecond() {
1934: return (theValue * (1000 / (1.0d / 1000)));
1935: }
1936:
1937: public double getMillimetersPerMonth() {
1938: return (theValue * (1000 / (1.0d / 2629743.8)));
1939: }
1940:
1941: public double getMillimetersPerYear() {
1942: return (theValue * (1000 / (1.0d / 31556926)));
1943: }
1944:
1945: public double getMillimetersPerFortnight() {
1946: return (theValue * (1000 / (1.0d / 1209600)));
1947: }
1948:
1949: public double getFurlongsPerSecond() {
1950: return (theValue * ((1.0d / 201.168) / 1.0d));
1951: }
1952:
1953: public double getFurlongsPerMinute() {
1954: return (theValue * ((1.0d / 201.168) / (1.0d / 60)));
1955: }
1956:
1957: public double getFurlongsPerHour() {
1958: return (theValue * ((1.0d / 201.168) / (1.0d / 3600)));
1959: }
1960:
1961: public double getFurlongsPerDay() {
1962: return (theValue * ((1.0d / 201.168) / (1.0d / 86400)));
1963: }
1964:
1965: public double getFurlongsPerWeek() {
1966: return (theValue * ((1.0d / 201.168) / (1.0d / 604800)));
1967: }
1968:
1969: public double getFurlongsPerMillisecond() {
1970: return (theValue * ((1.0d / 201.168) / 1000));
1971: }
1972:
1973: public double getFurlongsPerKilosecond() {
1974: return (theValue * ((1.0d / 201.168) / (1.0d / 1000)));
1975: }
1976:
1977: public double getFurlongsPerMonth() {
1978: return (theValue * ((1.0d / 201.168) / (1.0d / 2629743.8)));
1979: }
1980:
1981: public double getFurlongsPerYear() {
1982: return (theValue * ((1.0d / 201.168) / (1.0d / 31556926)));
1983: }
1984:
1985: public double getFurlongsPerFortnight() {
1986: return (theValue * ((1.0d / 201.168) / (1.0d / 1209600)));
1987: }
1988:
1989: /** @param unit One of the constant units of Speed **/
1990: public double getValue(int unit) {
1991: if (unit >= 0 && unit <= MAXUNIT)
1992: return (theValue * getConvFactor(unit));
1993: else
1994: throw new UnknownUnitException();
1995: }
1996:
1997: /** @param unit1 One of the constant units of Distance
1998: * @param unit2 One of the constant units of Duration
1999: **/
2000: public double getValue(int unit1, int unit2) {
2001: if (unit1 >= 0 && unit1 <= Distance.MAXUNIT && unit2 >= 0
2002: && unit2 <= Duration.MAXUNIT)
2003: return (theValue * Duration.getConvFactor(unit2) / Distance
2004: .getConvFactor(unit1));
2005: else
2006: throw new UnknownUnitException();
2007: }
2008:
2009: public boolean equals(Object o) {
2010: return (o instanceof Speed && theValue == ((Speed) o).theValue);
2011: }
2012:
2013: public String toString() {
2014: return Double.toString(theValue) + "m/s";
2015: }
2016:
2017: public int hashCode() {
2018: return (new Double(theValue)).hashCode();
2019: }
2020:
2021: // Derivative
2022: public final Class getNumeratorClass() {
2023: return Distance.class;
2024: }
2025:
2026: public final Class getDenominatorClass() {
2027: return Duration.class;
2028: }
2029:
2030: private final static Distance can_num = new Distance(0.0, 0);
2031:
2032: public final Measure getCanonicalNumerator() {
2033: return can_num;
2034: }
2035:
2036: private final static Duration can_den = new Duration(0.0, 0);
2037:
2038: public final Measure getCanonicalDenominator() {
2039: return can_den;
2040: }
2041:
2042: public final Measure computeNumerator(Measure den) {
2043: if (!(den instanceof Duration))
2044: throw new IllegalArgumentException();
2045: return new Distance(theValue * den.getValue(0), 0);
2046: }
2047:
2048: public final Measure computeDenominator(Measure num) {
2049: if (!(num instanceof Distance))
2050: throw new IllegalArgumentException();
2051: return new Duration(num.getValue(0) / theValue, 0);
2052: }
2053:
2054: // serialization
2055: public void writeExternal(ObjectOutput out) throws IOException {
2056: out.writeDouble(theValue);
2057: }
2058:
2059: public void readExternal(ObjectInput in) throws IOException {
2060: theValue = in.readDouble();
2061: }
2062: }
|