@Test public void testUdunitsToUcum() throws Exception { testUdunitsToUcum("seconds since 1970-01-01T00:00:00Z", "s{since 1970-01-01T00:00:00Z}"); testUdunitsToUcum("millisec since 1971-02-03T01", "ms{since 1971-02-03T01}"); testUdunitsToUcum("sec since 1971-02-03T00:00:00-4:00", "s{since 1971-02-03T00:00:00-4:00}"); testUdunitsToUcum("min since 1971-02-03", "min{since 1971-02-03}"); testUdunitsToUcum("hr since 1971-02-03", "h{since 1971-02-03}"); testUdunitsToUcum("days since 1971-02-03", "d{since 1971-02-03}"); testUdunitsToUcum("months since 1971-02-03", "mo{since 1971-02-03}"); testUdunitsToUcum("yrs since 1971-02-03", "a{since 1971-02-03}"); testUdunitsToUcum("zztops since 1971-02-03", "zztops.since.1971-02-03"); testUdunitsToUcum("abampere", "(10.A)"); testUdunitsToUcum("abfarad", "GF"); testUdunitsToUcum("abhenry", "nH"); testUdunitsToUcum("abmho", "GS"); testUdunitsToUcum("abohm", "nO"); testUdunitsToUcum("abvolt", "(V/10^8)"); testUdunitsToUcum("acre_feet", "([acr_us].ft)"); testUdunitsToUcum("acre_foot", "([acr_us].ft)"); testUdunitsToUcum("acre", "[acr_us]"); testUdunitsToUcum("ampere", "A"); testUdunitsToUcum("amp", "A"); testUdunitsToUcum("amu", "u"); testUdunitsToUcum("Å", "Ao"); testUdunitsToUcum("Ångström", "Ao"); testUdunitsToUcum("angstrom", "Ao"); testUdunitsToUcum("angular_degree", "deg"); testUdunitsToUcum("angular_minute", "'"); testUdunitsToUcum("angular_second", "''"); testUdunitsToUcum("apostilb", "(cd/[pi]/m2)"); testUdunitsToUcum("apdram", "[dr_ap]"); testUdunitsToUcum("apothecary_dram", "[dr_ap]"); testUdunitsToUcum("apothecary_ounce", "[oz_ap]"); testUdunitsToUcum("apothecary_pound", "[lb_ap]"); testUdunitsToUcum("apounce", "[oz_ap]"); testUdunitsToUcum("appound", "[lb_ap]"); testUdunitsToUcum("arcdeg", "deg"); testUdunitsToUcum("arcminute", "'"); testUdunitsToUcum("arcsecond", "''"); testUdunitsToUcum("are", "ar"); testUdunitsToUcum("arpentlin", "(191835/1000.[ft_i])"); testUdunitsToUcum("assay_ton", "(2916667/10^8.kg)"); testUdunitsToUcum("astronomical_unit", "AU"); testUdunitsToUcum("at", "att"); testUdunitsToUcum("atmosphere", "atm"); testUdunitsToUcum("atomic_mass_unit", "u"); testUdunitsToUcum("atomicmassunit", "u"); testUdunitsToUcum("avogadro_constant", "mol"); testUdunitsToUcum("avoirdupois_ounce", "[oz_av]"); testUdunitsToUcum("avoirdupois_pound", "[lb_av]"); testUdunitsToUcum("bag", "(94.[lb_av])"); testUdunitsToUcum("bakersdozen", "13"); testUdunitsToUcum("barie", "(dN/m2)"); testUdunitsToUcum("barleycorn", "([in_i]/3)"); testUdunitsToUcum("barn", "b"); testUdunitsToUcum("barrel", "[bbl_us]"); testUdunitsToUcum("bars", "bar"); testUdunitsToUcum("baud", "Bd"); testUdunitsToUcum("barye", "(dN/m2)"); testUdunitsToUcum("bbl", "[bbl_us]"); testUdunitsToUcum("becquerel", "Bq"); testUdunitsToUcum("bel", "B"); testUdunitsToUcum("bev", "GeV"); testUdunitsToUcum("big_point", "([in_i]/72)"); testUdunitsToUcum("biot", "Bi"); testUdunitsToUcum("bit", "bit"); testUdunitsToUcum("blondel", "(cd/[pi]/m2)"); testUdunitsToUcum("board_feet", "[bf_i]"); testUdunitsToUcum("board_foot", "[bf_i]"); testUdunitsToUcum("boiler_horsepower", "(98095/10.W)"); testUdunitsToUcum("bps", "(bit/s)"); testUdunitsToUcum("Btu", "[Btu_IT]"); testUdunitsToUcum("bushel", "[bu_us]"); testUdunitsToUcum("bu", "[bu_us]"); testUdunitsToUcum("byte", "By"); testUdunitsToUcum("C", "C"); testUdunitsToUcum("c", "[c]"); testUdunitsToUcum("C12_faraday", "(9648531/100.C)"); testUdunitsToUcum("cal", "cal_IT"); testUdunitsToUcum("calorie", "cal_IT"); testUdunitsToUcum("Canadian_liquid_gallon", "(454609/10^8.m3)"); testUdunitsToUcum("candela", "cd"); testUdunitsToUcum("candle", "cd"); testUdunitsToUcum("carat", "[car_m]"); testUdunitsToUcum("cc", "cm3"); testUdunitsToUcum("celsius", "Cel"); testUdunitsToUcum("Celsius", "Cel"); testUdunitsToUcum("chemical_faraday", "(964957/10.C)"); testUdunitsToUcum("circle", "circ"); testUdunitsToUcum("circular_mil", "[cml_i]"); testUdunitsToUcum("clo", "(155/1000.K.m2/W)"); testUdunitsToUcum("cmH2O", "cm[H2O]"); testUdunitsToUcum("cmHg", "cm[Hg]"); testUdunitsToUcum("common_year", "(365.d)"); testUdunitsToUcum("conventional_mercury", "[Hg]"); testUdunitsToUcum("conventional_water", "[H2O]"); testUdunitsToUcum("coulomb", "C"); testUdunitsToUcum("count", "{count}"); testUdunitsToUcum("cps", "Hz"); testUdunitsToUcum("cup", "[cup_us]"); testUdunitsToUcum("curie", "Ci"); testUdunitsToUcum("darcy", "(9869233/10^19.m2)"); testUdunitsToUcum("day", "d"); testUdunitsToUcum("degree", "deg"); testUdunitsToUcum("degree_east", "deg{east}"); testUdunitsToUcum("degree_E", "deg{east}"); testUdunitsToUcum("degreeE", "deg{east}"); testUdunitsToUcum("degrees_east", "deg{east}"); testUdunitsToUcum("degrees_E", "deg{east}"); testUdunitsToUcum("degreesE", "deg{east}"); testUdunitsToUcum("degree_north", "deg{north}"); testUdunitsToUcum("degree_N", "deg{north}"); testUdunitsToUcum("degreeN", "deg{north}"); testUdunitsToUcum("degrees_north", "deg{north}"); testUdunitsToUcum("degrees_N", "deg{north}"); testUdunitsToUcum("degreesN", "deg{north}"); testUdunitsToUcum("degree_true", "deg{true}"); testUdunitsToUcum("degree_T", "deg{true}"); testUdunitsToUcum("degreeT", "deg{true}"); testUdunitsToUcum("degrees_true", "deg{true}"); testUdunitsToUcum("degrees_T", "deg{true}"); testUdunitsToUcum("degreesT", "deg{true}"); testUdunitsToUcum("degree_west", "deg{west}"); testUdunitsToUcum("degree_W", "deg{west}"); testUdunitsToUcum("degreeW", "deg{west}"); testUdunitsToUcum("degrees_west", "deg{west}"); testUdunitsToUcum("degrees_W", "deg{west}"); testUdunitsToUcum("degreesW", "deg{west}"); testUdunitsToUcum("°C", "Cel"); testUdunitsToUcum("degree_centigrade", "Cel"); testUdunitsToUcum("degree_Celsius", "Cel"); testUdunitsToUcum("degrees_Celsius", "Cel"); testUdunitsToUcum("degC", "Cel"); testUdunitsToUcum("degreeC", "Cel"); testUdunitsToUcum("degreesC", "Cel"); testUdunitsToUcum("degree_C", "Cel"); testUdunitsToUcum("degrees_C", "Cel"); testUdunitsToUcum("degree_c", "Cel"); testUdunitsToUcum("degrees_c", "Cel"); testUdunitsToUcum("deg_C", "Cel"); testUdunitsToUcum("degs_C", "Cel"); testUdunitsToUcum("deg_c", "Cel"); testUdunitsToUcum("degs_c", "Cel"); testUdunitsToUcum("°F", "[degF]"); testUdunitsToUcum("degree_Fahrenheit", "[degF]"); testUdunitsToUcum("degrees_Fahrenheit", "[degF]"); testUdunitsToUcum("degF", "[degF]"); testUdunitsToUcum("degreeF", "[degF]"); testUdunitsToUcum("degreesF", "[degF]"); testUdunitsToUcum("degree_F", "[degF]"); testUdunitsToUcum("degrees_F", "[degF]"); testUdunitsToUcum("degree_f", "[degF]"); testUdunitsToUcum("degrees_f", "[degF]"); testUdunitsToUcum("deg_F", "[degF]"); testUdunitsToUcum("degs_F", "[degF]"); testUdunitsToUcum("deg_f", "[degF]"); testUdunitsToUcum("degs_f", "[degF]"); testUdunitsToUcum("°K", "K"); testUdunitsToUcum("degree_Kelvin", "K"); testUdunitsToUcum("degrees_Kelvin", "K"); testUdunitsToUcum("degK", "K"); testUdunitsToUcum("degreeK", "K"); testUdunitsToUcum("degreesK", "K"); testUdunitsToUcum("degree_K", "K"); testUdunitsToUcum("degrees_K", "K"); testUdunitsToUcum("degree_k", "K"); testUdunitsToUcum("degrees_k", "K"); testUdunitsToUcum("deg_K", "K"); testUdunitsToUcum("degs_K", "K"); testUdunitsToUcum("deg_k", "K"); testUdunitsToUcum("degs_k", "K"); testUdunitsToUcum("°R", "(5/9.K)"); testUdunitsToUcum("degree_Rankine", "(5/9.K)"); testUdunitsToUcum("degrees_Rankine", "(5/9.K)"); testUdunitsToUcum("degR", "(5/9.K)"); testUdunitsToUcum("degreeR", "(5/9.K)"); testUdunitsToUcum("degreesR", "(5/9.K)"); testUdunitsToUcum("degree_R", "(5/9.K)"); testUdunitsToUcum("degrees_R", "(5/9.K)"); testUdunitsToUcum("degree_r", "(5/9.K)"); testUdunitsToUcum("degrees_r", "(5/9.K)"); testUdunitsToUcum("deg_R", "(5/9.K)"); testUdunitsToUcum("degs_R", "(5/9.K)"); testUdunitsToUcum("deg_r", "(5/9.K)"); testUdunitsToUcum("degs_r", "(5/9.K)"); testUdunitsToUcum("denier", "(1111111/10^13.kg/m)"); testUdunitsToUcum("diopter", "[diop]"); testUdunitsToUcum("dozen", "12{count}"); testUdunitsToUcum("dram", "[fdr_us]"); testUdunitsToUcum("dr", "[fdr_uk]"); testUdunitsToUcum("drop", "[drp]"); testUdunitsToUcum("dry_pint", "[dpt_us]"); testUdunitsToUcum("dry_quart", "[dqt_us]"); testUdunitsToUcum("dynamic", "[g]"); testUdunitsToUcum("dyne", "dyn"); testUdunitsToUcum("EC_therm", "(105506/10^13.J)"); testUdunitsToUcum("electric_horsepower", "(746.W)"); testUdunitsToUcum("electronvolt", "eV"); testUdunitsToUcum("eon", "Ga"); testUdunitsToUcum("ergs", "erg"); testUdunitsToUcum("F", "[degF]"); testUdunitsToUcum("Fahrenheit", "[degF]"); testUdunitsToUcum("fahrenheit", "[degF]"); testUdunitsToUcum("faraday", "(9648531/100.C)"); testUdunitsToUcum("farad", "F"); testUdunitsToUcum("fathom", "[fth_us]"); testUdunitsToUcum("feet", "[ft_i]"); testUdunitsToUcum("fermi", "fm"); testUdunitsToUcum("firkin", "([bbl_us]/4)"); testUdunitsToUcum("fldr", "[dr_av]"); testUdunitsToUcum("floz", "[foz_us]"); testUdunitsToUcum("fluid_ounce", "[foz_us]"); testUdunitsToUcum("fluid_dram", "[fdr_us]"); testUdunitsToUcum("footcandle", "(1076391/10^7.lx)"); testUdunitsToUcum("footlambert", "(3426259/10^6.cd/m2)"); testUdunitsToUcum("foot_H2O", "[ft_i'H2O]"); testUdunitsToUcum("footH2O", "[ft_i'H2O]"); testUdunitsToUcum("foot", "[ft_i]"); testUdunitsToUcum("force_gram", "gf"); testUdunitsToUcum("force_ounce", "([lbf_av]/16)"); testUdunitsToUcum("force_pound", "[lbf_av]"); testUdunitsToUcum("force_kilogram", "kgf"); testUdunitsToUcum("force_ton", "(2000.[lbf_av])"); testUdunitsToUcum("force", "[g]"); testUdunitsToUcum("fortnight", "(14.d)"); testUdunitsToUcum("free_fall", "[g]"); testUdunitsToUcum("ftH2O", "[ft_i'H2O]"); testUdunitsToUcum("ft", "[ft_i]"); testUdunitsToUcum("furlong", "[fur_us]"); testUdunitsToUcum("gallon", "[gal_us]"); testUdunitsToUcum("gal", "Gal"); testUdunitsToUcum("gamma", "nT"); testUdunitsToUcum("gauss", "G"); testUdunitsToUcum("geopotential", "[g]"); testUdunitsToUcum("gilbert", "Gb"); testUdunitsToUcum("gill", "[gil_us]"); testUdunitsToUcum("gp", "[g]"); testUdunitsToUcum("gr", "[gr]"); testUdunitsToUcum("grade", "gon"); testUdunitsToUcum("grain", "[gr]"); testUdunitsToUcum("gram_force", "gf"); testUdunitsToUcum("gram", "g"); testUdunitsToUcum("gravity", "[g]"); testUdunitsToUcum("gray", "Gy"); testUdunitsToUcum("Gregorian_year", "a_g"); testUdunitsToUcum("h2o", "[H2O]"); testUdunitsToUcum("H2O", "[H2O]"); testUdunitsToUcum("hectare", "Har"); testUdunitsToUcum("henry", "H"); testUdunitsToUcum("hertz", "Hz"); testUdunitsToUcum("hg", "[Hg]"); testUdunitsToUcum("Hg", "[Hg]"); testUdunitsToUcum("horsepower", "[HP]"); testUdunitsToUcum("hour", "h"); testUdunitsToUcum("hr", "h"); testUdunitsToUcum("hundred", "100"); testUdunitsToUcum("inch_H2O_39F", "[in_i'H2O]{39F}"); testUdunitsToUcum("inch_H2O_60F", "[in_i'H2O]{60F}"); testUdunitsToUcum("inch_Hg_32F", "[in_i'Hg]{32F}"); testUdunitsToUcum("inch_Hg_60F", "[in_i'Hg]{60F}"); testUdunitsToUcum("inch_Hg", "[in_i'Hg]"); testUdunitsToUcum("inches", "[in_i]"); testUdunitsToUcum("inch", "[in_i]"); testUdunitsToUcum("inhg", "[in_i'Hg]"); testUdunitsToUcum("in", "[in_i]"); testUdunitsToUcum("international_feet", "[ft_i]"); testUdunitsToUcum("international_foot", "[ft_i]"); testUdunitsToUcum("international_inches", "[in_i]"); testUdunitsToUcum("international_inch", "[in_i]"); testUdunitsToUcum("international_knot", "[kn_i]"); testUdunitsToUcum("international_mile", "[mi_i]"); testUdunitsToUcum("international_yard", "[yd_i]"); testUdunitsToUcum("IT_Btu", "[Btu_IT]"); testUdunitsToUcum("IT_calorie", "cal_IT"); testUdunitsToUcum("jiffies", "cs"); testUdunitsToUcum("jiffy", "cs"); testUdunitsToUcum("joule", "J"); testUdunitsToUcum("Julian_year", "a_j"); testUdunitsToUcum("K", "K"); testUdunitsToUcum("kat", "kat"); testUdunitsToUcum("katal", "kat"); testUdunitsToUcum("kayser", "Ky"); testUdunitsToUcum("kelvin", "K"); testUdunitsToUcum("Kelvin", "K"); testUdunitsToUcum("kip", "(1000.[lbf_av])"); testUdunitsToUcum("knot_international", "[kn_i]"); testUdunitsToUcum("knot", "[kn_i]"); testUdunitsToUcum("ksi", "(1000.[lbf_av]/[in_i]2)"); testUdunitsToUcum("kt", "[kn_i]"); testUdunitsToUcum("L", "L"); testUdunitsToUcum("l", "l"); testUdunitsToUcum("lambert", "Lmb"); testUdunitsToUcum("lbf", "[lbf_av]"); testUdunitsToUcum("lb", "[lb_av]"); testUdunitsToUcum("leap_year", "(366.d)"); testUdunitsToUcum("light_year", "[ly]"); testUdunitsToUcum("liquid_gallon", "[gal_us]"); testUdunitsToUcum("liquid_pint", "[pt_us]"); testUdunitsToUcum("liquid_quart", "[qt_us]"); testUdunitsToUcum("liter", "l"); testUdunitsToUcum("litre", "l"); testUdunitsToUcum("long_hundredweight", "[lcwt_av]"); testUdunitsToUcum("long_ton", "t"); testUdunitsToUcum("longton", "t"); testUdunitsToUcum("lumen", "lm"); testUdunitsToUcum("lunar_month", "mo_s"); testUdunitsToUcum("luxes", "lx"); testUdunitsToUcum("lux", "lx"); testUdunitsToUcum("m", "m"); testUdunitsToUcum("maxwell", "Mx"); testUdunitsToUcum("mercury_0C", "[Hg]"); testUdunitsToUcum("mercury_32F", "[Hg]"); testUdunitsToUcum("mercury_60F", "[Hg]{60F}"); testUdunitsToUcum("mercury", "[Hg]"); testUdunitsToUcum("meter", "m"); testUdunitsToUcum("metric_horsepower", "(735499/10^5.W)"); testUdunitsToUcum("metric_ton", "t"); testUdunitsToUcum("metricton", "t"); testUdunitsToUcum("mhos", "mho"); testUdunitsToUcum("micron", "um"); testUdunitsToUcum("mile", "[mi_i]"); testUdunitsToUcum("millimeter_Hg", "mm[Hg]"); testUdunitsToUcum("million", "10^6"); testUdunitsToUcum("mil", "[mil_i]"); testUdunitsToUcum("mins", "min"); testUdunitsToUcum("minute", "min"); testUdunitsToUcum("mi", "[mi_i]"); testUdunitsToUcum("mm_Hg", "mm[Hg]"); testUdunitsToUcum("mm_hg", "mm[Hg]"); testUdunitsToUcum("mm_Hg_0C", "mm[Hg]{0C}"); testUdunitsToUcum("mmHg", "mm[Hg]"); testUdunitsToUcum("mole", "mol"); testUdunitsToUcum("month", "mo"); testUdunitsToUcum("N", "N"); testUdunitsToUcum("neper", "Np"); testUdunitsToUcum("nautical_mile", "[nmi_i]"); testUdunitsToUcum("nmile", "[nmi_i]"); testUdunitsToUcum("nmi", "[nmi_i]"); testUdunitsToUcum("newton", "N"); testUdunitsToUcum("nit", "(cd/m2)"); testUdunitsToUcum("NTU", "{ntu}"); testUdunitsToUcum("nt", "(cd/m2)"); testUdunitsToUcum("O", "O"); testUdunitsToUcum("oersted", "Oe"); testUdunitsToUcum("ohm", "O"); testUdunitsToUcum("osmole", "osm"); testUdunitsToUcum("ounce_force", "([lbf_av]/16)"); testUdunitsToUcum("ozf", "([lbf_av]/16)"); testUdunitsToUcum("oz", "[foz_us]"); testUdunitsToUcum("pair", "2"); testUdunitsToUcum("parsec", "pc"); testUdunitsToUcum("pascal", "Pa"); testUdunitsToUcum("peck", "[pk_us]"); testUdunitsToUcum("pennyweight", "[pwt_tr]"); testUdunitsToUcum("percent", "%"); testUdunitsToUcum("perches", "[rd_us]"); testUdunitsToUcum("perch", "[rd_us]"); testUdunitsToUcum("perm_0C", "(S.572135.10^-16.kg/(Pa.s.m2))"); testUdunitsToUcum("perm_23C", "(S.574525.10^-16.kg/(Pa.s.m2))"); testUdunitsToUcum("phot", "ph"); testUdunitsToUcum("pH", "[pH]"); testUdunitsToUcum("physical_faraday", "(965219/10.C)"); testUdunitsToUcum("pica", "[pca_pr]"); testUdunitsToUcum("pint", "[pt_us]"); testUdunitsToUcum("pi", "[pi]"); testUdunitsToUcum("PI", "[pi]"); testUdunitsToUcum("pk", "[pk_us]"); testUdunitsToUcum("poise", "P"); testUdunitsToUcum("pole", "[rd_us]"); testUdunitsToUcum("pond", "(980665/10^5.N)"); testUdunitsToUcum("poundal", "(138255/10^6.N)"); testUdunitsToUcum("pound_force", "[lbf_av]"); testUdunitsToUcum("pound", "[lb_av]"); testUdunitsToUcum("ppth", "[ppth]"); testUdunitsToUcum("ppm", "[ppm]"); testUdunitsToUcum("ppb", "[ppb]"); testUdunitsToUcum("pptr", "[pptr]"); testUdunitsToUcum("printers_pica", "[pca_pr]"); testUdunitsToUcum("printers_point", "[pnt_pr]"); testUdunitsToUcum("psi", "[psi]"); testUdunitsToUcum("PSU", "{psu}"); testUdunitsToUcum("psu", "{psu}"); testUdunitsToUcum("pt", "[pt_us]"); testUdunitsToUcum("quart", "[qt_us]"); testUdunitsToUcum("R", "R"); testUdunitsToUcum("radian", "rad"); testUdunitsToUcum("rad", "RAD"); testUdunitsToUcum("Rankine", "(5/9.K)"); testUdunitsToUcum("Rankines", "(5/9.K)"); testUdunitsToUcum("rankine", "(5/9.K)"); testUdunitsToUcum("rankines", "(5/9.K)"); testUdunitsToUcum("rd", "RAD"); testUdunitsToUcum("refrigeration_ton", "(12000.[Btu_IT]/hr)"); testUdunitsToUcum("register_ton", "(2831685/10^6.m3)"); testUdunitsToUcum("rem", "REM"); testUdunitsToUcum("rhe", "(10.Pa-1.s-1)"); testUdunitsToUcum("rod", "[rd_us]"); testUdunitsToUcum("roentgen", "R"); testUdunitsToUcum("rps", "Hz"); testUdunitsToUcum("S", "S"); testUdunitsToUcum("score", "20"); testUdunitsToUcum("scruple", "[sc_ap]"); testUdunitsToUcum("second", "s"); testUdunitsToUcum("sec", "s"); testUdunitsToUcum("shaft_horsepower", "[HP]"); testUdunitsToUcum("shake", "(10^-8.s)"); testUdunitsToUcum("short_hundredweight", "[scwt_av]"); testUdunitsToUcum("short_ton", "[ston_av]"); testUdunitsToUcum("shortton", "[ston_av]"); testUdunitsToUcum("sidereal_day", "(8616409/10^2.s)"); testUdunitsToUcum("sidereal_hour", "(359017/10^2.s)"); testUdunitsToUcum("sidereal_minute", "(5983617/10^5.s)"); testUdunitsToUcum("sidereal_month", "(27321661/10^6.d)"); testUdunitsToUcum("sidereal_second", "(9972696/10^7.s)"); testUdunitsToUcum("sidereal_year", "(31558150.s)"); testUdunitsToUcum("siemens", "S"); testUdunitsToUcum("sievert", "Sv"); testUdunitsToUcum("slug", "(145939/10^4.kg)"); testUdunitsToUcum("sphere", "(4.[pi].sr)"); testUdunitsToUcum("standard_atmosphere", "atm"); testUdunitsToUcum("standard_free_fall", "[g]"); testUdunitsToUcum("statampere", "(333564/10^15.A)"); testUdunitsToUcum("statcoulomb", "(333564/10^15.C)"); testUdunitsToUcum("statfarad", "(111265/10^17.F)"); testUdunitsToUcum("stathenry", "(8987554.10^5.H)"); testUdunitsToUcum("statmho", "(111265/10^17.S)"); testUdunitsToUcum("statohm", "(8987554.10^5.O)"); testUdunitsToUcum("statvolt", "(2997925/10^4.V)"); testUdunitsToUcum("steradian", "sr"); testUdunitsToUcum("stere", "st"); testUdunitsToUcum("stilb", "sb"); testUdunitsToUcum("stokes", "St"); testUdunitsToUcum("stone", "[stone_av]"); testUdunitsToUcum("svedberg", "[S]"); testUdunitsToUcum("T", "T"); testUdunitsToUcum("t", "t"); testUdunitsToUcum("tablespoon", "[tbs_us]"); testUdunitsToUcum("Tblsp", "[tbs_us]"); testUdunitsToUcum("tblsp", "[tbs_us]"); testUdunitsToUcum("Tbl", "[tbs_us]"); testUdunitsToUcum("Tbsp", "[tbs_us]"); testUdunitsToUcum("tbsp", "[tbs_us]"); testUdunitsToUcum("tbs", "[tbs_us]"); testUdunitsToUcum("teaspoon", "[tsp_us]"); testUdunitsToUcum("tsp", "[tsp_us]"); testUdunitsToUcum("technical_atmosphere", "att"); testUdunitsToUcum("ten", "10"); testUdunitsToUcum("tesla", "T"); testUdunitsToUcum("tex", "(mg/m)"); testUdunitsToUcum("thermochemical_calorie", "cal_th"); testUdunitsToUcum("therm", "(105480400.J)"); testUdunitsToUcum("thm", "(105480400.J)"); testUdunitsToUcum("thousand", "1000"); testUdunitsToUcum("ton_force", "(2000.[lbf_av])"); testUdunitsToUcum("ton_of_refrigeration", "(12000.[Btu_IT]/hr)"); testUdunitsToUcum("ton_TNT", "(4184.10^6.J)"); testUdunitsToUcum("tonne", "t"); testUdunitsToUcum("ton", "[ston_av]"); testUdunitsToUcum("torr", "mm[Hg]"); testUdunitsToUcum("tropical_month", "(27321582/10^6.d)"); testUdunitsToUcum("tropical_year", "a_t"); testUdunitsToUcum("troy_ounce", "[oz_tr]"); testUdunitsToUcum("troy_pound", "[lb_tr]"); testUdunitsToUcum("turn", "circ"); testUdunitsToUcum("u", "u"); testUdunitsToUcum("ua", "AU"); testUdunitsToUcum("UK_fluid_ounce", "[foz_br]"); testUdunitsToUcum("UK_horsepower", "(7457/10.W)"); testUdunitsToUcum("UK_liquid_cup", "([pt_br]/2)"); testUdunitsToUcum("UK_liquid_gallon", "[gal_br]"); testUdunitsToUcum("UK_liquid_gill", "[gil_br]"); testUdunitsToUcum("UK_liquid_ounce", "[foz_br]"); testUdunitsToUcum("UK_liquid_pint", "[pt_br]"); testUdunitsToUcum("UK_liquid_quart", "[qt_br]"); testUdunitsToUcum("unified_atomic_mass_unit", "u"); testUdunitsToUcum("unit_pole", "(1256637/10^13.Wb)"); testUdunitsToUcum("US_dry_gallon", "[gal_wi]"); testUdunitsToUcum("US_dry_pint", "[dpt_us]"); testUdunitsToUcum("US_dry_quart", "[dqt_us]"); testUdunitsToUcum("US_fluid_ounce", "[foz_us]"); testUdunitsToUcum("US_liquid_cup", "[cup_us]"); testUdunitsToUcum("US_liquid_gallon", "[gal_us]"); testUdunitsToUcum("US_liquid_gill", "[gil_us]"); testUdunitsToUcum("US_liquid_ounce", "[foz_us]"); testUdunitsToUcum("US_liquid_pint", "[pt_us]"); testUdunitsToUcum("US_liquid_quart", "[qt_us]"); testUdunitsToUcum("US_statute_mile", "[mi_us]"); testUdunitsToUcum("US_survey_feet", "[ft_us]"); testUdunitsToUcum("US_survey_foot", "[ft_us]"); testUdunitsToUcum("US_survey_mile", "[mi_us]"); testUdunitsToUcum("US_survey_yard", "[yd_us]"); testUdunitsToUcum("US_therm", "(105480400.J)"); testUdunitsToUcum("V", "V"); testUdunitsToUcum("volt", "V"); testUdunitsToUcum("W", "W"); testUdunitsToUcum("water_32F", "[H2O]"); testUdunitsToUcum("water_39F", "[H2O]{39F}"); testUdunitsToUcum("water_4C", "[H2O]{4Cel}"); testUdunitsToUcum("water_60F", "[H2O]{60F}"); testUdunitsToUcum("water", "[H2O]"); testUdunitsToUcum("watt", "W"); testUdunitsToUcum("weber", "Wb"); testUdunitsToUcum("week", "wk"); testUdunitsToUcum("work_month", "(2056.hr/12)"); testUdunitsToUcum("work_year", "(2056.hr)"); testUdunitsToUcum("yard", "[yd_i]"); testUdunitsToUcum("yd", "[yd_i]"); testUdunitsToUcum("year", "a"); testUdunitsToUcum("yr", "a"); testUdunitsToUcum("atto", "a{count}"); testUdunitsToUcum("centi", "c{count}"); testUdunitsToUcum("deci", "d{count}"); testUdunitsToUcum("deka", "da{count}"); testUdunitsToUcum("exa", "E{count}"); testUdunitsToUcum("femto", "f{count}"); testUdunitsToUcum("giga", "G{count}"); testUdunitsToUcum("hecto", "h{count}"); testUdunitsToUcum("kilo", "k{count}"); testUdunitsToUcum("mega", "M{count}"); testUdunitsToUcum("micro", "u{count}"); testUdunitsToUcum("µ", "u{count}"); testUdunitsToUcum("milli", "m{count}"); testUdunitsToUcum("nano", "n{count}"); testUdunitsToUcum("peta", "P{count}"); testUdunitsToUcum("pico", "p{count}"); testUdunitsToUcum("tera", "T{count}"); testUdunitsToUcum("yocto", "y{count}"); testUdunitsToUcum("yotta", "Y{count}"); testUdunitsToUcum("zepto", "z{count}"); testUdunitsToUcum("zetta", "Z{count}"); testUdunitsToUcum("decikilocentinpgrams", "dkcnpg"); testUdunitsToUcum("kilograms / second2", "kg/s2"); testUdunitsToUcum("kilograms PER second**2", "kg/s^2"); testUdunitsToUcum("kilograms per second^2", "kg/s^2"); testUdunitsToUcum("-12 kg", "-12.kg"); testUdunitsToUcum("-0.0e14 kg", "0.kg"); testUdunitsToUcum("-20.0e14 kg", "-2.10^15.kg"); testUdunitsToUcum("-1.2e1 kg", "-12.kg"); testUdunitsToUcum("-12340e-1 kg", "-1234.kg"); testUdunitsToUcum("-12340e2 kg", "-1234000.kg"); testUdunitsToUcum("-12.345e2 kg", "-12345.10^-1.kg"); testUdunitsToUcum("-12.345e400 kg", "-12.345e400.kg"); testUdunitsToUcum("dkilo", "dk{count}"); testUdunitsToUcum("kiloBobs", "kiloBobs"); testUdunitsToUcum("per", "/"); testUdunitsToUcum("PER", "/"); testUdunitsToUcum("**", "^"); testUdunitsToUcum("*", "."); testUdunitsToUcum("·", "."); testUdunitsToUcum(" ", "."); testUdunitsToUcum("\"", "''"); testUdunitsToUcum("'", "'"); testUdunitsToUcum("°", "deg"); testUdunitsToUcum("°F", "[degF]"); testUdunitsToUcum("°R", "(5/9.K)"); testUdunitsToUcum("°C", "Cel"); testUdunitsToUcum("°K", "K"); testUdunitsToUcum("°north", "°north"); }
public static String udunitsToUcum(String udunits) { if (udunits == null) { return null; } int sincePo = udunits.indexOf(" since "); if (sincePo > 0) { try { double baf[] = ErddapCalendar2.getTimeBaseAndFactor(udunits); String u; if (Misc.nearlyEquals(baf[1], 0.001, 1e-6)) { u = "ms"; } else if (baf[1] == 1) { u = "s"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_MINUTE) { u = "min"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_HOUR) { u = "h"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_DAY) { u = "d"; } else if (baf[1] == 30 * ErddapCalendar2.SECONDS_PER_DAY) { u = "mo"; } else if (baf[1] == 360 * ErddapCalendar2.SECONDS_PER_DAY) { u = "a"; } else { u = udunitsToUcum(udunits.substring(0, sincePo)); } return u + "{" + udunits.substring(sincePo + 1) + "}"; } catch (Exception e) { } } StringBuilder ucum = new StringBuilder(); int udLength = udunits.length(); int po = 0; while (po < udLength) { char ch = udunits.charAt(po); if (isUdunitsLetter(ch)) { int po2 = po + 1; while (po2 < udLength && (isUdunitsLetter(udunits.charAt(po2)) || udunits.charAt(po2) == '_' || ErddapString2.isDigit(udunits.charAt(po2)))) { po2++; } String tUdunits = udunits.substring(po, po2); po = po2; int firstDigit = tUdunits.length(); while (firstDigit >= 1 && ErddapString2.isDigit(tUdunits.charAt(firstDigit - 1))) { firstDigit--; } String exponent = tUdunits.substring(firstDigit); tUdunits = tUdunits.substring(0, firstDigit); String tUcum = oneUdunitsToUcum(tUdunits); if (tUcum.equals("/")) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } } else { ucum.append(tUcum); } ucum.append(exponent); continue; } if (ch == '-' || ErddapString2.isDigit(ch)) { int po2 = po + 1; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } boolean hasDot = false; if (po2 < udLength - 1 && udunits.charAt(po2) == '.' && ErddapString2.isDigit(udunits.charAt(po2 + 1))) { hasDot = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } boolean hasE = false; if (po2 < udLength - 1 && Character.toLowerCase(udunits.charAt(po2)) == 'e' && (udunits.charAt(po2 + 1) == '-' || ErddapString2.isDigit(udunits.charAt(po2 + 1)))) { hasE = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } String num = udunits.substring(po, po2); po = po2; if (hasDot || hasE) { int rational[] = ErddapString2.toRational(ErddapString2.parseDouble(num)); if (rational[1] == Integer.MAX_VALUE) { ucum.append(num); } else if (rational[1] == 0) { ucum.append(rational[0]); } else { ucum.append(rational[0]).append(".10^").append(rational[1]); } } else { ucum.append(num); } continue; } if (ch == ' ' || ch == '.' || ch == 183) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } po++; continue; } if (ch == '*') { po++; if (po < udLength && udunits.charAt(po) == '*') { ucum.append('^'); po++; } else { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } } continue; } if (ch == '/') { po++; char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } continue; } if (ch == '\"') { po++; ucum.append("''"); continue; } ucum.append(ch); po++; } return ucum.toString(); }
ErddapEDUnits { public static String udunitsToUcum(String udunits) { if (udunits == null) { return null; } int sincePo = udunits.indexOf(" since "); if (sincePo > 0) { try { double baf[] = ErddapCalendar2.getTimeBaseAndFactor(udunits); String u; if (Misc.nearlyEquals(baf[1], 0.001, 1e-6)) { u = "ms"; } else if (baf[1] == 1) { u = "s"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_MINUTE) { u = "min"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_HOUR) { u = "h"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_DAY) { u = "d"; } else if (baf[1] == 30 * ErddapCalendar2.SECONDS_PER_DAY) { u = "mo"; } else if (baf[1] == 360 * ErddapCalendar2.SECONDS_PER_DAY) { u = "a"; } else { u = udunitsToUcum(udunits.substring(0, sincePo)); } return u + "{" + udunits.substring(sincePo + 1) + "}"; } catch (Exception e) { } } StringBuilder ucum = new StringBuilder(); int udLength = udunits.length(); int po = 0; while (po < udLength) { char ch = udunits.charAt(po); if (isUdunitsLetter(ch)) { int po2 = po + 1; while (po2 < udLength && (isUdunitsLetter(udunits.charAt(po2)) || udunits.charAt(po2) == '_' || ErddapString2.isDigit(udunits.charAt(po2)))) { po2++; } String tUdunits = udunits.substring(po, po2); po = po2; int firstDigit = tUdunits.length(); while (firstDigit >= 1 && ErddapString2.isDigit(tUdunits.charAt(firstDigit - 1))) { firstDigit--; } String exponent = tUdunits.substring(firstDigit); tUdunits = tUdunits.substring(0, firstDigit); String tUcum = oneUdunitsToUcum(tUdunits); if (tUcum.equals("/")) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } } else { ucum.append(tUcum); } ucum.append(exponent); continue; } if (ch == '-' || ErddapString2.isDigit(ch)) { int po2 = po + 1; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } boolean hasDot = false; if (po2 < udLength - 1 && udunits.charAt(po2) == '.' && ErddapString2.isDigit(udunits.charAt(po2 + 1))) { hasDot = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } boolean hasE = false; if (po2 < udLength - 1 && Character.toLowerCase(udunits.charAt(po2)) == 'e' && (udunits.charAt(po2 + 1) == '-' || ErddapString2.isDigit(udunits.charAt(po2 + 1)))) { hasE = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } String num = udunits.substring(po, po2); po = po2; if (hasDot || hasE) { int rational[] = ErddapString2.toRational(ErddapString2.parseDouble(num)); if (rational[1] == Integer.MAX_VALUE) { ucum.append(num); } else if (rational[1] == 0) { ucum.append(rational[0]); } else { ucum.append(rational[0]).append(".10^").append(rational[1]); } } else { ucum.append(num); } continue; } if (ch == ' ' || ch == '.' || ch == 183) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } po++; continue; } if (ch == '*') { po++; if (po < udLength && udunits.charAt(po) == '*') { ucum.append('^'); po++; } else { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } } continue; } if (ch == '/') { po++; char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } continue; } if (ch == '\"') { po++; ucum.append("''"); continue; } ucum.append(ch); po++; } return ucum.toString(); } }
ErddapEDUnits { public static String udunitsToUcum(String udunits) { if (udunits == null) { return null; } int sincePo = udunits.indexOf(" since "); if (sincePo > 0) { try { double baf[] = ErddapCalendar2.getTimeBaseAndFactor(udunits); String u; if (Misc.nearlyEquals(baf[1], 0.001, 1e-6)) { u = "ms"; } else if (baf[1] == 1) { u = "s"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_MINUTE) { u = "min"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_HOUR) { u = "h"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_DAY) { u = "d"; } else if (baf[1] == 30 * ErddapCalendar2.SECONDS_PER_DAY) { u = "mo"; } else if (baf[1] == 360 * ErddapCalendar2.SECONDS_PER_DAY) { u = "a"; } else { u = udunitsToUcum(udunits.substring(0, sincePo)); } return u + "{" + udunits.substring(sincePo + 1) + "}"; } catch (Exception e) { } } StringBuilder ucum = new StringBuilder(); int udLength = udunits.length(); int po = 0; while (po < udLength) { char ch = udunits.charAt(po); if (isUdunitsLetter(ch)) { int po2 = po + 1; while (po2 < udLength && (isUdunitsLetter(udunits.charAt(po2)) || udunits.charAt(po2) == '_' || ErddapString2.isDigit(udunits.charAt(po2)))) { po2++; } String tUdunits = udunits.substring(po, po2); po = po2; int firstDigit = tUdunits.length(); while (firstDigit >= 1 && ErddapString2.isDigit(tUdunits.charAt(firstDigit - 1))) { firstDigit--; } String exponent = tUdunits.substring(firstDigit); tUdunits = tUdunits.substring(0, firstDigit); String tUcum = oneUdunitsToUcum(tUdunits); if (tUcum.equals("/")) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } } else { ucum.append(tUcum); } ucum.append(exponent); continue; } if (ch == '-' || ErddapString2.isDigit(ch)) { int po2 = po + 1; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } boolean hasDot = false; if (po2 < udLength - 1 && udunits.charAt(po2) == '.' && ErddapString2.isDigit(udunits.charAt(po2 + 1))) { hasDot = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } boolean hasE = false; if (po2 < udLength - 1 && Character.toLowerCase(udunits.charAt(po2)) == 'e' && (udunits.charAt(po2 + 1) == '-' || ErddapString2.isDigit(udunits.charAt(po2 + 1)))) { hasE = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } String num = udunits.substring(po, po2); po = po2; if (hasDot || hasE) { int rational[] = ErddapString2.toRational(ErddapString2.parseDouble(num)); if (rational[1] == Integer.MAX_VALUE) { ucum.append(num); } else if (rational[1] == 0) { ucum.append(rational[0]); } else { ucum.append(rational[0]).append(".10^").append(rational[1]); } } else { ucum.append(num); } continue; } if (ch == ' ' || ch == '.' || ch == 183) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } po++; continue; } if (ch == '*') { po++; if (po < udLength && udunits.charAt(po) == '*') { ucum.append('^'); po++; } else { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } } continue; } if (ch == '/') { po++; char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } continue; } if (ch == '\"') { po++; ucum.append("''"); continue; } ucum.append(ch); po++; } return ucum.toString(); }  }
ErddapEDUnits { public static String udunitsToUcum(String udunits) { if (udunits == null) { return null; } int sincePo = udunits.indexOf(" since "); if (sincePo > 0) { try { double baf[] = ErddapCalendar2.getTimeBaseAndFactor(udunits); String u; if (Misc.nearlyEquals(baf[1], 0.001, 1e-6)) { u = "ms"; } else if (baf[1] == 1) { u = "s"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_MINUTE) { u = "min"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_HOUR) { u = "h"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_DAY) { u = "d"; } else if (baf[1] == 30 * ErddapCalendar2.SECONDS_PER_DAY) { u = "mo"; } else if (baf[1] == 360 * ErddapCalendar2.SECONDS_PER_DAY) { u = "a"; } else { u = udunitsToUcum(udunits.substring(0, sincePo)); } return u + "{" + udunits.substring(sincePo + 1) + "}"; } catch (Exception e) { } } StringBuilder ucum = new StringBuilder(); int udLength = udunits.length(); int po = 0; while (po < udLength) { char ch = udunits.charAt(po); if (isUdunitsLetter(ch)) { int po2 = po + 1; while (po2 < udLength && (isUdunitsLetter(udunits.charAt(po2)) || udunits.charAt(po2) == '_' || ErddapString2.isDigit(udunits.charAt(po2)))) { po2++; } String tUdunits = udunits.substring(po, po2); po = po2; int firstDigit = tUdunits.length(); while (firstDigit >= 1 && ErddapString2.isDigit(tUdunits.charAt(firstDigit - 1))) { firstDigit--; } String exponent = tUdunits.substring(firstDigit); tUdunits = tUdunits.substring(0, firstDigit); String tUcum = oneUdunitsToUcum(tUdunits); if (tUcum.equals("/")) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } } else { ucum.append(tUcum); } ucum.append(exponent); continue; } if (ch == '-' || ErddapString2.isDigit(ch)) { int po2 = po + 1; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } boolean hasDot = false; if (po2 < udLength - 1 && udunits.charAt(po2) == '.' && ErddapString2.isDigit(udunits.charAt(po2 + 1))) { hasDot = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } boolean hasE = false; if (po2 < udLength - 1 && Character.toLowerCase(udunits.charAt(po2)) == 'e' && (udunits.charAt(po2 + 1) == '-' || ErddapString2.isDigit(udunits.charAt(po2 + 1)))) { hasE = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } String num = udunits.substring(po, po2); po = po2; if (hasDot || hasE) { int rational[] = ErddapString2.toRational(ErddapString2.parseDouble(num)); if (rational[1] == Integer.MAX_VALUE) { ucum.append(num); } else if (rational[1] == 0) { ucum.append(rational[0]); } else { ucum.append(rational[0]).append(".10^").append(rational[1]); } } else { ucum.append(num); } continue; } if (ch == ' ' || ch == '.' || ch == 183) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } po++; continue; } if (ch == '*') { po++; if (po < udLength && udunits.charAt(po) == '*') { ucum.append('^'); po++; } else { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } } continue; } if (ch == '/') { po++; char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } continue; } if (ch == '\"') { po++; ucum.append("''"); continue; } ucum.append(ch); po++; } return ucum.toString(); }  static String udunitsToUcum(String udunits); static String ucumToUdunits(String ucum); static HashMap<String, String> getHashMapStringString(InputStream inputStream, String charset); }
ErddapEDUnits { public static String udunitsToUcum(String udunits) { if (udunits == null) { return null; } int sincePo = udunits.indexOf(" since "); if (sincePo > 0) { try { double baf[] = ErddapCalendar2.getTimeBaseAndFactor(udunits); String u; if (Misc.nearlyEquals(baf[1], 0.001, 1e-6)) { u = "ms"; } else if (baf[1] == 1) { u = "s"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_MINUTE) { u = "min"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_HOUR) { u = "h"; } else if (baf[1] == ErddapCalendar2.SECONDS_PER_DAY) { u = "d"; } else if (baf[1] == 30 * ErddapCalendar2.SECONDS_PER_DAY) { u = "mo"; } else if (baf[1] == 360 * ErddapCalendar2.SECONDS_PER_DAY) { u = "a"; } else { u = udunitsToUcum(udunits.substring(0, sincePo)); } return u + "{" + udunits.substring(sincePo + 1) + "}"; } catch (Exception e) { } } StringBuilder ucum = new StringBuilder(); int udLength = udunits.length(); int po = 0; while (po < udLength) { char ch = udunits.charAt(po); if (isUdunitsLetter(ch)) { int po2 = po + 1; while (po2 < udLength && (isUdunitsLetter(udunits.charAt(po2)) || udunits.charAt(po2) == '_' || ErddapString2.isDigit(udunits.charAt(po2)))) { po2++; } String tUdunits = udunits.substring(po, po2); po = po2; int firstDigit = tUdunits.length(); while (firstDigit >= 1 && ErddapString2.isDigit(tUdunits.charAt(firstDigit - 1))) { firstDigit--; } String exponent = tUdunits.substring(firstDigit); tUdunits = tUdunits.substring(0, firstDigit); String tUcum = oneUdunitsToUcum(tUdunits); if (tUcum.equals("/")) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } } else { ucum.append(tUcum); } ucum.append(exponent); continue; } if (ch == '-' || ErddapString2.isDigit(ch)) { int po2 = po + 1; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } boolean hasDot = false; if (po2 < udLength - 1 && udunits.charAt(po2) == '.' && ErddapString2.isDigit(udunits.charAt(po2 + 1))) { hasDot = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } boolean hasE = false; if (po2 < udLength - 1 && Character.toLowerCase(udunits.charAt(po2)) == 'e' && (udunits.charAt(po2 + 1) == '-' || ErddapString2.isDigit(udunits.charAt(po2 + 1)))) { hasE = true; po2 += 2; while (po2 < udLength && ErddapString2.isDigit(udunits.charAt(po2))) { po2++; } } String num = udunits.substring(po, po2); po = po2; if (hasDot || hasE) { int rational[] = ErddapString2.toRational(ErddapString2.parseDouble(num)); if (rational[1] == Integer.MAX_VALUE) { ucum.append(num); } else if (rational[1] == 0) { ucum.append(rational[0]); } else { ucum.append(rational[0]).append(".10^").append(rational[1]); } } else { ucum.append(num); } continue; } if (ch == ' ' || ch == '.' || ch == 183) { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } po++; continue; } if (ch == '*') { po++; if (po < udLength && udunits.charAt(po) == '*') { ucum.append('^'); po++; } else { char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/' || lastUcum == '.') { } else { ucum.append('.'); } } continue; } if (ch == '/') { po++; char lastUcum = ucum.length() == 0 ? '\u0000' : ucum.charAt(ucum.length() - 1); if (lastUcum == '/') { ucum.setCharAt(ucum.length() - 1, '.'); } else if (lastUcum == '.') { ucum.setCharAt(ucum.length() - 1, '/'); } else { ucum.append('/'); } continue; } if (ch == '\"') { po++; ucum.append("''"); continue; } ucum.append(ch); po++; } return ucum.toString(); }  static String udunitsToUcum(String udunits); static String ucumToUdunits(String ucum); static HashMap<String, String> getHashMapStringString(InputStream inputStream, String charset); static String metricName; static String metricAcronym; static int nMetric; static String twoAcronym; static String twoValue; static int nTwo; }