kr.co.hit.live.util
Class NumericHelper

java.lang.Object
  extended by kr.co.hit.live.util.NumericHelper

public class NumericHelper
extends Object

Number(Numeric) 관련 Live Framework의 Helper Class

아래 Method들은 모두 static으로 선언 되었기 때문에 유념하기 바란다.

Since:
3.0
Version:
$Revision: 1.1 $ $Date: 2006/09/26 08:20:12 $
Author:
노준훈(현대정보기술)

Field Summary
static int ROUND_CEILING
           무조건 올림 (음수일 경우에 무조건 내림)
static int ROUND_DOWN
           내림(절사)
static int ROUND_FLOOR
           무조건 내림 (음수일 경우에 무조건 올림)
static int ROUND_HALF_UP
           반올림
static int ROUND_UNNECESSARY
           사용하지 않음
static int ROUND_UP
           올림
 
Constructor Summary
protected NumericHelper()
           NumericHelper의 default 컨스트럭터(Constructor).
 
Method Summary
static String add(String val1, String val2)
           덧셈을 실행하여 문자열로 리턴한다.
static String add(String val1, String val2, int scale)
           덧셈을 실행하여 문자열로 리턴한다.
static String add(String val1, String val2, int scale, int roundMode)
           덧셈을 실행하여 문자열로 리턴한다.
static String divide(String val1, String val2, int roundMode)
           val1 / val2 결과를 문자열로 리턴한다.
static String divide(String val1, String val2, int scale, int roundMode)
           val1 / val2 결과를 문자열로 리턴한다.
static String isDivide(String thisVal, String addVal, int roundMode)
          Deprecated. Use divide Method.
static String isDivide(String thisVal, String addVal, int scale, int roundMode)
          Deprecated. Use divide Method.
static String isMinus(String thisVal, String addVal)
          Deprecated. Use subtract Method.
static String isMinus(String thisVal, String addVal, int scale)
          Deprecated. Use subtract Method.
static String isMinus(String thisVal, String addVal, int scale, int roundMode)
          Deprecated. Use subtract Method.
static String isMultiply(String thisVal, String addVal)
          Deprecated. Use multiply Method.
static String isMultiply(String thisVal, String addVal, int scale)
          Deprecated. Use multiply Method.
static String isMultiply(String thisVal, String addVal, int scale, int roundMode)
          Deprecated. Use multiply Method.
static boolean isNumber(String source)
           문자열의 Number형 문자열인지 여부 (- 기호나 소수점도 포함)
static boolean isNumeric(String str)
          숫자형 문자열인지 확인한다.
static String isPlus(String thisVal, String addVal)
          Deprecated. Use add Method.
static String isPlus(String thisVal, String addVal, int scale)
          Deprecated. Use add Method.
static String isPlus(String thisVal, String addVal, int scale, int roundMode)
          Deprecated. Use add Method.
static String multiply(String val1, String val2)
           곱셈을 실행하여 결과를 문자열로 리턴한다.
static String multiply(String val1, String val2, int scale)
           곱셈을 실행하여 결과를 문자열로 리턴한다.
static String multiply(String val1, String val2, int scale, int roundMode)
           곱셈을 실행하여 결과를 문자열로 리턴한다.
static BigDecimal round(BigDecimal rounder, int scale, int roundMode)
           숫자형 자료의 round 함수.
static double round(double rounder, int scale, int roundMode)
           숫자형 자료의 round 함수.
static long round(long rounder, int scale, int roundMode)
           숫자형 자료의 round 함수.
static String round(String rounder, int scale, int roundMode)
           숫자형 자료의 round 함수.
static String setScale(String thisVal, int scale, int roundMode)
           기본값을 scale 자릿수만큼 ROUND한다.
static String subtract(String val1, String val2)
           기본뺄셈을 실행하여 결과를 문자열로 리턴한다.
static String subtract(String val1, String val2, int scale)
           기본뺄셈을 실행하여 결과를 문자열로 리턴한다.
static String subtract(String val1, String val2, int scale, int roundMode)
           기본뺄셈을 실행하여 결과를 문자열로 리턴한다.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROUND_UP

public static final int ROUND_UP

올림

See Also:
Constant Field Values

ROUND_DOWN

public static final int ROUND_DOWN

내림(절사)

See Also:
Constant Field Values

ROUND_HALF_UP

public static final int ROUND_HALF_UP

반올림

See Also:
Constant Field Values

ROUND_FLOOR

public static final int ROUND_FLOOR

무조건 내림 (음수일 경우에 무조건 올림)

See Also:
Constant Field Values

ROUND_CEILING

public static final int ROUND_CEILING

무조건 올림 (음수일 경우에 무조건 내림)

See Also:
Constant Field Values

ROUND_UNNECESSARY

public static final int ROUND_UNNECESSARY

사용하지 않음

See Also:
Constant Field Values
Constructor Detail

NumericHelper

protected NumericHelper()

NumericHelper의 default 컨스트럭터(Constructor).

Method Detail

isNumber

public static boolean isNumber(String source)

문자열의 Number형 문자열인지 여부 (- 기호나 소수점도 포함)

Parameters:
source - 검증 하고자 하는 문자열
Returns:
숫자형 문자열 여부 (true : 숫자형)

add

public static String add(String val1,
                         String val2)

덧셈을 실행하여 문자열로 리턴한다.

Parameters:
val1 - String
val2 - String
Returns:
결과 값
See Also:
add(String, String, int), add(String, String, int, int)

add

public static String add(String val1,
                         String val2,
                         int scale)

덧셈을 실행하여 문자열로 리턴한다. 덧셈한 결과값의 자릿수를 scale로 지정한다.

Parameters:
val1 - String
val2 - String
scale - int 자리수지정
Returns:
결과 값
See Also:
add(String, String, int, int), add(String, String)

add

public static String add(String val1,
                         String val2,
                         int scale,
                         int roundMode)

덧셈을 실행하여 문자열로 리턴한다. 덧셈한 결과값의 자릿수를 scale로 지정한다. 덧셈한 결과값의 자릿수와 올림,내림,절삭여부를 roundMode로 지정한다.

Parameters:
val1 - String
val2 - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
결과 값
See Also:
add(String, String, int), add(String, String)

subtract

public static String subtract(String val1,
                              String val2)

기본뺄셈을 실행하여 결과를 문자열로 리턴한다.

Parameters:
val1 - String
val2 - String
Returns:
결과 값
See Also:
subtract(String, String, int), subtract(String, String, int, int)

subtract

public static String subtract(String val1,
                              String val2,
                              int scale)

기본뺄셈을 실행하여 결과를 문자열로 리턴한다. 뺄셈한 결과값의 자릿수를 scale로 지정한다.

Parameters:
val1 - String
val2 - String
scale - int 자리수지정
Returns:
결과 값
See Also:
subtract(String, String, int, int), subtract(String, String)

subtract

public static String subtract(String val1,
                              String val2,
                              int scale,
                              int roundMode)

기본뺄셈을 실행하여 결과를 문자열로 리턴한다. 뺄셈한 결과값의 자릿수를 scale로 지정한다. 뺄셈한 결과값의 자릿수와 올림,내림,절삭여부를 roundMode로 지정한다.

Parameters:
val1 - String
val2 - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
결과 값
See Also:
subtract(String, String, int), subtract(String, String)

multiply

public static String multiply(String val1,
                              String val2)

곱셈을 실행하여 결과를 문자열로 리턴한다.

Parameters:
val1 - String
val2 - String
Returns:
결과 값
See Also:
multiply(String, String, int), multiply(String, String, int, int)

multiply

public static String multiply(String val1,
                              String val2,
                              int scale)

곱셈을 실행하여 결과를 문자열로 리턴한다. 곱셈한 결과값의 자릿수를 scale로 지정한다.

Parameters:
val1 - String
val2 - String
scale - int 자리수지정
Returns:
결과 값
See Also:
multiply(String, String, int, int), multiply(String, String)

multiply

public static String multiply(String val1,
                              String val2,
                              int scale,
                              int roundMode)

곱셈을 실행하여 결과를 문자열로 리턴한다. 곱셈한 결과값의 자릿수를 scale로 지정한다. 곱셈한 결과값의 자릿수와 올림,내림,절삭여부를 roundMode로 지정한다.

Parameters:
val1 - String
val2 - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
결과 값
See Also:
multiply(String, String, int), multiply(String, String)

divide

public static String divide(String val1,
                            String val2,
                            int roundMode)

val1 / val2 결과를 문자열로 리턴한다.

Parameters:
val1 - String
val2 - String
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
결과 값
See Also:
divide(String, String, int, int)

divide

public static String divide(String val1,
                            String val2,
                            int scale,
                            int roundMode)

val1 / val2 결과를 문자열로 리턴한다. 계산 결과의 스케일을 scale로 지정한다.

Parameters:
val1 - String
val2 - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
String
See Also:
divide(String, String, int)

setScale

public static String setScale(String thisVal,
                              int scale,
                              int roundMode)

기본값을 scale 자릿수만큼 ROUND한다.

Parameters:
thisVal - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
String

isPlus

@Deprecated
public static String isPlus(String thisVal,
                                       String addVal)
Deprecated. Use add Method.

String형 값의 기본덧셈을 실행한다.

Parameters:
thisVal - String
addVal - String
Returns:
결과 값
See Also:
isPlus(String, String, int), isPlus(String, String, int, int)

isPlus

@Deprecated
public static String isPlus(String thisVal,
                                       String addVal,
                                       int scale)
Deprecated. Use add Method.

덧셈한 결과값의 자릿수만 지정한다.

Parameters:
thisVal - String
addVal - String
scale - int 자리수지정
Returns:
결과 값
See Also:
isPlus(String, String, int, int), isPlus(String, String)

isPlus

@Deprecated
public static String isPlus(String thisVal,
                                       String addVal,
                                       int scale,
                                       int roundMode)
Deprecated. Use add Method.

덧셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다.

Parameters:
thisVal - String
addVal - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
결과 값
See Also:
isPlus(String, String, int), isPlus(String, String)

isMultiply

@Deprecated
public static String isMultiply(String thisVal,
                                           String addVal)
Deprecated. Use multiply Method.

기본곱셈을 실행한다.

Parameters:
thisVal - String
addVal - String
Returns:
결과 값
See Also:
isMultiply(String, String, int), isMultiply(String, String, int, int)

isMultiply

@Deprecated
public static String isMultiply(String thisVal,
                                           String addVal,
                                           int scale)
Deprecated. Use multiply Method.

곱셈한 결과값의 자릿수만 지정한다.

Parameters:
thisVal - String
addVal - String
scale - int 자리수지정
Returns:
결과 값
See Also:
isMultiply(String, String, int, int), isMultiply(String, String)

isMultiply

@Deprecated
public static String isMultiply(String thisVal,
                                           String addVal,
                                           int scale,
                                           int roundMode)
Deprecated. Use multiply Method.

곱셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다.

Parameters:
thisVal - String
addVal - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
결과 값
See Also:
isMultiply(String, String, int), isMultiply(String, String)

isDivide

@Deprecated
public static String isDivide(String thisVal,
                                         String addVal,
                                         int roundMode)
Deprecated. Use divide Method.

나눗셈의 결과값이 정수

Parameters:
thisVal - String
addVal - String
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
결과 값
See Also:
isDivide(String, String, int, int)

isDivide

@Deprecated
public static String isDivide(String thisVal,
                                         String addVal,
                                         int scale,
                                         int roundMode)
Deprecated. Use divide Method.

나눗셈 결과값의 자릿수와 올림,내림,절삭여부 지정한다

Parameters:
thisVal - String
addVal - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
String
See Also:
isDivide(String, String, int)

isMinus

@Deprecated
public static String isMinus(String thisVal,
                                        String addVal)
Deprecated. Use subtract Method.

기본뺄셈을 실행한다.

Parameters:
thisVal - String
addVal - String
Returns:
결과 값
See Also:
isMinus(String, String, int), isMinus(String, String, int, int)

isMinus

@Deprecated
public static String isMinus(String thisVal,
                                        String addVal,
                                        int scale)
Deprecated. Use subtract Method.

뺄셈한 결과값의 자릿수만 지정한다.

Parameters:
thisVal - String
addVal - String
scale - int 자리수지정
Returns:
결과 값
See Also:
isMinus(String, String, int, int), isMinus(String, String)

isMinus

@Deprecated
public static String isMinus(String thisVal,
                                        String addVal,
                                        int scale,
                                        int roundMode)
Deprecated. Use subtract Method.

뺄셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다.

Parameters:
thisVal - String
addVal - String
scale - int 자리수지정
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
결과 값
See Also:
isMinus(String, String, int), isMinus(String, String)

round

public static BigDecimal round(BigDecimal rounder,
                               int scale,
                               int roundMode)

숫자형 자료의 round 함수.

 BigDecimal rounder  = new BigDecimal(230045.456);
 int scale           = 2;
 int roundMode       = NumericHelper.ROUND_DOWN;
 BigDecimal result   = NumericHelper.round(rounder, scale, roundMode);
 
result"230045.45" 을 가지게 된다.

Parameters:
rounder - 대상 BigDecimal형 Data
scale - 자리 올림, 내림이나 반올림 할 자리수를 지정한다.
만약 양수일 경우에는 소수점 이하의 소수점 자리수를 지칭하며
음수일 경우에는 소수점 이상의 정수 자리수를 지침한다.
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
변환된 결과

round

public static double round(double rounder,
                           int scale,
                           int roundMode)

숫자형 자료의 round 함수.

 double rounder = 230045.456;
 int scale      = 2;
 int roundMode  = NumericHelper.ROUND_DOWN;
 double result  = NumericHelper.round(rounder, scale, roundMode);
 
result230045.45 을 가지게 된다.

Parameters:
rounder - 대상 double형 Data
scale - 자리 올림, 내림이나 반올림 할 자리수를 지정한다.
만약 양수일 경우에는 소수점 이하의 소수점 자리수를 지칭하며
음수일 경우에는 소수점 이상의 정수 자리수를 지침한다.
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
변환된 결과

round

public static String round(String rounder,
                           int scale,
                           int roundMode)

숫자형 자료의 round 함수.

 String rounder  = "230045.456";
 int scale       = 2;
 int roundMode   = NumericHelper.ROUND_DOWN;
 String result   = NumericHelper.round(rounder, scale, roundMode);
 
result"230045.45" 을 가지게 된다.

Parameters:
rounder - 대상 String형 Data
scale - 자리 올림, 내림이나 반올림 할 자리수를 지정한다.
만약 양수일 경우에는 소수점 이하의 소수점 자리수를 지칭하며
음수일 경우에는 소수점 이상의 정수 자리수를 지침한다.
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
변환된 결과

round

public static long round(long rounder,
                         int scale,
                         int roundMode)

숫자형 자료의 round 함수.

 long rounder  = 230045;
 int scale     = -1;
 int roundMode = NumericHelper.ROUND_DOWN;
 long result   = NumericHelper.round(rounder, scale, roundMode);
 
result230040 을 가지게 된다.

Parameters:
rounder - 대상 long형 Data
scale - 자리 올림, 내림이나 반올림 할 자리수를 지정한다.
만약 양수일 경우에는 소수점 이하의 소수점 자리수를 지칭하며
음수일 경우에는 소수점 이상의 정수 자리수를 지침한다.
※ 대상이 long형의 정수 부분이기 때문에 음수를 지정해야 한다.
roundMode - int Round 여부
올 림 : ROUND_UP
내 림 : ROUND_DOWN
반올림 : ROUND_HALF_UP
Returns:
변환된 결과

isNumeric

public static boolean isNumeric(String str)
숫자형 문자열인지 확인한다. Radix 및 Exponent 형태의 문자열은 지원하지 않는다.

Parameters:
str -
Returns:


Copyright © 2014. All Rights Reserved.