ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package com.vci.server.bof.utils;
 
public class RevisionComputer {
    
    public static void main(String[] args) {
        RevisionComputer a = new RevisionComputer();
        String start = "Zz";
        String jump = "DO5";
        for (int i = 0; i < 30; i++) {
            start = a.computerNextRevision(start, jump);
            //System.out.println(start);
        }
    }
 
    /**
     * 计划小写字符的下一个值
     * @param startVal
     * @return
     */
    public String cumputeLowChar(String startVal) {
        
        char[] chars = startVal.toCharArray();
        boolean isCarry = false;
        for (int i = chars.length - 1; i  >= 0; i--) {
            if (chars[i] == 'z') {
                chars[i] = 'a';
                isCarry = true;
            } else {
                chars[i] = (char) (chars[i] + 1);
                isCarry = false;
                break;
            }
        }
        String rsValue = "";
        for (int i = 0; i < chars.length; i++) {
            if (isCarry) {
                rsValue = "a";
                isCarry = false;
            }
            rsValue += chars[i];
        }
        return rsValue;
    }
    
    /**
     * 计算大写字符下一个值
     * @param startVal
     * @return
     */
    public String computeUpperChar(String startVal) {
        char[] chars = startVal.toCharArray();
        boolean isCarry = false;
        for (int i = chars.length - 1; i  >= 0; i--) {
            if (chars[i] == 'Z') {
                chars[i] = 'A';
                isCarry = true;
            } else {
                chars[i] = (char) (chars[i] + 1);
                isCarry = false;
                break;
            }
        }
        String rsValue = "";
        for (int i = 0; i < chars.length; i++) {
            if (isCarry) {
                rsValue = "A";
                isCarry = false;
            }
            rsValue += chars[i];
        }
        return rsValue;
    }
    
    /**
     * 计算数字的下一个值
     * @param number
     * @return
     */
    public String computerNumber(String number, String jumpCharacter) {
        int currentNum = Integer.valueOf(number).intValue();
        return String.valueOf(currentNum + 1);
    }
    
    public String computerComplexVal(String currentVal, String jumpCharacter) {
        char[] chars = currentVal.toCharArray();
        boolean isCarry = false;
        String prefix = "";
        if (isNumber(currentVal)) {
            prefix = "1";
        } else if (isUpperChar(currentVal)) {
            prefix = "A";
        } else if (isLowerChar(currentVal)) {
            prefix = "a";
        }
        for (int i = chars.length - 1; i  >= 0; i--) {
            do {
            if (isNumber(String.valueOf(chars[i]))) {
                if (chars[i] == '9') {
                    chars[i] = '0';
                    isCarry = true;
                } else {
                    chars[i] = (char) (chars[i] + 1);
                    isCarry = false;
                }
            } else if (isUpperChar(String.valueOf(chars[i]))) {
                if (chars[i] == 'Z') {
                    chars[i] = 'A';
                    isCarry = true;
                } else {
                    chars[i] = (char) (chars[i] + 1);
                    isCarry = false;
                }
            } else if (isLowerChar(String.valueOf(chars[i]))) {
                if (chars[i] == 'z') {
                    chars[i] = 'a';
                    isCarry = true;
                } else {
                    chars[i] = (char) (chars[i] + 1);
                    isCarry = false;
                }
            } }
            while (jumpCharacter.indexOf(String.valueOf(chars[i])) >= 0);
            if (!isCarry) {
                break;
            }
        }
        if (isCarry && prefix.trim().equals("")) {
            return currentVal;
        }
        String rsValue = "";
        for (int i = 0; i < chars.length; i++) {
            rsValue += chars[i];
        }
        if (isCarry) {
            rsValue = prefix + rsValue;
        }
        
        return rsValue;
    }
    
    /**
     * 计算复杂字符串的下一个值
     * @param currentVal
     * @return
     */
    public String computerNextRevision(String currentVal, String jumpCharacter) {
        String nextVal = currentVal;
        if (!isNumberAndChar(currentVal)) {
            return nextVal;
        }
        
        return computerComplexVal(currentVal, jumpCharacter);
    }
    
    /**
     * 判读传入的字符串是否有数字和字母组成
     * @param value
     * @return
     */
    public boolean isNumberAndChar(String value) {
        String regex = "[0-9A-Za-z]+";
        if (value.matches(regex)) {
            return true;
        }
        return false;
    }
    
    /**
     * 判断传递字符串是否为数字
     * @param revisionVal
     * @return
     */
    public boolean isNumber(String value) {
        String regex = "[0-9]+";
        if (value.matches(regex)) {
            return true;
        }
        return false;
    }
    
    /**
     * 判断传入字符是否是大写字符组成的字符串
     * @param revisionVal
     * @return
     */
    public boolean isUpperChar(String value) {
        String regex = "[A-Z]+";
        if (value.matches(regex)) {
            return true;
        }
        return false;
    }
    
    /**
     * 判断传入的字符串是否为小写字符组成的字符串
     * @param revisionVal
     * @return
     */
    public boolean isLowerChar(String value) {
        String regex = "[a-z]+";
        if (value.matches(regex)) {
            return true;
        }
        return false;
    }
}