Class NumericService

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

    public class NumericService
    extends ServiceConfig
    Numeric service Class Numeric Utilities for AWE
    Author:
    Pablo GARCIA - 16/APR/2012
    • Constructor Detail

      • NumericService

        public NumericService​(NumericConfigProperties numericConfigProperties)
        Hide the constructor
        Parameters:
        numericConfigProperties - Numeric configuration properties
    • Method Detail

      • applyPattern

        public String applyPattern​(String pattern,
                                   Double value)
        Fixes an string value for a criteria
        Parameters:
        pattern - pattern to apply
        value - string number value
        Returns:
        number formatted
      • applyRawPattern

        public String applyRawPattern​(String pattern,
                                      Double value)
        Fixes a string value for a criteria in a raw pattern Use Locale US
        Parameters:
        pattern - Number pattern
        value - String value
        Returns:
        Value fixed
      • applyPatternWithLocale

        public String applyPatternWithLocale​(String pattern,
                                             Double value,
                                             String format)
        Fixes a string value for a criteria in a raw pattern with locale
        Parameters:
        pattern - patter to apply
        value - number value
        format - LOCALE to apply
        Returns:
        String with pattern applied
      • applyPatternWithLocale

        public String applyPatternWithLocale​(String pattern,
                                             Double value,
                                             NumberFormat numberFormat)
        Fixes a string value for a criteria in a raw pattern with locale
        Parameters:
        pattern - patter to apply
        value - number value
        numberFormat - LOCALE to apply
        Returns:
        String with pattern applied
      • formatNumber

        public String formatNumber​(NumberFormat format,
                                   Double value)
        Fixes a string value for a criteria in a raw pattern with locale
        Parameters:
        format - Number format
        value - number value
        Returns:
        Number formatted
      • parseNumericString

        public Number parseNumericString​(String val)
                                  throws ParseException
        Parses a string value to a number. It reads the numeric type from numeric.properties
        Parameters:
        val - String value with format as defined in numeric.properties
        Returns:
        parsedValue parsed number
        Throws:
        ParseException - Error parsing number
      • parseRawNumericString

        public Number parseRawNumericString​(String val)
                                     throws ParseException
        Parses a string value to a number. It parses a string that represents a raw formatted numeric
        Parameters:
        val - String value with format as defined in numeric.properties
        Returns:
        parsedValue parsed number
        Throws:
        ParseException - Error parsing number
      • getDecimalsNumberInNumericString

        public int getDecimalsNumberInNumericString​(String val)
        Returns decimals number a string that represents a formatted numeric
        Parameters:
        val - String value with format as defined in numeric.properties
        Returns:
        decimals number
      • getDecimalsNumberInRawNumericString

        public int getDecimalsNumberInRawNumericString​(String val)
        Returns decimals number a string that represents a raw formatted numeric
        Parameters:
        val - String value with format as defined in numeric.properties
        Returns:
        decimals number