public class GMetricUnit extends Object implements GUnit
Le propos de cette classe est de fournir à l'utilisateur la possibilité de saisir des unités basées sur le Système International ainsi que les méthodes de conversion. Les unitès composées sont séparées par des "." ou des "/". La puissance s'exprime par le caractère ^. La puissance peut être négative. Ainsi km/s est équivalent à km.s^-1 et 1/s est égal à s-1
Les unités de bases prises en comptes sont :
Les unités composées avec leur définition par rapport aux unités de bases sont :
Les multiples et sous muiltiples pris en comptes sont :
| Constructor and Description |
|---|
GMetricUnit(String unitName)
Constructeur par defaut.
|
| Modifier and Type | Method and Description |
|---|---|
BigDecimal |
convertFromMemory(BigDecimal value)
Converts the value from the memory unit.
|
double |
convertFromMemory(double value)
Converts the value from the memory unit.
|
BigDecimal |
convertToMemory(BigDecimal value)
Converts the value to the memory unit.
|
double |
convertToMemory(double value)
Converts the value to the memory unit.
|
BigDecimal |
convertToUnit(BigDecimal value,
GUnit destUnit)
Converts the units of value to unit.
|
double |
convertToUnit(double value,
GUnit destUnit)
Converts the units of value to unit.
|
String |
getCompactedName()
Returns the name of the unit decomposed in basicUnits, without multipliers and sorted.
|
String |
getName()
Get the string representing the unit name.
|
boolean |
isCompatible(GUnit unit)
Determines if unit is compatible with the GUnit object.
|
boolean |
isValidUnitName(String unitName)
Verify if a unit name string represents a valid unit.
|
public GMetricUnit(String unitName)
unitName - nom composé de l'unitépublic boolean isValidUnitName(String unitName)
isValidUnitName in interface GUnitunitName - unit name string to test.public boolean isCompatible(GUnit unit)
isCompatible in interface GUnitunit - to check if it is compatible.public double convertToUnit(double value,
GUnit destUnit)
throws GException
convertToUnit in interface GUnitvalue - to convert.destUnit - the destination unit.GException - in case of an error performing the conversion.public double convertToMemory(double value)
convertToMemory in interface GUnitvalue - to convert.public double convertFromMemory(double value)
convertFromMemory in interface GUnitvalue - to convert.public String getName()
public String getCompactedName()
getCompactedName in interface GUnitpublic BigDecimal convertToUnit(BigDecimal value, GUnit destUnit) throws GException
convertToUnit in interface GUnitvalue - to convert.destUnit - the destination unit.GException - in case of an error performing the conversion.public BigDecimal convertToMemory(BigDecimal value)
convertToMemory in interface GUnitvalue - to convert.public BigDecimal convertFromMemory(BigDecimal value)
convertFromMemory in interface GUnitvalue - to convert.Copyright © 2024. All rights reserved.