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 VTDouble extends VTDataType{ //精度 private int accuracy; //0: 手动输入; 1: 下拉框选择 public static int accInMode; public static int accDefault; public static int accMax; //长度 private int length; public static int lenInMode; public static int lenDefault; public static int lenMax; //默认值 public static double defaultValue; public static int defVInMode; private double value; public double getValue(){ return this.value; } public VTDouble(double 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; } String[] rages = rage.split(";"); boolean rageFlag = false; //当该值等于 用!= 所限制的值时,不满足值域 for(int i = 0; i < rages.length; i++){ String rage_ = rages[i]; if(rage_.contains("!=")){ double rageUne = Double.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("=")){ double rageUne = Double.valueOf(rage_.substring(rage_.indexOf("=") + 1)); if(rageUne == this.value){ rageFlag = true; break; } } if(rage_.contains(">") && !rage_.contains(">=")){ double rageUne = Double.valueOf(rage_.substring(rage_.indexOf(">") + 1)); if(this.value > rageUne){ rageFlag = true; break; } } if(rage_.contains(">=")){ double rageUne = Double.valueOf(rage_.substring(rage_.indexOf("=") + 1)); if(this.value >= rageUne){ rageFlag = true; break; } } if(rage_.contains("<") && !rage_.contains("<=")){ double rageUne = Double.valueOf(rage_.substring(rage_.indexOf("<") + 1)); if(this.value < rageUne){ rageFlag = true; break; } } if(rage_.contains("<=")){ double rageUne = Double.valueOf(rage_.substring(rage_.indexOf("<") + 1)); if(this.value <= rageUne){ 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 = String.valueOf(this.value).length() - 1; if(length >= maxLength){ return true; } return false; } }