P15GEN2\59518
2024-05-29 d4210c7c4b04abde20037ea8aa0f54ef8a2649aa
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
package foundation.json.tree;
 
import foundation.json.JType;
 
public class JBandItem {
 
    private String fullName;
    private String objectName;
    private String propertyName;
    private String[] segments;
    private Object value;
    
    
    public JBandItem(String fullName, Object value) {
        this.fullName = fullName;
        this.value = value;
        
        parse(fullName);
    }
 
    private void parse(String fullName) {
        //1. 默认深度不超过3的主从结构, org_account.shipment[0].code;
        if (fullName == null) {
            return;
        }
        
        //2. 根据.进行分割
        fullName = fullName.trim();
        segments = fullName.split("\\.");
        
        propertyName = segments[segments.length - 1];
        objectName = segments[segments.length - 2];
        
        //3. Array检查
        int max = segments.length;
        for (int i = max - 2; i >= 0; i--) {
            String segment = segments[i];
            
            int begin = segment.lastIndexOf("[");
            
            if (begin >= 0) {
                int end = segment.indexOf("]", begin);
                
                if (end >= 0) {
//                    String idx = segment.substring(begin + 1, end);
//                    arrayIndex = Integer.parseInt(idx);
//                    type = JType.Array;
                }
            }
        }
    }
 
    public String getFullName() {
        return fullName;
    }
 
    public String getObjectName() {
        return objectName;
    }
    
    public String getPropertyName() {
        return propertyName;
    }
    
    public Object getValue() {
        return value;
    }
 
    public String[] getSegments() {
        return segments;
    }
 
    public JType getType(int idx) {
        int max = segments.length;
        
        if (idx >= max) {
            return JType.Unknown;
        }
        
        if (idx == (max - 1)) {
            return null;//JType.Value;
        }
        
        String segment = segments[idx];
        JType type = segment.endsWith("[]") ? JType.Array : JType.Object;
        return type;
    }
 
    public String getName(int itemLevel) {
        // TODO Auto-generated method stub
        return null;
    }
}