ResourceLoader.java
3.36 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.ut;
import com.adobe.xfa.ut.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.Properties;
public class ResourceLoader {
private static final String gXFAResources = "com.adobe.xfa.messages_";
private static final Properties mMessageStrings;
private static final Properties mXFAProperties;
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Loose catch block
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
* Lifted jumps to return sites
*/
private static Properties load(String sFile) {
InputStream is = ResourceLoader.class.getResourceAsStream("/" + sFile);
if (is == null) return null;
Properties properties = new Properties();
properties.load(is);
Properties properties2 = properties;
try {
is.close();
return properties2;
}
catch (IOException ignored) {
// empty catch block
}
return properties2;
catch (IOException ex) {
try {
is.close();
return null;
}
catch (IOException ignored) {
return null;
}
catch (Throwable throwable) {
try {
is.close();
throw throwable;
}
catch (IOException ignored) {
// empty catch block
}
throw throwable;
}
}
}
public static String loadResource(int nResId) {
if (mMessageStrings != null) {
String sResource = mMessageStrings.getProperty("IDS_XTG_" + Integer.toString(nResId));
if (sResource == null) {
sResource = "%s";
}
return sResource;
}
return "Can't locate resource IDS_XTG_" + Integer.toString(nResId);
}
public static String loadProperty(String property) {
String propertyValue = null;
if (mXFAProperties != null) {
propertyValue = mXFAProperties.getProperty(property);
}
if (propertyValue == null) {
propertyValue = System.getProperty(property);
}
if (propertyValue == null) {
propertyValue = "";
}
return propertyValue;
}
static {
String lang = Locale.getDefault().toString();
if (StringUtils.isEmpty(lang)) {
lang = "en";
}
String resFile = "com.adobe.xfa.messages_" + lang + ".properties";
Properties messageStrings = ResourceLoader.load(resFile);
String deflt = Locale.getDefault().getLanguage();
if (messageStrings == null && !deflt.equals(lang)) {
lang = deflt;
resFile = "com.adobe.xfa.messages_" + lang + ".properties";
messageStrings = ResourceLoader.load(resFile);
}
if (messageStrings == null && !lang.equals("en")) {
messageStrings = ResourceLoader.load("com.adobe.xfa.messages_en.properties");
}
mMessageStrings = messageStrings;
String propFile = "com.adobe.xfa.environment.properties";
mXFAProperties = ResourceLoader.load(propFile);
}
}