hefeixia
2021-02-18 5b8c95c760840f09910730943b21391e47187315
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
package frame.object.reader;
 
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
 
import org.apache.log4j.Logger;
 
public abstract class EntityReader implements IEntityReader {
 
    protected static Logger logger;
    protected static Set<String> excludeMethods;
    protected Class<?> clazz;
 
    static {
        logger = Logger.getLogger(ObjectReader.class);
        createExcludeMethodSet();
    }
 
    protected EntityReader(Class<?> clazz) {
        this.clazz = clazz;
    }
 
    public static IEntityReader getInstance(Class<?> clazz) throws Exception {
 
        if (Collection.class.isAssignableFrom(clazz)) {
            return new CollectionReader(clazz);
        } 
        else if (Map.class.isAssignableFrom(clazz)) {
            return new MapReader(clazz);
        } 
        else {
            return new ObjectReader(clazz);
        }
    }
 
    protected abstract void initValueReader(Class<?> dataType) throws Exception;
 
    public abstract String getString(Object entity);
 
    public abstract String getJSONString(Object entity) throws Exception;
 
    public Class<?> getEntityClass() {
        return clazz;
    }
 
    private static void createExcludeMethodSet() {
        excludeMethods = new HashSet<String>();
        excludeMethods.add("getclass");
        excludeMethods.add("getnames");
        excludeMethods.add("getsize");
        excludeMethods.add("containsproperty");
        excludeMethods.add("loaddata");
        excludeMethods.add("setdata");
        excludeMethods.add("setdataString");
        excludeMethods.add("getdata");
        excludeMethods.add("getString");
        excludeMethods.add("getjsonString");
        excludeMethods.add("getsqlString");
        excludeMethods.add("getvalue");
        excludeMethods.add("getdynamicdata");
        excludeMethods.add("iterator");
        excludeMethods.add("toString");
        excludeMethods.add("finalize");
        excludeMethods.add("wait");
        excludeMethods.add("hashcode");
        excludeMethods.add("clone");
        excludeMethods.add("registernatives");
        excludeMethods.add("equals");
        excludeMethods.add("notify");
        excludeMethods.add("notifyall");
        excludeMethods.add("getinstance");
    }
 
}