Package com.irurueta.units
Class AngleFormatter
- All Implemented Interfaces:
Cloneable
Formats and parses angle value and unit.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDegree symbol.private static final StringPattern to format degrees and minutes.private static final StringPattern to parse degrees and minutes expressions.private static final StringPattern to format degrees, minutes and seconds.private static final StringPattern to parse degrees, minutes and seconds expressions.private PatternPattern to parse angle in degrees and decimal minutes format.private PatternPattern to parse angle in degrees, minutes and decimal seconds format.static final StringRadian symbol.Fields inherited from class com.irurueta.units.MeasureFormatter
DEFAULT_VALUE_AND_UNIT_FORMAT_PATTERN, numberFormat -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.AngleFormatter(AngleFormatter formatter) Copy constructor.AngleFormatter(Locale locale) Constructor with locale. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if two angle formatters are equal by comparing all of its internal parameters.Attempts to determine an angle unit within a measurement string representation.formatAndConvert(Number value, AngleUnit unit, UnitSystem system) Formats and converts provided angle value and unit using metric system.formatDegreesAndMinutes(Angle angle) Formats provided angle into degrees and decimal minutes.Formats provided angle into degrees, minutes and decimal seconds.getUnitSymbol(AngleUnit 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 an angle value and unit.parseDegreesAndMinutes(CharSequence source) Parses provided string representation using degrees and decimal minutes format.Parses provided string representation using degrees, minutes and decimal seconds format.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
-
DEGREE
Degree symbol.- See Also:
-
RADIAN
Radian symbol.- See Also:
-
DEGREES_AND_MINUTES_MESSAGE_PATTERN
Pattern to format degrees and minutes.- See Also:
-
DEGREES_MINUTES_AND_SECONDS_MESSAGE_PATTERN
Pattern to format degrees, minutes and seconds.- See Also:
-
DEGREES_AND_MINUTES_PATTERN
Pattern to parse degrees and minutes expressions.- See Also:
-
DEGREES_MINUTES_AND_SECONDS_PATTERN
Pattern to parse degrees, minutes and seconds expressions.- See Also:
-
degreesAndMinutesPattern
Pattern to parse angle in degrees and decimal minutes format. -
degreesMinutesAndSecondsPattern
Pattern to parse angle in degrees, minutes and decimal seconds format.
-
-
Constructor Details
-
AngleFormatter
public AngleFormatter()Constructor. -
AngleFormatter
Constructor with locale.- Parameters:
locale- locale.- Throws:
IllegalArgumentException- if locale is null.
-
AngleFormatter
Copy constructor.- Parameters:
formatter- input instance to copy from.- Throws:
NullPointerException- if provided formatter is null.
-
-
Method Details
-
equals
Determines if two angle formatters are equal by comparing all of its internal parameters.- Overrides:
equalsin classMeasureFormatter<Angle,AngleUnit> - 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<Angle,AngleUnit> - Returns:
- hash code.
-
getUnitSystem
Gets unit system for detected unit into provided string representation of a measurement.- Specified by:
getUnitSystemin classMeasureFormatter<Angle,AngleUnit> - Parameters:
source- a measurement string representation to be checked.- Returns:
- a unit system (metric) or null if unit cannot be determined.
-
parse
Parses provided string and tries to determine an angle value and unit.- Specified by:
parsein classMeasureFormatter<Angle,AngleUnit> - Parameters:
source- a string to be parsed.- Returns:
- an angle containing a value and unit.
- Throws:
ParseException- if provided string cannot be parsed.UnknownUnitException- if unit cannot be determined.
-
findUnit
Attempts to determine an angle unit within a measurement string representation.- Specified by:
findUnitin classMeasureFormatter<Angle,AngleUnit> - Parameters:
source- an angle measurement string representation.- Returns:
- an angle unit, or null if none can be determined.
-
formatAndConvert
Formats and converts provided angle value and unit using metric system. This implementation ignores provided unit system.- Specified by:
formatAndConvertin classMeasureFormatter<Angle,AngleUnit> - Parameters:
value- a measurement value.unit- a measurement unit.system- ignored.- Returns:
- a string representation of angle value and unit.
-
getUnitSymbol
Returns unit string representation.- Specified by:
getUnitSymbolin classMeasureFormatter<Angle,AngleUnit> - Parameters:
unit- an angle unit.- Returns:
- its string representation.
-
formatDegreesAndMinutes
Formats provided angle into degrees and decimal minutes.- Parameters:
angle- angle to be formatted.- Returns:
- string representation of provided angle expressed as degrees and decimal minutes.
-
formatDegreesMinutesAndSeconds
Formats provided angle into degrees, minutes and decimal seconds.- Parameters:
angle- angle to be formatted.- Returns:
- string representation of provided angle expressed as degrees, minutes and decimal seconds.
-
parseDegreesAndMinutes
public Angle parseDegreesAndMinutes(CharSequence source) throws ParseException, UnknownUnitException Parses provided string representation using degrees and decimal minutes format. Note: decimals are not accepted on degrees value.- Parameters:
source- string to be parsed.- Returns:
- parsed angle.
- Throws:
ParseException- if parsing fails.UnknownUnitException- if format is not recognized.
-
parseDegreesMinutesAndSeconds
public Angle parseDegreesMinutesAndSeconds(CharSequence source) throws ParseException, UnknownUnitException Parses provided string representation using degrees, minutes and decimal seconds format.- Parameters:
source- string to be parsed.- Returns:
- parsed angle.
- Throws:
ParseException- if parsing fails.UnknownUnitException- if format is not recognized.
-