田源
2025-01-16 39269c81905457378a73dc83050349d7a364a1f8
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
package com.vci.client.common.datatype;
 
import com.vci.client.common.providers.ServiceProvider;
import com.vci.common.log.ServerWithLog4j;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.atm.AttribItem;
import com.vci.omd.constants.AttributeConstants;
import com.vci.omd.dataType.VTDataType;
 
public class VTString extends VTDataType{
    //长度
    private int length;
    public static int lenInMode;
    public static int lenDefault;
    public static int lenMax;
    private String value;
    
    public String getValue(){
        return this.value;
    }
    
    public VTString(String value){
        this.value = value;
    }
    
    /**
     * 检查value是否符合 属性abName的值域
     * @param abName
     * @return
     */
    public boolean checkRageValueByAbName(String abName){
        AttribItem ab = null;
        try {
            ab = ServiceProvider.getOMDService().getAttributeService().getAttribItemByName(abName);
        } catch (VCIError e) {
            //e.printStackTrace();
            ServerWithLog4j.logger.error(e);
        }
        if(ab == null){
            return false;
        }
        String rage = ab.rage;
        return checkRageValueByRage(rage);
    }
    
    /**
     * 检查value是否符合 rage
     * @param rage
     * @return
     */
    public boolean checkRageValueByRage(String rage){
        if(rage == null || rage.equals("")){
            return true;
        }
        String[] rages = rage.split(";");
        boolean rageFlag = false;
        for(int i = 0; i < rages.length; i++){
            if(rages[i].equals(this.value)){
                rageFlag = true;
                break;
            }
        }
        return rageFlag;
    }
    
    /**
     * 检查value是否超过了 属性abName的最大长度
     * @return
     */
    public boolean beyondMaxLength(String abName){
        AttribItem ab = null;
        try {
            ab = ServiceProvider.getOMDService().getAttributeService().getAttribItemByName(abName);
        } catch (VCIError e) {
            //e.printStackTrace();
            ServerWithLog4j.logger.error(e);
        }
        if(ab == null){
            return false;
        }
        
        String other = ab.other;
        int maxLength = Integer.valueOf(AttributeConstants.getOtherValueByType(other, AttributeConstants.LENGTH));
        int length = this.value.length();
        if(length > maxLength){
            return true;
        }
        return false;
    }
}