ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
package com.vci.omd.objects;
 
public class OtherInfo {
    
    private int length = 0;
    private boolean allowNull = false;
    private int accuracy = 0;
    private String enumName = "";
    
    /**
     * -1: 非参照
     * 0: 参照业务类型
     * 1: 参照链接类型
     */
    private int refFlag = -1;
    private String refTypeName = "";
    /**
     * 1:当前版本当前版次
     * 3:最新版本最新版次
     */
    private int version = 1;
    public int getLength() {
        return length;
    }
    public void setLength(int length) {
        this.length = length;
    }
    public boolean isAllowNull() {
        return allowNull;
    }
    public void setAllowNull(boolean allowNull) {
        this.allowNull = allowNull;
    }
    public int getAccuracy() {
        return accuracy;
    }
    public void setAccuracy(int accuracy) {
        this.accuracy = accuracy;
    }
    public String getEnumName() {
        return enumName;
    }
    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }
    
    /**
     * -1: 非参照
     * 0: 参照业务类型
     * 1: 参照链接类型
     */
    public int getRefFlag() {
        return refFlag;
    }
    public void setRefFlag(int refFlag) {
        this.refFlag = refFlag;
    }
    public String getRefTypeName() {
        return refTypeName;
    }
    public void setRefTypeName(String refTypeName) {
        this.refTypeName = refTypeName;
    }
    public int getVersion() {
        return version;
    }
    public void setVersion(int version) {
        this.version = version;
    }
    
    private static final String LENGTH = "length";
    private static final String ALLOWNULL = "allowNull";
//    private static final String ISFIXLEN = "isFixLen";
//    private static final String OTHER = "other";
    private static final String ACCURACY = "accuracy";
    private static final String BTM = "btm";
    private static final String ENUMNAME = "enumName";
    private static final String LINKTYPENAME = "linkTypeName";
    private static final String VERSION = "version";
    
    /**
     * 获取other中指定项目的值
     * @return
     */
    private static String getOtherValueByType(String other, String type){
        String[] otherArray = other.split(";");
        for(int i = 0; i < otherArray.length; i++){
            String otherValue = otherArray[i];
            if(otherValue.contains(type)){
                return otherValue.substring(otherValue.indexOf("=") + 2, otherValue.length());
            }
        }
        return null;
        
    }
    
    /**
     * 将属性的other信息封装成OtherInfo对象 
     * @param text
     * @return
     */
    public static OtherInfo getOtherInfoByText(String text){
        OtherInfo obj = new OtherInfo();
        String value = getOtherValueByType(text, ACCURACY);
        if(value != null && !value.equals("")){
            obj.setAccuracy(Integer.valueOf(value));
        }
        value = getOtherValueByType(text, ALLOWNULL);
        if(value != null && !value.equals("")){
            if(value.equals("yes")){
                obj.setAllowNull(true);
            }else if(value.equals("no")){
                obj.setAllowNull(false);
            }
        }
        value = getOtherValueByType(text, BTM);
        if(value != null && !value.equals("")){
            obj.setRefFlag(0);
            obj.setRefTypeName(String.valueOf(value));
        }
        value = getOtherValueByType(text, LINKTYPENAME);
        if(value != null && !value.equals("")){
            obj.setRefFlag(1);
            obj.setRefTypeName(String.valueOf(value));
            value = getOtherValueByType(text, VERSION);
            if(value != null && !value.equals("")){
                obj.setVersion(Integer.valueOf(value));
            }
        }
        value = getOtherValueByType(text, ENUMNAME);
        if(value != null && !value.equals("")){
            obj.setEnumName(value);
        }
        value = getOtherValueByType(text, LENGTH);
        if(value != null && !value.equals("")){
            obj.setLength(Integer.valueOf(value));
        }
        return obj;
    }
}