Package com.irurueta.units
Class SurfaceFormatter
- All Implemented Interfaces:
Cloneable
Formats and parses surface value and unit.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAcre symbol.static final StringAre symbol.static final StringCentiare symbol.static final StringDecare symbol.static final StringHectare symbol.static final StringSquare centimeter symbol.static final StringSquare foot symbol.static final StringSquare inch symbol.static final StringSquare kilometer symbol.static final StringSquare meter symbol.static final StringSquare mile symbol.static final StringSquare millimeter symbol.static final StringSquare yard symbol.Fields inherited from class com.irurueta.units.MeasureFormatter
DEFAULT_VALUE_AND_UNIT_FORMAT_PATTERN, numberFormat -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.SurfaceFormatter(SurfaceFormatter formatter) Copy constructor.SurfaceFormatter(Locale locale) Constructor with locale. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if two distance formatters are equal by comparing all of its internal parameters.Attempts to determine a surface unit within a measurement string representation.formatAndConvert(Number value, SurfaceUnit unit, UnitSystem system) Formats and converts provided surface value and unit using provided unit system.formatAndConvertImperial(Number value, SurfaceUnit unit) Formats and converts provided surface value and unit using imperial unit system.formatAndConvertMetric(Number value, SurfaceUnit unit) Formats and converts provided surface value and unit using metric unit system.getUnitSymbol(SurfaceUnit unit) Returns unit string representation.getUnitSystem(String source) Gets unit system for detected unit into provided string representation of a measurement.inthashCode()Hash code generated for this instance.Parses provided string and tries to determine a surface value and unit.Methods inherited from class com.irurueta.units.MeasureFormatter
clone, format, format, format, format, format, format, formatAndConvert, formatAndConvert, formatAndConvert, formatAndConvert, formatAndConvert, getAvailableLocales, getLocale, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getRoundingMode, getUnitSystem, getValueAndUnitFormatPattern, internalClone, internalParse, isGroupingUsed, isImperialUnit, isMetricUnit, isParseIntegerOnly, isValidMeasurement, isValidUnit, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingMode, setValueAndUnitFormatPattern
-
Field Details
-
SQUARE_MILLIMETER
Square millimeter symbol.- See Also:
-
SQUARE_CENTIMETER
Square centimeter symbol.- See Also:
-
SQUARE_METER
Square meter symbol.- See Also:
-
SQUARE_KILOMETER
Square kilometer symbol.- See Also:
-
SQUARE_INCH
Square inch symbol.- See Also:
-
SQUARE_FOOT
Square foot symbol.- See Also:
-
SQUARE_YARD
Square yard symbol.- See Also:
-
SQUARE_MILE
Square mile symbol.- See Also:
-
CENTIARE
Centiare symbol.- See Also:
-
ARE
Are symbol.- See Also:
-
DECARE
Decare symbol.- See Also:
-
HECTARE
Hectare symbol.- See Also:
-
ACRE
Acre symbol.- See Also:
-
-
Constructor Details
-
SurfaceFormatter
public SurfaceFormatter()Constructor. -
SurfaceFormatter
Constructor with locale.- Parameters:
locale- locale.- Throws:
IllegalArgumentException- if locale is null.
-
SurfaceFormatter
Copy constructor.- Parameters:
formatter- input instance to copy from.- Throws:
NullPointerException- if provided formatter is null.
-
-
Method Details
-
equals
Determines if two distance formatters are equal by comparing all of its internal parameters.- Overrides:
equalsin classMeasureFormatter<Surface,SurfaceUnit> - Parameters:
obj- another object to compare.- Returns:
- true if provided object is assumed to be equal to this instance.
-
hashCode
public int hashCode()Hash code generated for this instance. Hash codes can be internally used by some collections to coarsely compare objects. This implementation only calls parent implementation to avoid static analyzer warning.- Overrides:
hashCodein classMeasureFormatter<Surface,SurfaceUnit> - Returns:
- hash code.
-
getUnitSystem
Gets unit system for detected unit into provided string representation of a measurement.- Specified by:
getUnitSystemin classMeasureFormatter<Surface,SurfaceUnit> - Parameters:
source- a measurement string representation to be checked.- Returns:
- a unit system (either metric or imperial) or null if unit cannot be determined.
-
parse
Parses provided string and tries to determine a surface value and unit.- Specified by:
parsein classMeasureFormatter<Surface,SurfaceUnit> - Parameters:
source- text to be parsed.- Returns:
- a surface containing a value and unit.
- Throws:
ParseException- if provided string cannot be parsed.UnknownUnitException- if unit cannot be determined.
-
findUnit
Attempts to determine a surface unit within a measurement string representation.- Specified by:
findUnitin classMeasureFormatter<Surface,SurfaceUnit> - Parameters:
source- a surface measurement string representation.- Returns:
- a surface unit, or null if none can be determined.
-
formatAndConvert
Formats and converts provided surface value and unit using provided unit system. If provided value is too large for provided unit, this method will convert it to a more appropriate unit using provided unit system (either metric or imperial).- Specified by:
formatAndConvertin classMeasureFormatter<Surface,SurfaceUnit> - Parameters:
value- a surface value.unit- a surface unit.system- system unit to convert surface to.- Returns:
- a string representation of surface value and unit.
-
formatAndConvertMetric
Formats and converts provided surface value and unit using metric unit system. If provided surface value is too large for provided surface unit, this method will convert it to a more appropriate unit.- Parameters:
value- a surface value.unit- a surface unit.- Returns:
- a string representation of surface value and unit using metric unit system.
-
formatAndConvertImperial
Formats and converts provided surface value and unit using imperial unit system. If provided surface value is too large for provided surface unit, this method will convert it to a more appropriate unit.- Parameters:
value- a surface value.unit- a surface unit.- Returns:
- a string representation of surface value and unit using imperial unit system.
-
getUnitSymbol
Returns unit string representation.- Specified by:
getUnitSymbolin classMeasureFormatter<Surface,SurfaceUnit> - Parameters:
unit- a measure unit.- Returns:
- its string representation.
-