教育训练处考试制证系统后端
“djh”
2025-02-18 3bf782ceb9411b81e5c03cadb73751f429e4051a
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
207
208
209
210
211
212
213
214
215
216
217
218
/*     */
package com.gkhy.exam.pay.utils.config;
/*     */
/*     */
 
//import com.xjhys.edu.fee.sdk.annotation.PropertiesConfig;
 
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Properties;
 
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */ public class PropertiesUtil
        /*     */ {
    /*     */   public static final String PROPERTIES_SUFFIX_NAME = "properties";
    /*     */   public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    /*     */   public static final String RESOURCES_PATH = "/";
    /*     */   public static final String INT_NAME = "int";
    /*     */   public static final String DOUBLE_NAME = "double";
    /*     */   public static final String FLOAT_NAME = "float";
    /*     */   public static final String LONG_NAME = "long";
    /*     */   public static final String METHOD_SET = "set";
 
    /*     */
    /*     */
    public static Properties loadPropertiesFile(InputStream in) throws IOException {
        /*  43 */
        Properties p = new Properties();
        /*  44 */
        p.load(in);
        /*  45 */
        return p;
        /*     */
    }
 
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    public static void loadData(Object propertiesBean) throws IOException {
        /*  56 */
        if (propertiesBean == null) {
            /*     */
            return;
            /*     */
        }
        /*  59 */
        PropertiesConfig pc = propertiesBean.getClass().<PropertiesConfig>getAnnotation(PropertiesConfig.class);
        /*  60 */
        String fileNmae = pc.fileName();
        /*  61 */
        loadData(fileNmae, propertiesBean);
        /*     */
    }
 
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    public static void loadData(String fileNmae, Object propertiesBean) throws IOException {
        /*  75 */
        if (propertiesBean == null) {
            /*     */
            return;
            /*     */
        }
        /*  78 */
        URL url = PropertiesUtil.class.getResource("/" + fileNmae);
        /*  79 */
        InputStream openStream = url.openStream();
        /*  80 */
        Properties p = loadPropertiesFile(openStream);
        /*  81 */
        Field[] fs = propertiesBean.getClass().getDeclaredFields();
        /*  82 */
        for (int i = 0; i < fs.length; i++) {
            /*  83 */
            Field field = fs[i];
            /*  84 */
            PropertiesConfig pc = field.<PropertiesConfig>getAnnotation(PropertiesConfig.class);
            /*  85 */
            String pKey = field.getName();
            /*  86 */
            String value = null;
            /*  87 */
            if (pc != null) {
                /*  88 */
                value = p.getProperty(pc.name());
                /*     */
            } else {
                /*  90 */
                value = p.getProperty(pKey);
                /*     */
            }
            /*  92 */
            if (value != null) {
                /*  93 */
                field.setAccessible(true);
                /*     */
                try {
                    /*  95 */
                    field.set(propertiesBean, conversion(value, field.getType()));
                    /*  96 */
                } catch (IllegalArgumentException e) {
                    /*     */
                    /*  98 */
                    e.printStackTrace();
                    /*  99 */
                } catch (IllegalAccessException e) {
                    /*     */
                    /* 101 */
                    e.printStackTrace();
                    /*     */
                }
                /*     */
            }
            /*     */
        }
        /*     */
    }
 
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    public static Object conversion(String value, Class<?> type) {
        /* 118 */
        if (value == null) {
            /* 119 */
            return null;
            /*     */
        }
        /* 121 */
        if ("int".equals(type.getName()) || type.getName().equals(Integer.class.getName()))
            /* 122 */ return Integer.valueOf(value);
        /* 123 */
        if ("double".equals(type.getName()) || type.getName().equals(Double.class.getName()))
            /* 124 */ return Double.valueOf(value);
        /* 125 */
        if ("float".equals(type.getName()) || type.getName().equals(Float.class.getName()))
            /* 126 */ return Float.valueOf(value);
        /* 127 */
        if ("long".equals(type.getName()) || type.getName().equals(Long.class.getName()))
            /* 128 */ return Long.valueOf(value);
        /* 129 */
        if (type.getName().equals(Date.class.getName())) {
            /* 130 */
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            /*     */
            try {
                /* 132 */
                return format.parse(value);
                /* 133 */
            } catch (ParseException e) {
                /*     */
                /* 135 */
                e.printStackTrace();
                /*     */
            }
            /*     */
        }
        /*     */
        /* 139 */
        return value;
        /*     */
    }
    /*     */
}
 
 
/* Location:              D:\jar\sign_util-1.0-SNAPSHOT.20240227.jar!\BOOT-INF\lib\SNAPSHOT-1.0.0.jar!\com\xjhys\edu\fee\sd\\utils\PropertiesUtil.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */