Class OceanusDecimalParser
java.lang.Object
io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimalParser
Parsing methods for decimals in a particular locale.
- Author:
- Tony Washer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPerCent adjustment.static final intPerMille adjustment. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateMoneyFromDouble(Double pValue) create Money from double.createMoneyFromDouble(Double pValue, String pCurrCode) create Money from double.createPriceFromDouble(Double pValue) create Price from double.createPriceFromDouble(Double pValue, String pCurrCode) create Price from double.createRateFromDouble(Double pValue) create Rate from double.createRatioFromDouble(Double pValue) create Ratio from double.createUnitsFromDouble(Double pValue) create Units from double.final CurrencyObtain the default currency.parseDecimalValue(String pValue, int pScale) Parse Decimal value.protected static voidparseDecimalValue(String pValue, OceanusDecimal pResult) Parse a string into a decimal.protected static voidparseDecimalValue(String pValue, OceanusDecimalLocale pLocale, boolean useMoneyDecimal, OceanusDecimal pResult) Parse a string into a decimal.parseIntegerValue(String pValue) Parse Integer value.parseLongValue(String pValue) Parse Long value.protected static longparseLongValue(String pValue, OceanusDecimalLocale pLocale) Parse a long value.parseMoneyValue(String pValue) Parse Money value.parseMoneyValue(String pValue, Currency pDeemedCurrency) Parse Money value.parsePriceValue(String pValue) Parse Price value.parsePriceValue(String pValue, Currency pDeemedCurrency) Parse Price value.parseRateValue(String pValue) Parse Rate value.parseRatioValue(String pValue) Parse Ratio value.parseShortValue(String pValue) Parse Short value.parseUnitsValue(String pValue) Parse Units value.final voidSet the locale.voidsetStrictDecimals(boolean bStrictDecimals) Should we parse to strict decimals.Obtain a new zero money value for the default currency.Obtain a new zero money value for the currency.Obtain a new zero price value for the default currency.Obtain a new zero price value for the currency.
-
Field Details
-
ADJUST_PERCENT
public static final int ADJUST_PERCENTPerCent adjustment.- See Also:
-
ADJUST_PERMILLE
public static final int ADJUST_PERMILLEPerMille adjustment.- See Also:
-
-
Constructor Details
-
OceanusDecimalParser
public OceanusDecimalParser()Constructor. -
OceanusDecimalParser
Constructor.- Parameters:
pLocale- the locale
-
-
Method Details
-
setStrictDecimals
public void setStrictDecimals(boolean bStrictDecimals) Should we parse to strict decimals.- Parameters:
bStrictDecimals- true/false
-
setLocale
Set the locale.- Parameters:
pLocale- the locale
-
getDefaultCurrency
Obtain the default currency.- Returns:
- the default currency
-
parseDecimalValue
Parse a string into a decimal.- Parameters:
pValue- The value to parse.pResult- the decimal to hold the result in- Throws:
IllegalArgumentException- on invalid decimal
-
parseDecimalValue
protected static void parseDecimalValue(String pValue, OceanusDecimalLocale pLocale, boolean useMoneyDecimal, OceanusDecimal pResult) Parse a string into a decimal.- Parameters:
pValue- The value to parse.pLocale- the Decimal localeuseMoneyDecimal- use money decimal rather than standard decimal true/falsepResult- the decimal to hold the result in- Throws:
IllegalArgumentException- on invalid decimal
-
parseLongValue
Parse a long value.- Parameters:
pValue- The value to parse.pLocale- the Decimal locale- Returns:
- the long value
- Throws:
IllegalArgumentException- on invalid decimal
-
zeroMoney
Obtain a new zero money value for the default currency.- Returns:
- the new money
-
zeroMoney
Obtain a new zero money value for the currency.- Parameters:
pCurrency- the currency- Returns:
- the new money
-
parseMoneyValue
Parse Money value.- Parameters:
pValue- the string value to parse.- Returns:
- the parsed money
- Throws:
IllegalArgumentException- on invalid money value
-
parseMoneyValue
Parse Money value.- Parameters:
pValue- the string value to parse.pDeemedCurrency- the assumed currency if no currency identifier- Returns:
- the parsed money
- Throws:
IllegalArgumentException- on invalid money value
-
zeroPrice
Obtain a new zero price value for the default currency.- Returns:
- the new price
-
zeroPrice
Obtain a new zero price value for the currency.- Parameters:
pCurrency- the currency- Returns:
- the new price
-
parsePriceValue
Parse Price value.- Parameters:
pValue- the string value to parse.- Returns:
- the parsed price
- Throws:
IllegalArgumentException- on invalid price value
-
parsePriceValue
Parse Price value.- Parameters:
pValue- the string value to parse.pDeemedCurrency- the assumed currency if no currency identifier- Returns:
- the parsed price
- Throws:
IllegalArgumentException- on invalid price value
-
parseRateValue
Parse Rate value.- Parameters:
pValue- the string value to parse.- Returns:
- the parsed rate
- Throws:
IllegalArgumentException- on invalid rate value
-
parseUnitsValue
Parse Units value.- Parameters:
pValue- the string value to parse.- Returns:
- the parsed units
- Throws:
IllegalArgumentException- on invalid units value
-
parseRatioValue
Parse Ratio value.- Parameters:
pValue- the string value to parse.- Returns:
- the parsed ratio
- Throws:
IllegalArgumentException- on invalid ratio value
-
parseDecimalValue
Parse Decimal value.- Parameters:
pValue- the string value to parse.pScale- the scale of the resulting decimal- Returns:
- the parsed decimal
- Throws:
IllegalArgumentException- on invalid decimal value
-
parseLongValue
Parse Long value.- Parameters:
pValue- the string value to parse.- Returns:
- the parsed value
- Throws:
IllegalArgumentException- on invalid value
-
parseIntegerValue
Parse Integer value.- Parameters:
pValue- the string value to parse.- Returns:
- the parsed value
- Throws:
IllegalArgumentException- on invalid value
-
parseShortValue
Parse Short value.- Parameters:
pValue- the string value to parse.- Returns:
- the parsed value
- Throws:
IllegalArgumentException- on invalid value
-
createMoneyFromDouble
create Money from double.- Parameters:
pValue- the double value.- Returns:
- the parsed money
- Throws:
IllegalArgumentException- on invalid money value
-
createMoneyFromDouble
create Money from double.- Parameters:
pValue- the double value.pCurrCode- the currency code- Returns:
- the parsed money
- Throws:
IllegalArgumentException- on invalid money value
-
createPriceFromDouble
create Price from double.- Parameters:
pValue- the double value.- Returns:
- the parsed price
- Throws:
IllegalArgumentException- on invalid price value
-
createPriceFromDouble
create Price from double.- Parameters:
pValue- the double value.pCurrCode- the currency code- Returns:
- the parsed price
- Throws:
IllegalArgumentException- on invalid price value
-
createRateFromDouble
create Rate from double.- Parameters:
pValue- the double value.- Returns:
- the parsed rate
- Throws:
IllegalArgumentException- on invalid rate value
-
createUnitsFromDouble
create Units from double.- Parameters:
pValue- the double value.- Returns:
- the parsed units
- Throws:
IllegalArgumentException- on invalid units value
-
createRatioFromDouble
create Ratio from double.- Parameters:
pValue- the double value.- Returns:
- the parsed ratio
- Throws:
IllegalArgumentException- on invalid ratio value
-