parent
1c8bc80789
commit
9a06bdb651
@ -474,7 +474,7 @@ public class MeasureUnitImpl {
|
||||
}
|
||||
|
||||
private static int getTrieIndex(MeasureUnit.SIPrefix prefix) {
|
||||
return prefix.getSiPrefixPower() + UnitsData.Constants.kSIPrefixOffset;
|
||||
return prefix.getPower() + UnitsData.Constants.kSIPrefixOffset;
|
||||
}
|
||||
|
||||
private MeasureUnitImpl parse() {
|
||||
|
@ -105,10 +105,10 @@ public class SingleUnitImpl {
|
||||
if (index > other.index) {
|
||||
return 1;
|
||||
}
|
||||
if (this.getSiPrefix().getSiPrefixPower() < other.getSiPrefix().getSiPrefixPower()) {
|
||||
if (this.getSiPrefix().getPower() < other.getSiPrefix().getPower()) {
|
||||
return -1;
|
||||
}
|
||||
if (this.getSiPrefix().getSiPrefixPower() > other.getSiPrefix().getSiPrefixPower()) {
|
||||
if (this.getSiPrefix().getPower() > other.getSiPrefix().getPower()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -205,9 +205,9 @@ public class UnitConverter {
|
||||
return result;
|
||||
}
|
||||
|
||||
BigDecimal siApplied = BigDecimal.valueOf(Math.pow(10.0, Math.abs(siPrefix.getSiPrefixPower())));
|
||||
BigDecimal siApplied = BigDecimal.valueOf(Math.pow(10.0, Math.abs(siPrefix.getPower())));
|
||||
|
||||
if (siPrefix.getSiPrefixPower() < 0) {
|
||||
if (siPrefix.getPower() < 0) {
|
||||
result.factorDen = this.factorDen.multiply(siApplied);
|
||||
return result;
|
||||
}
|
||||
|
@ -8,20 +8,6 @@
|
||||
*/
|
||||
package com.ibm.icu.util;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.impl.CollectionSet;
|
||||
import com.ibm.icu.impl.ICUData;
|
||||
import com.ibm.icu.impl.ICUResourceBundle;
|
||||
@ -31,6 +17,20 @@ import com.ibm.icu.impl.units.MeasureUnitImpl;
|
||||
import com.ibm.icu.impl.units.SingleUnitImpl;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* A unit such as length, mass, volume, currency, etc. A unit is
|
||||
@ -293,20 +293,32 @@ public class MeasureUnit implements Serializable {
|
||||
*/
|
||||
YOCTO(-24, "yocto");
|
||||
|
||||
private final int siPrefixPower;
|
||||
private final int power;
|
||||
private final String identifier;
|
||||
|
||||
SIPrefix(int siPrefixPower, String identifier) {
|
||||
this.siPrefixPower = siPrefixPower;
|
||||
SIPrefix(int power, String identifier) {
|
||||
this.power = power;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the identifier of the prefix.
|
||||
*
|
||||
* @draft ICU 68
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public int getSiPrefixPower() {
|
||||
return siPrefixPower;
|
||||
/*
|
||||
* Returns the power of 10 of the prefix. For example, if the prefix is "centi", the power will be -2.
|
||||
*
|
||||
* @draft ICU 68
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public int getPower() {
|
||||
return power;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user