IMC Epclient 5.0.3

at.spardat.enterprise.util
Class NumberUtil

java.lang.Object
  extended byat.spardat.enterprise.util.NumberUtil

public class NumberUtil
extends java.lang.Object

Provides some utility methods pertaining to numbers.


Nested Class Summary
static class NumberUtil.Metric
          Returned from method getMetric(java.lang.String) to describe a canonic number
 
Constructor Summary
NumberUtil()
           
 
Method Summary
static void appendIntString(int i, int minLen, java.lang.StringBuffer toAppendTo)
          Converts a nonnegative integer to a string, left-pads with zeros up to a given length and appends the result to a StringBuffer.
static java.lang.String double2String(double d)
          Converts a double to a fixed point number string using a point as decimal separation character (canonic format, see above).
static NumberUtil.Metric getMetric(java.lang.String v)
          Parses a provided number in the so called canonic number format and returns some information about it.
static boolean isDigit(char ch)
          Provides a fast but not locale independent implementation of numeric check.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberUtil

public NumberUtil()
Method Detail

getMetric

public static NumberUtil.Metric getMetric(java.lang.String v)
Parses a provided number in the so called canonic number format and returns some information about it. We consider a number encoding to be canonic if it obeys the following syntax: An '-', followed by a sequence of digits, followed by '.', followed by a sequence of digits. All components are optional. At least one digit must be present.

Parameters:
v - the number. Must not be null.
Returns:
a Metric object describing the number or null, if the number is not a canonic one.

isDigit

public static boolean isDigit(char ch)
Provides a fast but not locale independent implementation of numeric check.


appendIntString

public static void appendIntString(int i,
                                   int minLen,
                                   java.lang.StringBuffer toAppendTo)
Converts a nonnegative integer to a string, left-pads with zeros up to a given length and appends the result to a StringBuffer.

This method is performance optimized for small numbers, i.e., numbers less than 10000.

Parameters:
i - integer to be appended. Must not be negative.
minLen - minimum length of appended zero praefixed string
toAppendTo - StringBuffer where to append to

double2String

public static java.lang.String double2String(double d)
Converts a double to a fixed point number string using a point as decimal separation character (canonic format, see above). If the provided double is NaN or Infinity, the empty string is returned. Digits after the comma are reduced so that the total number of significant digits does not exceed 15 digits.

Parameters:
d - the input double
Returns:
string in canonic format

IMC Epclient 5.0.3