田源
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
91
92
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.dataType.VTDataType;
 
public class VTLong extends VTDataType{
    private long value;
    
    public long getValue(){
        return this.value;
    }
    
    public VTLong(long value){
        this.value = value;
    }
    
    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);
    }
    
    public boolean checkRageValueByRage(String rage){
        if(rage == null || rage.equals("")){
            return true;
        }
        boolean rageFlag = false;
        String[] rages = rage.split(";");
        //当该值等于 用!= 所限制的值时,不满足值域
        for(int i = 0; i < rages.length; i++){
            String rage_ = rages[i];
            if(rage_.contains("!=")){
                long rageUne = Long.valueOf(rage_.substring(rage_.indexOf("=") + 1));
                if(rageUne == this.value){
                    return false;
                }
            }
        }
        //当满足!= 以外的任一条件时,既满足值域
        for(int i = 0; i < rages.length; i++){
            String rage_ = rages[i];
            if(rage_.contains("=")){
                long rageUne = Long.valueOf(rage_.substring(rage_.indexOf("=") + 1));
                if(rageUne == this.value){
                    rageFlag = true;
                    break;
                }
            }
            if(rage_.contains(">") && !rage_.contains(">=")){
                long rageUne = Long.valueOf(rage_.substring(rage_.indexOf(">") + 1));
                if(this.value > rageUne){
                    rageFlag = true;
                    break;
                }
            }
            if(rage_.contains(">=")){
                long rageUne = Long.valueOf(rage_.substring(rage_.indexOf("=") + 1));
                if(this.value >= rageUne){
                    rageFlag = true;
                    break;
                }
            }
            if(rage_.contains("<") && !rage_.contains("<=")){
                long rageUne = Long.valueOf(rage_.substring(rage_.indexOf("<") + 1));
                if(this.value < rageUne){
                    rageFlag = true;
                    break;
                }
            }
            if(rage_.contains("<=")){
                long rageUne = Long.valueOf(rage_.substring(rage_.indexOf("<") + 1));
                if(this.value <= rageUne){
                    rageFlag = true;
                    break;
                }
            }
        }
        return rageFlag;
    }
}