You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
855 B
32 lines
855 B
package org.leolo.nrdatad.util; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
import org.apache.logging.log4j.Logger; |
|
|
|
public class JSONUtil { |
|
|
|
static Logger log = LogManager.getLogger(); |
|
|
|
public static int parseInt(String val){ |
|
//Throw exception for empty string, or just a plus sign to maintenance backward |
|
//compatibility with previous version. |
|
if(val.length()==0 || "+".equals(val)){ |
|
throw new NumberFormatException(); |
|
} |
|
if (val.startsWith("+")) { |
|
return _parseInt(val.substring(1)); |
|
} |
|
return _parseInt(val); |
|
} |
|
|
|
private static int _parseInt(String val) { |
|
if(val.length()==0){ |
|
return 0; |
|
} |
|
if (val.startsWith("0")) { |
|
return _parseInt(val.substring(1)); |
|
} |
|
return Integer.parseInt(val); |
|
} |
|
|
|
}
|
|
|