001/* 002 * Units of Measurement Systems for Java 003 * Copyright (c) 2005-2016, Jean-Marie Dautelle, Werner Keil, V2COM. 004 * 005 * All rights reserved. 006 * 007 * Redistribution and use in source and binary forms, with or without modification, 008 * are permitted provided that the following conditions are met: 009 * 010 * 1. Redistributions of source code must retain the above copyright notice, 011 * this list of conditions and the following disclaimer. 012 * 013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 014 * and the following disclaimer in the documentation and/or other materials provided with the distribution. 015 * 016 * 3. Neither the name of JSR-363 nor the names of its contributors may be used to endorse or promote products 017 * derived from this software without specific prior written permission. 018 * 019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030package systems.uom.common; 031 032import javax.measure.Quantity; 033import javax.measure.Unit; 034 035import tec.uom.se.function.RationalConverter; 036 037/** 038 * Utility class holding prefixes used today in India, Pakistan, Bangladesh, Nepal 039 * and Myanmar (Burma); based on grouping by two decimal places, rather than the 040 * three decimal places common in most parts of the world. [code] import static 041 * org.eclipse.uomo.units.IndianPrefix.*; // Static import. ... Unit<Pressure> 042 * LAKH_PASCAL = LAKH(PASCAL); 043 * Unit<Length>CRORE_METER = CRORE(METER); [/code] 044 * 045 * @author <a href="mailto:werner@uom.systems">Werner Keil</a> 046 * @version 1.7 $Date: 2016-10-18 $ 047 * @see <a 048 * href="http://en.wikipedia.org/wiki/Indian_numbering_system">Wikipedia: Indian numbering system</a> 049 */ 050public abstract class IndianPrefix { 051 052 /** 053 * <p> 054 * एक (Ek) 055 * </p> 056 * Returns the specified unit multiplied by the factor <code>1</code> 057 * 058 * @param unit 059 * any unit. 060 * @return <code>unit.times(1)</code>. 061 */ 062 public static final <Q extends Quantity<Q>> Unit<Q> EK(Unit<Q> unit) { 063 return unit; 064 } 065 066 /** 067 * <p> 068 * दस (Das) 069 * </p> 070 * Returns the specified unit multiplied by the factor 071 * <code>10<sup>1</sup></code> 072 * 073 * @param unit 074 * any unit. 075 * @return <code>unit.times(10)</code>. 076 */ 077 public static final <Q extends Quantity<Q>> Unit<Q> DAS(Unit<Q> unit) { 078 return unit.transform(E1); 079 } 080 081 /** 082 * <p> 083 * सौ (Sau) 084 * </p> 085 * Returns the specified unit multiplied by the factor 086 * <code>10<sup>2</sup></code> 087 * 088 * @param unit 089 * any unit. 090 * @return <code>unit.times(100)</code>. 091 */ 092 public static final <Q extends Quantity<Q>> Unit<Q> SAU(Unit<Q> unit) { 093 return unit.transform(E2); 094 } 095 096 /** 097 * <p> 098 * सहस्र (Sahasr) 099 * </p> 100 * Returns the specified unit multiplied by the factor 101 * <code>10<sup>3</sup></code> 102 * 103 * @param unit 104 * any unit. 105 * @return <code>unit.times(1e3)</code>. 106 */ 107 public static final <Q extends Quantity<Q>> Unit<Q> SAHASR(Unit<Q> unit) { 108 return unit.transform(E3); 109 } 110 111 /** 112 * <p> 113 * हजार (Hazaar) 114 * </p> 115 * Equivalent to {@link #SAHASR}. 116 */ 117 public static final <Q extends Quantity<Q>> Unit<Q> HAZAAR(Unit<Q> unit) { 118 return SAHASR(unit); 119 } 120 121 /** 122 * <p> 123 * लाख (Lakh) 124 * </p> 125 * Returns the specified unit multiplied by the factor 126 * <code>10<sup>5</sup></code> 127 * 128 * @param unit 129 * any unit. 130 * @return <code>unit.times(1e5)</code>. 131 */ 132 public static final <Q extends Quantity<Q>> Unit<Q> LAKH(Unit<Q> unit) { 133 return unit.transform(E5); 134 } 135 136 /** 137 * <p> 138 * करोड़ (Crore) 139 * </p> 140 * Returns the specified unit multiplied by the factor 141 * <code>10<sup>7</sup></code> 142 * 143 * @param unit 144 * any unit. 145 * @return <code>unit.times(1e7)</code>. 146 */ 147 public static final <Q extends Quantity<Q>> Unit<Q> CRORE(Unit<Q> unit) { 148 return unit.transform(E7); 149 } 150 151 /** 152 * <p> 153 * अरब (Arawb) 154 * </p> 155 * Returns the specified unit multiplied by the factor 156 * <code>10<sup>9</sup></code> 157 * 158 * @param unit 159 * any unit. 160 * @return <code>unit.times(1e9)</code>. 161 */ 162 public static final <Q extends Quantity<Q>> Unit<Q> ARAWB(Unit<Q> unit) { 163 return unit.transform(E9); 164 } 165 166 /** 167 * <p> 168 * खरब (Kharawb) 169 * </p> 170 * Returns the specified unit multiplied by the factor 171 * <code>10<sup>11</sup></code> 172 * 173 * @param unit 174 * any unit. 175 * @return <code>unit.times(1e11)</code>. 176 */ 177 public static final <Q extends Quantity<Q>> Unit<Q> KHARAWB(Unit<Q> unit) { 178 return unit.transform(E11); 179 } 180 181 /** 182 * <p> 183 * नील (Neel) 184 * </p> 185 * Returns the specified unit multiplied by the factor 186 * <code>10<sup>13</sup></code> 187 * 188 * @param unit 189 * any unit. 190 * @return <code>unit.times(1e13)</code>. 191 */ 192 public static final <Q extends Quantity<Q>> Unit<Q> NEEL(Unit<Q> unit) { 193 return unit.transform(E13); 194 } 195 196 /** 197 * <p> 198 * पद्म (Padma) 199 * </p> 200 * Returns the specified unit multiplied by the factor 201 * <code>10<sup>15</sup></code> 202 * 203 * @param unit 204 * any unit. 205 * @return <code>unit.times(1e15)</code>. 206 */ 207 public static final <Q extends Quantity<Q>> Unit<Q> PADMA(Unit<Q> unit) { 208 return unit.transform(E15); 209 } 210 211 /** 212 * <p> 213 * शंख (Shankh) 214 * </p> 215 * Returns the specified unit multiplied by the factor 216 * <code>10<sup>17</sup></code> 217 * 218 * @param unit 219 * any unit. 220 * @return <code>unit.times(1e17)</code>. 221 */ 222 public static final <Q extends Quantity<Q>> Unit<Q> SHANKH(Unit<Q> unit) { 223 return unit.transform(E17); 224 } 225 226 /** 227 * <p> 228 * महाशंख (Mahashankh) 229 * </p> 230 * Returns the specified unit multiplied by the factor 231 * <code>10<sup>19</sup></code> 232 * 233 * @param unit 234 * any unit. 235 * @return <code>unit.times(1e19)</code>. 236 */ 237 public static final <Q extends Quantity<Q>> Unit<Q> MAHASHANKH(Unit<Q> unit) { 238 return unit.transform(E19); 239 } 240 241 private static final RationalConverter E19 = RationalConverter.of(1e19d, 1d); 242 private static final RationalConverter E17 = RationalConverter.of(1e17d, 1d); 243 private static final RationalConverter E15 = RationalConverter.of(1e15d, 1d); 244 private static final RationalConverter E13 = RationalConverter.of(1e13d, 1d); 245 private static final RationalConverter E11 = RationalConverter.of(1e11d, 1d); 246 private static final RationalConverter E9 = RationalConverter.of(1e9d, 1d); 247 private static final RationalConverter E7 = RationalConverter.of(1e7d, 1d); 248 private static final RationalConverter E5 = RationalConverter.of(1e5d, 1d); 249 private static final RationalConverter E3 = RationalConverter.of(1e3d, 1d); 250 private static final RationalConverter E2 = RationalConverter.of(1e2d, 1d); 251 private static final RationalConverter E1 = RationalConverter.of(1e1d, 1d); 252 253 // Holds prefix converters (optimization). 254 /* 255 * static final RationalConverter E7 = new RationalConverter( 256 BigInteger.TEN.pow(7), BigInteger.ONE); 257 * static final RationalConverter E5 = new RationalConverter( 258 BigInteger.TEN.pow(5), BigInteger.ONE); 259 260 private static final RationalConverter E19 = new RationalConverter( 261 BigInteger.TEN.pow(19), BigInteger.ONE); 262 private static final RationalConverter E17 = new RationalConverter( 263 BigInteger.TEN.pow(17), BigInteger.ONE); 264 private static final RationalConverter E15 = new RationalConverter( 265 BigInteger.TEN.pow(15), BigInteger.ONE); 266 private static final RationalConverter E13 = new RationalConverter( 267 BigInteger.TEN.pow(13), BigInteger.ONE); 268 private static final RationalConverter E11 = new RationalConverter( 269 BigInteger.TEN.pow(11), BigInteger.ONE); 270 private static final RationalConverter E9 = new RationalConverter( 271 BigInteger.TEN.pow(9), BigInteger.ONE); 272 private static final RationalConverter E3 = new RationalConverter( 273 BigInteger.TEN.pow(3), BigInteger.ONE); 274 private static final RationalConverter E2 = new RationalConverter( 275 BigInteger.TEN.pow(2), BigInteger.ONE); 276 private static final RationalConverter E1 = new RationalConverter( 277 BigInteger.TEN.pow(1), BigInteger.ONE); 278 */ 279}