-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathMeta.java
More file actions
53 lines (49 loc) · 1.25 KB
/
Copy pathMeta.java
File metadata and controls
53 lines (49 loc) · 1.25 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
package javaforce;
import java.io.*;
import java.util.*;
/** MetaData.
*
* Provides extended meta data:
* - field order
* - method order
*
* @see javaforce.utils.GenMeta
*
* @author pquiring
*/
public class Meta {
public static Meta getMetaData(String className) {
String md = "/" + className.replace(".", "/") + ".md";
InputStream is = Meta.class.getResourceAsStream(md);
if (is == null) {
JFLog.log("Error:meta data not found:" + md);
return null;
}
Meta meta = new Meta();
ArrayList<String> fields = new ArrayList<>();
ArrayList<String> methods = new ArrayList<>();
ArrayList<String> section = null;
try {
String[] lns = new String(is.readAllBytes()).split("\n");
for(String ln : lns) {
if (ln.equals("[fields]")) {
section = fields;
continue;
}
if (ln.equals("[methods]")) {
section = methods;
continue;
}
if (section == null) continue;
section.add(ln);
}
meta.fields = fields.toArray(JF.StringArrayType);
meta.methods = methods.toArray(JF.StringArrayType);
} catch (Exception e) {
JFLog.log(e);
}
return meta;
}
public String[] fields;
public String[] methods;
}