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; } }