|
@@ -344,6 +344,7 @@ public final class CommonUtils {
|
|
public static String toCHNum(int inputNum) {
|
|
public static String toCHNum(int inputNum) {
|
|
String resultNum = "";
|
|
String resultNum = "";
|
|
String numStr = String.valueOf(inputNum);
|
|
String numStr = String.valueOf(inputNum);
|
|
|
|
+
|
|
int len = numStr.length();
|
|
int len = numStr.length();
|
|
for (int i = 0; i < len; i++) {
|
|
for (int i = 0; i < len; i++) {
|
|
int tmpNum = numStr.charAt(i) - '0';
|
|
int tmpNum = numStr.charAt(i) - '0';
|
|
@@ -353,6 +354,7 @@ public final class CommonUtils {
|
|
resultNum += CN_SMALL_NUM[tmpNum];
|
|
resultNum += CN_SMALL_NUM[tmpNum];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
if (resultNum.contains("零")) {
|
|
if (resultNum.contains("零")) {
|
|
resultNum = resultNum.replaceAll("零{1,}", "零");
|
|
resultNum = resultNum.replaceAll("零{1,}", "零");
|
|
}
|
|
}
|
|
@@ -362,14 +364,16 @@ public final class CommonUtils {
|
|
if (resultNum.startsWith("一十")) {
|
|
if (resultNum.startsWith("一十")) {
|
|
resultNum = resultNum.replaceFirst("一十", "十");
|
|
resultNum = resultNum.replaceFirst("一十", "十");
|
|
}
|
|
}
|
|
|
|
+
|
|
while (StringUtils.countMatches(resultNum, "万") > 1) {
|
|
while (StringUtils.countMatches(resultNum, "万") > 1) {
|
|
resultNum = resultNum.replaceFirst("万", "");
|
|
resultNum = resultNum.replaceFirst("万", "");
|
|
}
|
|
}
|
|
|
|
+
|
|
while (StringUtils.countMatches(resultNum, "亿") > 1) {
|
|
while (StringUtils.countMatches(resultNum, "亿") > 1) {
|
|
resultNum = resultNum.replaceFirst("亿", "");
|
|
resultNum = resultNum.replaceFirst("亿", "");
|
|
}
|
|
}
|
|
- return resultNum;
|
|
|
|
|
|
|
|
|
|
+ return resultNum;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -459,18 +463,18 @@ public final class CommonUtils {
|
|
* @throws DocumentException
|
|
* @throws DocumentException
|
|
*/
|
|
*/
|
|
public static List<String> getAttrValueFromString(String htmlString, String flagName, String attrName) {
|
|
public static List<String> getAttrValueFromString(String htmlString, String flagName, String attrName) {
|
|
- List<String> idValues = new ArrayList<String>();
|
|
|
|
|
|
+ List<String> idValues = new ArrayList<>();
|
|
try {
|
|
try {
|
|
Document document = DocumentHelper.parseText(htmlString);
|
|
Document document = DocumentHelper.parseText(htmlString);
|
|
Element rootElement = document.getRootElement();
|
|
Element rootElement = document.getRootElement();
|
|
- List<Element> nodes = new ArrayList<Element>();
|
|
|
|
|
|
+ List<Element> nodes = new ArrayList<>();
|
|
if (flagName.equals(rootElement.getName())) {
|
|
if (flagName.equals(rootElement.getName())) {
|
|
nodes.add(rootElement);
|
|
nodes.add(rootElement);
|
|
} else {
|
|
} else {
|
|
nodes = rootElement.elements(flagName);
|
|
nodes = rootElement.elements(flagName);
|
|
}
|
|
}
|
|
for (Iterator<Element> itr = nodes.iterator(); itr.hasNext(); ) {
|
|
for (Iterator<Element> itr = nodes.iterator(); itr.hasNext(); ) {
|
|
- Element element = (Element) itr.next();
|
|
|
|
|
|
+ Element element = itr.next();
|
|
Attribute attr = element.attribute(attrName);
|
|
Attribute attr = element.attribute(attrName);
|
|
idValues.add(attr.getValue());
|
|
idValues.add(attr.getValue());
|
|
}
|
|
}
|
|
@@ -487,7 +491,7 @@ public final class CommonUtils {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public static List<String> getTagANames(String htmlString) {
|
|
public static List<String> getTagANames(String htmlString) {
|
|
- List<String> list = new ArrayList<String>();
|
|
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
Pattern p = Pattern.compile("<a[^<>]*\\s+id=\"([0-9A-Za-z-_.]+)\"\\s*");
|
|
Pattern p = Pattern.compile("<a[^<>]*\\s+id=\"([0-9A-Za-z-_.]+)\"\\s*");
|
|
Matcher m = p.matcher(htmlString);
|
|
Matcher m = p.matcher(htmlString);
|
|
while (m.find()) {
|
|
while (m.find()) {
|
|
@@ -504,7 +508,7 @@ public final class CommonUtils {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public static List<String> getTagANames2(String htmlString) {
|
|
public static List<String> getTagANames2(String htmlString) {
|
|
- List<String> list = new ArrayList<String>();
|
|
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
Pattern p = Pattern.compile("<a[^<>]*\\s+name=\"([0-9A-Za-z-_.]+)\"\\s*");
|
|
Pattern p = Pattern.compile("<a[^<>]*\\s+name=\"([0-9A-Za-z-_.]+)\"\\s*");
|
|
Matcher m = p.matcher(htmlString);
|
|
Matcher m = p.matcher(htmlString);
|
|
while (m.find()) {
|
|
while (m.find()) {
|