MsgFormatPos.java
3.51 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.ut;
import com.adobe.xfa.ut.MsgFormat;
import java.util.ArrayList;
import java.util.List;
public final class MsgFormatPos {
private boolean mbResolved;
private int mnResId;
private MsgFormat moFmt;
private final List<Integer> moParmPosns = new ArrayList<Integer>();
private final List<String> moParms = new ArrayList<String>();
protected MsgFormatPos() {
}
public MsgFormatPos(MsgFormatPos oSource) {
this.moFmt = new MsgFormat(oSource.moFmt);
this.assign(oSource);
}
public MsgFormatPos(int nResId) {
this.moFmt = new MsgFormat(nResId);
this.mnResId = nResId;
this.init();
}
public MsgFormatPos(int nResId, String sOut) {
this.mnResId = nResId;
this.moFmt = new MsgFormat(this.mnResId);
this.init();
this.format(sOut);
}
public MsgFormatPos(String sSource) {
this.moFmt = new MsgFormat(sSource);
this.init();
}
public MsgFormatPos(String sSource, String sOut) {
this.moFmt = new MsgFormat(sSource, sOut);
this.init();
this.format(sOut);
}
public MsgFormatPos assign(MsgFormatPos oSource) {
this.moFmt = oSource.moFmt;
this.mbResolved = oSource.mbResolved;
this.moParmPosns.addAll(oSource.moParmPosns);
this.moParms.addAll(oSource.moParms);
this.mnResId = oSource.mnResId;
return this;
}
public MsgFormatPos format(int nResId) {
return this.format(new MsgFormat(nResId).toString());
}
public MsgFormatPos format(String sOut) {
this.mbResolved = false;
this.moParms.add(sOut);
return this;
}
public String getParm(int nIndex) {
this.resolve();
return this.moFmt.getParm(nIndex);
}
public int getParmCount() {
this.resolve();
return this.moFmt.getParmCount();
}
void init() {
this.mbResolved = false;
StringBuilder sSrc = new StringBuilder(this.moFmt.sourceString());
int nLen = sSrc.length();
for (int i = 0; i < nLen; ++i) {
if (sSrc.charAt(i) != '%' || i >= nLen) continue;
if ('0' <= sSrc.charAt(++i) && sSrc.charAt(i) <= '9') {
this.moParmPosns.add(sSrc.charAt(i) - 48);
sSrc.setCharAt(i, 's');
continue;
}
if (sSrc.charAt(i) != 's') continue;
int nPos = this.moParmPosns.size();
this.moParmPosns.add(nPos);
sSrc.setCharAt(i, 's');
}
this.moFmt = new MsgFormat(sSrc.toString());
}
public int resId() {
return this.mnResId;
}
private void resolve() {
int n;
int i;
this.mbResolved = true;
int nParms = this.moParms.size();
int nSize = this.moParmPosns.size();
if (nSize == 0 || nParms == 0) {
return;
}
int nMin = this.moParmPosns.get(0);
for (i = 1; i < nSize; ++i) {
if (this.moParmPosns.get(i) >= nMin) continue;
nMin = this.moParmPosns.get(i);
}
for (i = 0; i < nSize && (n = this.moParmPosns.get(i) - nMin) < nParms; ++i) {
this.moFmt.format(this.moParms.get(n));
}
while (i < nSize) {
this.moFmt.format("");
++i;
}
this.moParms.clear();
this.moParmPosns.clear();
}
public String toString() {
this.resolve();
return this.moFmt.toString();
}
}