Package org.cip4.jdflib.util
Class UnitParser
java.lang.Object
org.cip4.jdflib.util.UnitParser
class to parse units from strings
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUnitKey(String key) voidconvertUnits(KElement element) voidconvertUnits(KElement element, boolean recurse) extractUnits(String val) extract units if and only if the string has a pattern of "<##>mm" or "<##>cm"or "<##>in" whitespace characters may be placed between the numbers and the units the unit case is ignoredextractUnits(String key, String val) doubleget the factor for one of the units to pointsgetNoUnitString(UnitParser.eParserUnit unit, double points) getNoUnitString(UnitParser.eParserUnit unit, double points, String separator) getter for unit attributeintGetter for precision attribute.getUnitString(String key, UnitParser.eParserUnit pu, String val0, String sep) getUnitString(UnitParser.eParserUnit pu, String val0, String sep) extract units if and only if the string has a pattern of "<##>mm" or "<##>cm"or "<##>in" whitespace characters may be placed between the numbers and the units the unit case is ignoredbooleanvoidsetPrecision(int precision) Setter for precision attribute.toString()
-
Constructor Details
-
UnitParser
public UnitParser()
-
-
Method Details
-
convertUnits
- Parameters:
element-
-
convertUnits
- Parameters:
element-
-
isUnit
- Parameters:
key-- Returns:
-
addUnitKey
- Parameters:
key-
-
getFactor
get the factor for one of the units to points- Parameters:
unit-- Returns:
-
extractUnits
- Parameters:
key- the attribute name to checkval-- Returns:
-
getUnitString
-
getUnitString
extract units if and only if the string has a pattern of "<##>mm" or "<##>cm"or "<##>in" whitespace characters may be placed between the numbers and the units the unit case is ignored- Parameters:
val- the string to convert- Returns:
- the converted unit string
-
extractUnits
extract units if and only if the string has a pattern of "<##>mm" or "<##>cm"or "<##>in" whitespace characters may be placed between the numbers and the units the unit case is ignored- Parameters:
val- the string to convert- Returns:
- the converted unit string
-
setPrecision
public void setPrecision(int precision) Setter for precision attribute.- Parameters:
precision- the precision to set
-
getNoUnitString
getter for unit attribute- Parameters:
precision- the precision to set
-
getNoUnitString
-
getPrecision
public int getPrecision()Getter for precision attribute.- Returns:
- the precision
-
toString
-