MsgFormat.java
4.01 KB
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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.ut;
import com.adobe.xfa.ut.ResourceLoader;
import com.adobe.xfa.ut.StringUtils;
import java.util.ArrayList;
import java.util.List;
public class MsgFormat {
private int mnResId;
private int mnSourceIndex;
private final List<String> moParms = new ArrayList<String>();
private StringBuilder msResult = new StringBuilder();
private String msSource;
protected MsgFormat() {
}
public MsgFormat(MsgFormat oSource) {
this.assign(oSource);
}
public MsgFormat(int nResId) {
this.initialize(nResId);
}
public MsgFormat(int nResId, String sOut) {
this.initialize(nResId);
this.format(sOut);
}
public MsgFormat(String sSource) {
this.initialize(sSource);
}
public MsgFormat(String sSource, String sOut) {
this.initialize(sSource);
this.format(sOut);
}
private void append(char cappend) {
this.msResult.append(cappend);
}
private void append(String sAppend) {
this.msResult.append(sAppend);
this.moParms.add(sAppend);
}
public MsgFormat assign(MsgFormat oSource) {
if (this == oSource) {
return this;
}
this.mnResId = oSource.mnResId;
this.msSource = oSource.msSource;
this.msResult = oSource.msResult;
this.moParms.addAll(oSource.moParms);
this.mnSourceIndex = oSource.mnSourceIndex;
return this;
}
private void findNextformat() {
if (StringUtils.isEmpty(this.msResult)) {
this.msResult.ensureCapacity(this.msSource.length());
}
while (this.mnSourceIndex < this.msSource.length()) {
if (this.msSource.charAt(this.mnSourceIndex) == '%') {
++this.mnSourceIndex;
if (this.mnSourceIndex < this.msSource.length() && this.msSource.charAt(this.mnSourceIndex) != '%') break;
}
this.append(this.msSource.charAt(this.mnSourceIndex));
++this.mnSourceIndex;
}
}
public MsgFormat format(String sOut) {
String sformat = this.loadformat();
this.formatString(sformat, sOut);
this.findNextformat();
return this;
}
private void formatString(String sformat, String sOut) {
this.append(sOut);
}
public String getParm(int nIndex) {
return nIndex > this.moParms.size() ? "" : this.moParms.get(nIndex);
}
public int getParmCount() {
return this.moParms.size();
}
private void initialize(int nResId) {
this.mnResId = nResId;
this.msSource = ResourceLoader.loadResource(nResId);
this.mnSourceIndex = 0;
this.findNextformat();
}
private void initialize(String sSource) {
this.mnResId = 0;
this.msSource = sSource;
this.mnSourceIndex = 0;
this.findNextformat();
}
private String loadformat() {
int nStart = this.mnSourceIndex;
boolean bDotFound = false;
boolean bSkipL = false;
String sformat = "%";
while (this.mnSourceIndex < this.msSource.length()) {
char cNext = this.msSource.charAt(this.mnSourceIndex);
if (cNext == '.') {
if (bDotFound) {
break;
}
} else {
if (cNext == 'l') {
bSkipL = true;
break;
}
if (cNext < '0' || cNext > '9') break;
}
++this.mnSourceIndex;
}
sformat = sformat + this.msSource.substring(nStart, this.mnSourceIndex);
if (bSkipL) {
++this.mnSourceIndex;
}
if (this.mnSourceIndex < this.msSource.length()) {
++this.mnSourceIndex;
}
return sformat;
}
public int resId() {
return this.mnResId;
}
public String sourceString() {
return this.msSource;
}
public String toString() {
return this.msResult.toString();
}
}