• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jiangxincode / ApkToolBoxGUI / #1173

06 Sep 2025 02:38PM UTC coverage: 2.892% (+0.001%) from 2.891%
#1173

push

jiangxincode
[PMD issues]Fix PMD issues: CollapsibleIfStatements

0 of 8 new or added lines in 1 file covered. (0.0%)

248 of 8574 relevant lines covered (2.89%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/edu/jiangxin/apktoolbox/file/zhconvert/ZHConverterUtils.java
1
package edu.jiangxin.apktoolbox.file.zhconvert;
2

3
import org.apache.logging.log4j.LogManager;
4
import org.apache.logging.log4j.Logger;
5

6
import java.io.*;
7
import java.util.Iterator;
8
import java.util.Properties;
9

10
public class ZHConverterUtils {
11
    private static final Logger logger = LogManager.getLogger(ZHConverterUtils.class.getSimpleName());
×
12

13
    private Properties charMap = new Properties();
×
14

15
    private Properties charMap2 = new Properties();
×
16

17
    public ZHConverterUtils() {
×
18
        String dirpath = "zhSimple2zhTw.properties";
×
19
        String dirpath2 = "zhTw2zhSimple.properties";
×
20
        initProperties(dirpath,charMap);
×
21
        initProperties(dirpath2,charMap2);
×
22
    }
×
23

24
    private void initProperties(String rPath, Properties properties) {
25
        File file = new File(rPath);
×
26
        if (!file.exists()) {
×
27
            try {
28
                file.createNewFile();
×
29
            } catch (IOException e) {
×
30
                logger.error("createNewFile failed: " + e.getMessage());
×
31
                return;
×
32
            }
×
33
        }
34

35
        try (InputStream is = new FileInputStream(file);
×
36
             BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
×
37
            properties.load(reader);
×
38
        } catch (IOException e) {
×
39
            logger.error("load failed: " + e.getMessage());
×
40
        }
×
41
    }
×
42

43

44
    /**
45
     *
46
     * @param str
47
     * @return
48
     */
49
    public String myConvertToTW(String str){
NEW
50
        for (Object o : charMap.keySet()) {
×
NEW
51
            String key = (String) o;
×
NEW
52
            if (!key.isEmpty() && str.contains(key)) {
×
NEW
53
                str = str.replaceAll(key, charMap.getProperty(key));
×
54
            }
55
        }
×
56
        return str;
×
57
    }
58

59
    /**
60
     *
61
     * @param str
62
     * @return
63
     */
64
    public String myConvertToSimple(String str){
NEW
65
        for (Object o : charMap2.keySet()) {
×
NEW
66
            String key = (String) o;
×
NEW
67
            if (!key.isEmpty() && str.contains(key)) {
×
NEW
68
                str = str.replaceAll(key, charMap2.getProperty(key));
×
69
            }
70
        }
×
71
        return str;
×
72
    }
73

74

75
    /**
76
     * 加入新词组对应
77
     * @param key
78
     * @param value
79
     */
80
    public void storeDataToProperties(String key,String value) {
81
        charMap.setProperty(key,value);
×
82
        String filePath = "zhSimple2zhTw.properties";
×
83
        try (OutputStream out = new FileOutputStream(filePath)) {
×
84
            charMap.store(out, "加入新元素");
×
85
        } catch (IOException e) {
×
86
            logger.error("storeDataToProperties failed: IOException");
×
87
        }
×
88
        charMap2.setProperty(value,key);
×
89
        String filePath2 = "zhTw2zhSimple.properties";
×
90
        try (OutputStream out2 = new FileOutputStream(filePath2)) {
×
91
            charMap2.store(out2, "加入新元素");
×
92
        } catch (IOException e) {
×
93
            logger.error("storeDataToProperties failed: IOException");
×
94
        }
×
95
    }
×
96

97
    public Properties getCharMap() {
98
        return charMap;
×
99
    }
100

101

102

103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc