Package hec.heclib.util
Class Unit
java.lang.Object
hec.heclib.util.Unit
- All Implemented Interfaces:
Serializable
Holds Unit Definitions, Conversion Factors, and Conversion Functions. Resource file loaded from file system or
classpath via static initializer.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAs Stored Unit Systemstatic final intAs Stored Unit Systemstatic final StringEnglish Unit Systemstatic final intEnglish Unit Systemstatic final StringFile system resource file path relative to CWMS_HOMEstatic final StringURL to resource file in classpathstatic final StringSI Unit Systemstatic final intSI Unit Systemstatic final StringUndefined Units Systemstatic final intUndefined Units System -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddConvFunction(String fromSys, String fromId, String toSys, String toId, double factor) Adds a scalar conversion factors to convert both ways between specified system/unit combinationsstatic voidCreates and adds a RPN conversion function to convert from sys/unit to sys/unitstatic voidaddConvFunction(String fromSys, String fromId, String toSys, String toId, RpnFunction function) Adds the RPN conversion function to convert from sys/unit to sys/unitstatic voidAdds a unit type without any conversionsstatic booleandoesUnitExist(String unitSys, String unitId) Returns true if a unit definition exists for the arg string and systemstatic RpnFunctiongetConvFunction(String fromSys, String fromId, String toSys, String toId) Returns an RpnFunction for use in converting units.Returns a mapping of aliases to unitsstatic String[]getUnitsForSystem(String forSys) Returns the all units for the specific systemstatic String[]getUnitsToConvertTo(String fromSys, String fromUnit) Returns the units that can be converted to from the arg unit and systemstatic String[]Returns known unit system strings ordered alphabeticallystatic String[]Returns all unique unit strings for known systemsstatic voidload()Loads this class from the resource file.static booleanloadFromFile(String filepath) Loads this class from the resource file specified via the filpath argstatic booleanLoads this class from the resource file loaded into the arg readerstatic booleanloadFromUrl(String filepath) Loads this class from a resource file specified via the arg URL
-
Field Details
-
UNDEF
Undefined Units System- See Also:
-
UNDEF_ID
public static final int UNDEF_IDUndefined Units System- See Also:
-
SI
SI Unit System- See Also:
-
SI_ID
public static final int SI_IDSI Unit System- See Also:
-
ENGLISH
English Unit System- See Also:
-
ENGLISH_ID
public static final int ENGLISH_IDEnglish Unit System- See Also:
-
AS_STORED_ID
public static final int AS_STORED_IDAs Stored Unit System- See Also:
-
AS_STORED
As Stored Unit System- See Also:
-
FILEPATH
File system resource file path relative to CWMS_HOME- See Also:
-
FILEURL
URL to resource file in classpath- See Also:
-
-
Constructor Details
-
Unit
public Unit()
-
-
Method Details
-
getUnitSystems
Returns known unit system strings ordered alphabetically -
getUnitsAliasTable
Returns a mapping of aliases to units -
getUnitTypes
Returns all unique unit strings for known systems -
getUnitsForSystem
Returns the all units for the specific system -
getUnitsToConvertTo
Returns the units that can be converted to from the arg unit and system -
getConvFunction
Returns an RpnFunction for use in converting units. -
load
public static void load()Loads this class from the resource file. -
loadFromUrl
Loads this class from a resource file specified via the arg URL -
loadFromFile
Loads this class from the resource file specified via the filpath arg -
loadFromReader
Loads this class from the resource file loaded into the arg reader -
addUnit
Adds a unit type without any conversions -
doesUnitExist
Returns true if a unit definition exists for the arg string and system -
addConvFunction
public static void addConvFunction(String fromSys, String fromId, String toSys, String toId, String strFunction) Creates and adds a RPN conversion function to convert from sys/unit to sys/unit -
addConvFunction
public static void addConvFunction(String fromSys, String fromId, String toSys, String toId, RpnFunction function) Adds the RPN conversion function to convert from sys/unit to sys/unit -
addConvFunction
public static void addConvFunction(String fromSys, String fromId, String toSys, String toId, double factor) Adds a scalar conversion factors to convert both ways between specified system/unit combinations- Parameters:
fromSys- The feature to be added to the ConvFunction attributefromId- The feature to be added to the ConvFunction attributetoSys- The feature to be added to the ConvFunction attributetoId- The feature to be added to the ConvFunction attributefactor- The feature to be added to the ConvFunction attribute
-