@@ -33,18 +33,11 @@ public static BigDecimal parse(String valueStr) {
33
33
}
34
34
35
35
public static BigDecimal parse (char [] chars , int off , int len ) {
36
- if (off > 0 || len != chars .length ) {
37
- chars = Arrays .copyOfRange (chars , off , off +len );
38
- }
39
- return parse (chars );
40
- }
41
-
42
- public static BigDecimal parse (char [] chars ) {
43
- final int len = chars .length ;
44
36
try {
45
37
if (len < 500 ) {
46
- return new BigDecimal (chars );
38
+ return new BigDecimal (chars , off , len );
47
39
}
40
+ chars = Arrays .copyOfRange (chars , off , off +len );
48
41
return new BigDecimalParser (chars ).parseBigDecimal (len / 10 );
49
42
} catch (NumberFormatException e ) {
50
43
String desc = e .getMessage ();
@@ -53,17 +46,21 @@ public static BigDecimal parse(char[] chars) {
53
46
desc = "Not a valid number representation" ;
54
47
}
55
48
String stringToReport ;
56
- if (chars . length <= MAX_CHARS_TO_REPORT ) {
57
- stringToReport = new String (chars );
49
+ if (len <= MAX_CHARS_TO_REPORT ) {
50
+ stringToReport = new String (chars , off , len );
58
51
} else {
59
- stringToReport = new String (Arrays .copyOfRange (chars , 0 , MAX_CHARS_TO_REPORT ))
52
+ stringToReport = new String (Arrays .copyOfRange (chars , off , MAX_CHARS_TO_REPORT ))
60
53
+ "(truncated, full length is " + chars .length + " chars)" ;
61
54
}
62
55
throw new NumberFormatException ("Value \" " + stringToReport
63
56
+ "\" can not be represented as `java.math.BigDecimal`, reason: " + desc );
64
57
}
65
58
}
66
59
60
+ public static BigDecimal parse (char [] chars ) {
61
+ return parse (chars , 0 , chars .length );
62
+ }
63
+
67
64
private BigDecimal parseBigDecimal (final int splitLen ) {
68
65
boolean numHasSign = false ;
69
66
boolean expHasSign = false ;
0 commit comments