fix协议封装挑战-数据有效性校验

原创 2013年12月03日 12:33:42

数据校验要校验每个字段还有头和尾。

校验包过数据类型校验,特殊值校验。

数据类型校验统一写,特殊值校验写在每个消息实体里。

数据校验采用递归的方式,减少代码编写难度。

Tag类(类型校验没写完,有些特殊类型暂时没写):

package cs.mina.codec.msg;

import java.util.HashSet;
import java.util.Set;

import cs.mina.exception.InValidDataException;

/*
 *@author(huangxiaoping)
 *@date 2013-10-24
 */
public class Tag {
	private String tagId;
	private String tagValue;
	private String format;
	private boolean must;
	
	public  boolean isTagIdInThisObject(String tagId){
		if(tagId.equals(this.tagId)){
			return true;
		}else {
			return false;
		}
	}
	
	public String encode(){
		if(tagValue==null){
			return "";
		}
		return this.tagId+"="+this.tagValue+BaseMsg.SOH;
	}
	
	public String decode(String input,Set<String> already){
		String myItem=input.substring(0, input.indexOf(BaseMsg.SOH));
		String returnStr=input.substring(input.indexOf(BaseMsg.SOH)+1);
		String [] tagItems=myItem.split("=");
		if(tagItems.length!=2){
			throw new InValidDataException("消息格式错误");
		}
		if(already.contains(tagId)){
			throw new InValidDataException(tagId+"消息已被解析");
		}
		if(this.getTagId().equals(tagItems[0])){
			this.tagValue=tagItems[1];
			already.add(tagItems[0]);
			return returnStr;
		}else{
			throw new InValidDataException("解析错误["+tagId+"-"+tagItems[0]+"]");
		}
	}
	
	public Tag(String tagId,String format,boolean must){
		this.tagId=tagId;
		this.format=format;
		this.must=must;
	}
	
	public void validate(){
		if(must){
			if(tagValue==null){
				throw new InValidDataException(tagId+"的值不可以为空");
			}else{
				if(format==null){
					throw new InValidDataException("format的不可以为空");
				}else{
					if(format.equals("int")){
						try{
							Integer.parseInt(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值不是int类型");
						}
						
					}else if(format.equals("Length")){
						try{
							int value=Integer.parseInt(tagValue);
							if(value<=0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(Length)不是正的int类型");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Length)不是int类型");
						}
					}else if(format.equals("TagNum")){
						try{
							if(tagValue.startsWith("0")){
								throw new InValidDataException(tagId+"-"+tagValue+":TagNum类型不能以0开头");
							}
							int value=Integer.parseInt(tagValue);
							if(value<=0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TagNum)不是正的int类型");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TagNum)不是int类型");
						}
					}else if(format.equals("SeqNum")){
						try{
							int value=Integer.parseInt(tagValue);
							if(value<0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(SeqNum)小于0");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(SeqNum)不是int类型");
						}
					}else if(format.equals("NumInGroup")){
						try{
							int value=Integer.parseInt(tagValue);
							if(value<=0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(NumInGroup)不是正的int类型");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(NumInGroup)不是int类型");
						}
					}else if(format.equals("DayOfMonth")){
						try{
							int value=Integer.parseInt(tagValue);
							if(!(value<=31&&value>=1)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(DayOfMonth)不在1和31之间");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(DayOfMonth)不是int类型");
						}
					}else if(format.equals("float")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(float)不是float类型");
						}
						
					}else if(format.equals("Qty")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Qty)不是float类型");
						}
					}else if(format.equals("Price")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Price)不是float类型");
						}
					}else if(format.equals("PriceOffset")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(PriceOffset)不是float类型");
						}
					}else if(format.equals("Amt")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Amt)不是float类型");
						}
					}else if(format.equals("Percentage")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Percentage)不是float类型");
						}
					}else if(format.equals("char")){
						if(tagValue.length()>1||tagValue.length()==0){
							throw new InValidDataException(tagId+"-"+tagValue+":值(char)长度大于1或等于0");
						}
						if(tagValue.equals(BaseMsg.SOH)){
							throw new InValidDataException(tagId+"-"+tagValue+":值(char)不能是分隔符");
						}
						
					}else if(format.equals("Boolean")){
						if(tagValue.length()>1||tagValue.length()==0){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Boolean)长度大于1或等于0");
						}
						if(!(tagValue.equals("N")||tagValue.equals("Y"))){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Boolean)不是N或Y");
						}
					}else if(format.equals("String")){
						int index=tagValue.indexOf(BaseMsg.SOH);
						if(index!=-1){
							throw new InValidDataException(tagId+"-"+tagValue+":值(String)不能包含分隔符");
						}
					}else if(format.equals("MultipleCharValue")){
						int index=tagValue.indexOf(BaseMsg.SOH);
						if(index!=-1){
							throw new InValidDataException(tagId+"-"+tagValue+":值(String)不能包含分隔符");
						}
						String[] valueArray=tagValue.split(" ");
						for(int i=0;i<valueArray.length;i++){
							String value=valueArray[i];
							if(value.length()>1){
								throw new InValidDataException(tagId+"-"+tagValue+":值(MultipleCharValue)包含String小单元了");
							}
						}
					}else if(format.equals("MultipleStringValue")){
						int index=tagValue.indexOf(BaseMsg.SOH);
						if(index!=-1){
							throw new InValidDataException(tagId+"-"+tagValue+":值(String)不能包含分隔符");
						}
					}else if(format.equals("Country")){
						if(tagValue.length()!=2){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Country)长度错误");
						}
						//TODO country比较
					}else if(format.equals("Currency")){
						if(tagValue.length()!=3){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Currency)长度错误");
						}
						//TODO Currency比较
					}else if(format.equals("Exchange")){		
						//TODO Exchange
					}else if(format.equals("MonthYear")){		
						 if(!(tagValue.length()==6||tagValue.length()==8)){
							 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)长度错误");
						 }
						 String year=tagValue.substring(0, 4);
						 String month=tagValue.substring(4, 6);
						 if(tagValue.length()==8){
							 String weekOrDay=tagValue.substring(6, 8);
							 try{
								int y= Integer.parseInt(year);
								if(y<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)年份错误");
								}
							 }catch(Exception e){
								 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)年份错误");
							 }
							 try{
								 int mon= Integer.parseInt(month);
								 if(!(mon>=1&&mon<=12)){
									 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)月份错误");
								 }
							 }catch(Exception e){
								 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)月份错误");
							 }
							 if(weekOrDay.startsWith("w")){
								 try{
									int week= Integer.parseInt(weekOrDay.substring(1));
									if(!(week>=1&&week<=5)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)星期错误");
									}
								 }catch(Exception e){
									 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)星期错误");
								 }
							 }else{
								 try{
									 int day=Integer.parseInt(weekOrDay);
									 if(!(day>=1&&day<=31)){
										 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)day错误");
									 }
								 }catch(Exception e){
									 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)day错误");
								 }
							 }
							 
						 }else{
							 try{
								 int y= Integer.parseInt(year);
									if(y<0){
										throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)年份错误");
									}
							 }catch(Exception e){
								 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)年份错误");
							 }
							 try{
								 int mon= Integer.parseInt(month);
								 if(!(mon>=1&&mon<=12)){
									 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)月份错误");
								 }
							 }catch(Exception e){
								 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)月份错误");
							 }
							
						 }
					}else if(format.equals("UTCTimestamp")){
						if(tagValue.length()==17){
							String yearStr=tagValue.substring(0, 4);
							String monthStr=tagValue.substring(4, 6);
							String dayStr=tagValue.substring(6, 8);
							String seperator1=tagValue.substring(8, 9);
							String hourStr=tagValue.substring(9, 11);
							String seperaotr2=tagValue.substring(11, 12);
							String minuteStr=tagValue.substring(12, 14);
							String seperator3=tagValue.substring(14, 15);
							String secondStr=tagValue.substring(15, 17);
							if(!seperator1.equals("-")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperaotr2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperator3.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							try{
								int year=Integer.parseInt(yearStr);
								if(year<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)年份错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)年份错误");
							}
							try{
								int month=Integer.parseInt(monthStr);
								if(!(month>=1&&month<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)月份错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)月份错误");
							}
							try{
								int day=Integer.parseInt(dayStr);
								if(!(day>=1&&day<=31)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=60)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)秒钟错误");
							}
							
						}else if(tagValue.length()==21){
							String yearStr=tagValue.substring(0, 4);
							String monthStr=tagValue.substring(4, 6);
							String dayStr=tagValue.substring(6, 8);
							String seperator1=tagValue.substring(8, 9);
							String hourStr=tagValue.substring(9, 11);
							String seperaotr2=tagValue.substring(11, 12);
							String minuteStr=tagValue.substring(12, 14);
							String seperator3=tagValue.substring(14, 15);
							String secondStr=tagValue.substring(15, 17);
							String seperater4=tagValue.substring(17, 18);
							String miliSecondStr=tagValue.substring(18, 21);
							if(!seperator1.equals("-")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperaotr2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperator3.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperater4.equals(".")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							try{
								int year=Integer.parseInt(yearStr);
								if(year<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)年份错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)年份错误");
							}
							try{
								int month=Integer.parseInt(monthStr);
								if(!(month>=1&&month<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)月份错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)月份错误");
							}
							try{
								int day=Integer.parseInt(dayStr);
								if(!(day>=1&&day<=31)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=60)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)秒钟错误");
							}
							try{
								int miliSecond=Integer.parseInt(miliSecondStr);
								if(miliSecond<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)毫秒错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)毫秒错误");
							}
							
						}else{
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)长度错误");
						}
					}else if(format.equals("UTCTimeOnly")){
						if(tagValue.length()==8){
							String hourStr=tagValue.substring(0, 2);
							String seperator1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperator2=tagValue.substring(5, 6);
							String secondStr=tagValue.substring(6, 8);
							if(!seperator1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							if(!seperator2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=60)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)秒钟错误");
							}
						}else if(tagValue.length()==12){
							String hourStr=tagValue.substring(0, 2);
							String seperator1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperator2=tagValue.substring(5, 6);
							String secondStr=tagValue.substring(6, 8);
							String seperator3=tagValue.substring(8,9);
							String milliSecondStr=tagValue.substring(9, 12);
							if(!seperator1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							if(!seperator2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							if(!seperator3.equals(".")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=60)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)秒钟错误");
							}
							try{
								int milliSecond=Integer.parseInt(milliSecondStr);
								if(milliSecond<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)毫秒错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)毫秒错误");
							}
						}else{
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)长度错误");
						}
					}else if(format.equals("UTCDateOnly")){
						if(tagValue.length()!=8){
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)长度错误");
						}
						String yearStr=tagValue.substring(0, 4);
						String monthStr=tagValue.substring(4, 6);
						String dayStr=tagValue.substring(6, 8);
						try{
							int year=Integer.parseInt(yearStr);
							if(year<0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)年份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)年份错误");
						}
						try{
							int month=Integer.parseInt(monthStr);
							if(!(month>=1&&month<=12)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)月份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)月份错误");
						}
						try{
							int day=Integer.parseInt(dayStr);
							if(!(day>=1&&day<=31)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)日期错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)日期错误");
						}
					}else if(format.equals("LocalMktDate")){
						if(tagValue.length()!=8){
							throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)长度错误");
						}
						String yearStr=tagValue.substring(0, 4);
						String monthStr=tagValue.substring(4, 6);
						String dayStr=tagValue.substring(6, 8);
						try{
							int year=Integer.parseInt(yearStr);
							if(year<0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)年份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)年份错误");
						}
						try{
							int month=Integer.parseInt(monthStr);
							if(!(month>=1&&month<=12)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)月份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)月份错误");
						}
						try{
							int day=Integer.parseInt(dayStr);
							if(!(day>=1&&day<=31)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)日期错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)日期错误");
						}
					}else if(format.equals("TZTimeOnly")){
						if(tagValue.length()==6){
							String hourStr=tagValue.substring(0, 2);
							String seperate1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String Z=tagValue.substring(5, 6);
							if(!seperate1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!Z.equals("Z")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)Z错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							
						}else if(tagValue.length()==9){
							String hourStr=tagValue.substring(0, 2);
							String seperate1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperate2=tagValue.substring(5,6);
							String secondStr=tagValue.substring(6, 8);
							String Z=tagValue.substring(8, 9);
							if(!seperate1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!Z.equals("Z")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)Z错误");
							}
							if(!seperate2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
							}
						}else if(tagValue.length()==8){
							String hourStr=tagValue.substring(0, 2);
							String seperate1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperate2=tagValue.substring(5,6);
							String offsetHourStr=tagValue.substring(6, 8);
							
							if(!seperate1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							
							if(!(seperate2.equals("-")||seperate2.equals("+"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							try{
								int offsetHour=Integer.parseInt(offsetHourStr);
								if(!(offsetHour>=1&&offsetHour<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
							}
						}else if(tagValue.length()==11){
							String seperator1=tagValue.substring(5, 6);
							String hourStr=tagValue.substring(0,2);
							String seperator2=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							if(!seperator2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							if(seperator1.equals(":")){
								String secondStr=tagValue.substring(6, 8);
								String seperator3=tagValue.substring(8,9);
								String offsetHourStr=tagValue.substring(9, 11);
								if(!(seperator3.equals("-")||seperator3.equals("+"))){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
								}
								try{
									int second=Integer.parseInt(secondStr);
									if(!(second>=0&&second<=59)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
									}
								}catch(Exception e){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
								}
								try{
									int offsetHour=Integer.parseInt(offsetHourStr);
									if(!(offsetHour>=1&&offsetHour<=12)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
									}
								}catch(Exception e){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}else if(seperator1.equals("-")||seperator1.equals("+")){
								String offsetHourStr=tagValue.substring(6,8);
								String seperator3=tagValue.substring(8, 9);
								String offsetMinuteStr=tagValue.substring(9, 11);
								if(!seperator3.equals(":")){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
								}
								try{
									int offsetHour=Integer.parseInt(offsetHourStr);
									if(!(offsetHour>=1&&offsetHour<=12)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
									}
								}catch(Exception e){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
								try{
									int offsetMinute=Integer.parseInt(offsetMinuteStr);
									if(!(offsetMinute>=0&&offsetMinute<=59)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
									}
								}catch(Exception e){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
								}
							}else{
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
						}else if(tagValue.length()==14){
							String hourStr=tagValue.substring(0,2);
							String seperator1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperator2=tagValue.substring(5, 6);
							String secondStr=tagValue.substring(6, 8);
							String seperator3=tagValue.substring(8,9);
							String offsetHourStr=tagValue.substring(9, 11);
							String seperator4=tagValue.substring(11, 12);
							String offsetMinuteStr=tagValue.substring(12, 14);
							if(!seperator1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!seperator2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!(seperator3.equals("+")||seperator3.equals("-"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!seperator4.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
							}
							try{
								int offsetHour=Integer.parseInt(offsetHourStr);
								if(!(offsetHour>=1&&offsetHour<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
							}
							try{
								int offsetMinute=Integer.parseInt(offsetMinuteStr);
								if(!(offsetMinute>=0&&offsetMinute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
							}
						}else {
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)长度错误");
						}
					}else if(format.equals("TZTimestamp")){
						if(tagValue.length()<15){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)长度错误");
						}
						String yearStr=tagValue.substring(0, 4);
						String monthStr=tagValue.substring(4, 6);
						String dayStr=tagValue.substring(6, 8);
						String seperator1=tagValue.substring(8, 9);
						String hourStr=tagValue.substring(9, 11);
						String seperator2=tagValue.substring(11, 12);
						String minuteStr=tagValue.substring(12, 14);
						if(!seperator1.equals("-")){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
						}
						if(!seperator2.equals(":")){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
						}
						try{
							int year=Integer.parseInt(yearStr);
							if(year<0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)年份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)年份错误");
						}
						try{
							int month=Integer.parseInt(monthStr);
							if(!(month>=1&&month<=12)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)月份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)月份错误");
						}
						try{
							int day=Integer.parseInt(dayStr);
							if(!(day>=1&&day<=31)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
						}
						try{
							int hour=Integer.parseInt(hourStr);
							if(!(hour>=0&&hour<=23)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)小时错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)小时错误");
						}
						try{
							int minute=Integer.parseInt(minuteStr);
							if(!(minute>=0&&minute<=59)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)分钟错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)分钟错误");
						}
						
						if(tagValue.length()==15){
							String Z=tagValue.substring(14, 15);
							if(!Z.equals("Z")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)Z错误");
							}
						}else if(tagValue.length()==17){
							String seperator3=tagValue.substring(14, 15);
							String offsetHourStr=tagValue.substring(15, 17);
							if(!(seperator3.equals("-")||seperator3.equals("+"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
							}
							try{
								int offsetHour=Integer.parseInt(offsetHourStr);
								if(!(offsetHour>=1&&offsetHour<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
							}
						}else if(tagValue.length()==20){
							String seperator3=tagValue.substring(14, 15);
							String offsetHourStr=tagValue.substring(15, 17);
							String seperator4=tagValue.substring(17, 18);
							String offsetMinuteStr=tagValue.substring(18, 20);
							if(!(seperator3.equals("-")||seperator3.equals("+"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
							}
							if(!(seperator4.equals("-")||seperator3.equals(":"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
							}
							try{
								int offsetHour=Integer.parseInt(offsetHourStr);
								if(!(offsetHour>=1&&offsetHour<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
							}
							try{
								int offsetMinute=Integer.parseInt(offsetMinuteStr);
								if(!(offsetMinute>=0&&offsetMinute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
							}
						}else {
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)长度错误");
						}
					}else if(format.equals("data")){
						//TODO
					}else if(format.equals("Pattern")){
						
					}else if(format.equals("Tenor")){
						
					}else if(format.equals("Reserved100Plus")){
						
					}else if(format.equals("Reserved1000Plus")){
						
					}else if(format.equals("Reserved4000Plus")){
						
					}else if(format.equals("XMLData")){
						
					}else if(format.equals("Language")){
						
					}else{
						throw new InValidDataException(tagId+"-"+tagValue+"-"+format+":format类型错误");
					}
				}
			}
		}else{
			if(tagValue!=null){
				if(format==null){
					throw new InValidDataException("format的不可以为空");
				}else{
					if(format.equals("int")){
						try{
							Integer.parseInt(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值不是int类型");
						}
						
					}else if(format.equals("Length")){
						try{
							int value=Integer.parseInt(tagValue);
							if(value<=0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(Length)不是正的int类型");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Length)不是int类型");
						}
					}else if(format.equals("TagNum")){
						try{
							if(tagValue.startsWith("0")){
								throw new InValidDataException(tagId+"-"+tagValue+":TagNum类型不能以0开头");
							}
							int value=Integer.parseInt(tagValue);
							if(value<=0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TagNum)不是正的int类型");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TagNum)不是int类型");
						}
					}else if(format.equals("SeqNum")){
						try{
							int value=Integer.parseInt(tagValue);
							if(value<0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(SeqNum)小于0");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(SeqNum)不是int类型");
						}
					}else if(format.equals("NumInGroup")){
						try{
							int value=Integer.parseInt(tagValue);
							if(value<=0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(NumInGroup)不是正的int类型");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(NumInGroup)不是int类型");
						}
					}else if(format.equals("DayOfMonth")){
						try{
							int value=Integer.parseInt(tagValue);
							if(!(value<=31&&value>=1)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(DayOfMonth)不在1和31之间");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(DayOfMonth)不是int类型");
						}
					}else if(format.equals("float")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(float)不是float类型");
						}
						
					}else if(format.equals("Qty")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Qty)不是float类型");
						}
					}else if(format.equals("Price")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Price)不是float类型");
						}
					}else if(format.equals("PriceOffset")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(PriceOffset)不是float类型");
						}
					}else if(format.equals("Amt")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Amt)不是float类型");
						}
					}else if(format.equals("Percentage")){
						try{
							Float.parseFloat(tagValue);
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Percentage)不是float类型");
						}
					}else if(format.equals("char")){
						if(tagValue.length()>1||tagValue.length()==0){
							throw new InValidDataException(tagId+"-"+tagValue+":值(char)长度大于1或等于0");
						}
						if(tagValue.equals(BaseMsg.SOH)){
							throw new InValidDataException(tagId+"-"+tagValue+":值(char)不能是分隔符");
						}
						
					}else if(format.equals("Boolean")){
						if(tagValue.length()>1||tagValue.length()==0){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Boolean)长度大于1或等于0");
						}
						if(!(tagValue.equals("N")||tagValue.equals("Y"))){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Boolean)不是N或Y");
						}
					}else if(format.equals("String")){
						int index=tagValue.indexOf(BaseMsg.SOH);
						if(index!=-1){
							throw new InValidDataException(tagId+"-"+tagValue+":值(String)不能包含分隔符");
						}
					}else if(format.equals("MultipleCharValue")){
						int index=tagValue.indexOf(BaseMsg.SOH);
						if(index!=-1){
							throw new InValidDataException(tagId+"-"+tagValue+":值(String)不能包含分隔符");
						}
						String[] valueArray=tagValue.split(" ");
						for(int i=0;i<valueArray.length;i++){
							String value=valueArray[i];
							if(value.length()>1){
								throw new InValidDataException(tagId+"-"+tagValue+":值(MultipleCharValue)包含String小单元了");
							}
						}
					}else if(format.equals("MultipleStringValue")){
						int index=tagValue.indexOf(BaseMsg.SOH);
						if(index!=-1){
							throw new InValidDataException(tagId+"-"+tagValue+":值(String)不能包含分隔符");
						}
					}else if(format.equals("Country")){
						if(tagValue.length()!=2){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Country)长度错误");
						}
						//TODO country比较
					}else if(format.equals("Currency")){
						if(tagValue.length()!=3){
							throw new InValidDataException(tagId+"-"+tagValue+":值(Currency)长度错误");
						}
						//TODO Currency比较
					}else if(format.equals("Exchange")){		
						//TODO Exchange
					}else if(format.equals("MonthYear")){		
						 if(!(tagValue.length()==6||tagValue.length()==8)){
							 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)长度错误");
						 }
						 String year=tagValue.substring(0, 4);
						 String month=tagValue.substring(4, 6);
						 if(tagValue.length()==8){
							 String weekOrDay=tagValue.substring(6, 8);
							 try{
								int y= Integer.parseInt(year);
								if(y<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)年份错误");
								}
							 }catch(Exception e){
								 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)年份错误");
							 }
							 try{
								 int mon= Integer.parseInt(month);
								 if(!(mon>=1&&mon<=12)){
									 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)月份错误");
								 }
							 }catch(Exception e){
								 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)月份错误");
							 }
							 if(weekOrDay.startsWith("w")){
								 try{
									int week= Integer.parseInt(weekOrDay.substring(1));
									if(!(week>=1&&week<=5)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)星期错误");
									}
								 }catch(Exception e){
									 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)星期错误");
								 }
							 }else{
								 try{
									 int day=Integer.parseInt(weekOrDay);
									 if(!(day>=1&&day<=31)){
										 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)day错误");
									 }
								 }catch(Exception e){
									 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)day错误");
								 }
							 }
							 
						 }else{
							 try{
								 int y= Integer.parseInt(year);
									if(y<0){
										throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)年份错误");
									}
							 }catch(Exception e){
								 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)年份错误");
							 }
							 try{
								 int mon= Integer.parseInt(month);
								 if(!(mon>=1&&mon<=12)){
									 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)月份错误");
								 }
							 }catch(Exception e){
								 throw new InValidDataException(tagId+"-"+tagValue+":值(MonthYear)月份错误");
							 }
							
						 }
					}else if(format.equals("UTCTimestamp")){
						if(tagValue.length()==17){
							String yearStr=tagValue.substring(0, 4);
							String monthStr=tagValue.substring(4, 6);
							String dayStr=tagValue.substring(6, 8);
							String seperator1=tagValue.substring(8, 9);
							String hourStr=tagValue.substring(9, 11);
							String seperaotr2=tagValue.substring(11, 12);
							String minuteStr=tagValue.substring(12, 14);
							String seperator3=tagValue.substring(14, 15);
							String secondStr=tagValue.substring(15, 17);
							if(!seperator1.equals("-")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperaotr2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperator3.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							try{
								int year=Integer.parseInt(yearStr);
								if(year<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)年份错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)年份错误");
							}
							try{
								int month=Integer.parseInt(monthStr);
								if(!(month>=1&&month<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)月份错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)月份错误");
							}
							try{
								int day=Integer.parseInt(dayStr);
								if(!(day>=1&&day<=31)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=60)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)秒钟错误");
							}
							
						}else if(tagValue.length()==21){
							String yearStr=tagValue.substring(0, 4);
							String monthStr=tagValue.substring(4, 6);
							String dayStr=tagValue.substring(6, 8);
							String seperator1=tagValue.substring(8, 9);
							String hourStr=tagValue.substring(9, 11);
							String seperaotr2=tagValue.substring(11, 12);
							String minuteStr=tagValue.substring(12, 14);
							String seperator3=tagValue.substring(14, 15);
							String secondStr=tagValue.substring(15, 17);
							String seperater4=tagValue.substring(17, 18);
							String miliSecondStr=tagValue.substring(18, 21);
							if(!seperator1.equals("-")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperaotr2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperator3.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							if(!seperater4.equals(".")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							try{
								int year=Integer.parseInt(yearStr);
								if(year<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)年份错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)年份错误");
							}
							try{
								int month=Integer.parseInt(monthStr);
								if(!(month>=1&&month<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)月份错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)月份错误");
							}
							try{
								int day=Integer.parseInt(dayStr);
								if(!(day>=1&&day<=31)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)日期错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=60)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)秒钟错误");
							}
							try{
								int miliSecond=Integer.parseInt(miliSecondStr);
								if(miliSecond<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)毫秒错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)毫秒错误");
							}
							
						}else{
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimestamp)长度错误");
						}
					}else if(format.equals("UTCTimeOnly")){
						if(tagValue.length()==8){
							String hourStr=tagValue.substring(0, 2);
							String seperator1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperator2=tagValue.substring(5, 6);
							String secondStr=tagValue.substring(6, 8);
							if(!seperator1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							if(!seperator2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=60)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)秒钟错误");
							}
						}else if(tagValue.length()==12){
							String hourStr=tagValue.substring(0, 2);
							String seperator1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperator2=tagValue.substring(5, 6);
							String secondStr=tagValue.substring(6, 8);
							String seperator3=tagValue.substring(8,9);
							String milliSecondStr=tagValue.substring(9, 12);
							if(!seperator1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							if(!seperator2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							if(!seperator3.equals(".")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=60)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)秒钟错误");
							}
							try{
								int milliSecond=Integer.parseInt(milliSecondStr);
								if(milliSecond<0){
									throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)毫秒错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)毫秒错误");
							}
						}else{
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCTimeOnly)长度错误");
						}
					}else if(format.equals("UTCDateOnly")){
						if(tagValue.length()!=8){
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)长度错误");
						}
						String yearStr=tagValue.substring(0, 4);
						String monthStr=tagValue.substring(4, 6);
						String dayStr=tagValue.substring(6, 8);
						try{
							int year=Integer.parseInt(yearStr);
							if(year<0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)年份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)年份错误");
						}
						try{
							int month=Integer.parseInt(monthStr);
							if(!(month>=1&&month<=12)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)月份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)月份错误");
						}
						try{
							int day=Integer.parseInt(dayStr);
							if(!(day>=1&&day<=31)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)日期错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(UTCDateOnly)日期错误");
						}
					}else if(format.equals("LocalMktDate")){
						if(tagValue.length()!=8){
							throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)长度错误");
						}
						String yearStr=tagValue.substring(0, 4);
						String monthStr=tagValue.substring(4, 6);
						String dayStr=tagValue.substring(6, 8);
						try{
							int year=Integer.parseInt(yearStr);
							if(year<0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)年份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)年份错误");
						}
						try{
							int month=Integer.parseInt(monthStr);
							if(!(month>=1&&month<=12)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)月份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)月份错误");
						}
						try{
							int day=Integer.parseInt(dayStr);
							if(!(day>=1&&day<=31)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)日期错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(LocalMktDate)日期错误");
						}
					}else if(format.equals("TZTimeOnly")){
						if(tagValue.length()==6){
							String hourStr=tagValue.substring(0, 2);
							String seperate1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String Z=tagValue.substring(5, 6);
							if(!seperate1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!Z.equals("Z")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)Z错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							
						}else if(tagValue.length()==9){
							String hourStr=tagValue.substring(0, 2);
							String seperate1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperate2=tagValue.substring(5,6);
							String secondStr=tagValue.substring(6, 8);
							String Z=tagValue.substring(8, 9);
							if(!seperate1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!Z.equals("Z")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)Z错误");
							}
							if(!seperate2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
							}
						}else if(tagValue.length()==8){
							String hourStr=tagValue.substring(0, 2);
							String seperate1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperate2=tagValue.substring(5,6);
							String offsetHourStr=tagValue.substring(6, 8);
							
							if(!seperate1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							
							if(!(seperate2.equals("-")||seperate2.equals("+"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							try{
								int offsetHour=Integer.parseInt(offsetHourStr);
								if(!(offsetHour>=1&&offsetHour<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
							}
						}else if(tagValue.length()==11){
							String seperator1=tagValue.substring(5, 6);
							String hourStr=tagValue.substring(0,2);
							String seperator2=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							if(!seperator2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							if(seperator1.equals(":")){
								String secondStr=tagValue.substring(6, 8);
								String seperator3=tagValue.substring(8,9);
								String offsetHourStr=tagValue.substring(9, 11);
								if(!(seperator3.equals("-")||seperator3.equals("+"))){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
								}
								try{
									int second=Integer.parseInt(secondStr);
									if(!(second>=0&&second<=59)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
									}
								}catch(Exception e){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
								}
								try{
									int offsetHour=Integer.parseInt(offsetHourStr);
									if(!(offsetHour>=1&&offsetHour<=12)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
									}
								}catch(Exception e){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}else if(seperator1.equals("-")||seperator1.equals("+")){
								String offsetHourStr=tagValue.substring(6,8);
								String seperator3=tagValue.substring(8, 9);
								String offsetMinuteStr=tagValue.substring(9, 11);
								if(!seperator3.equals(":")){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
								}
								try{
									int offsetHour=Integer.parseInt(offsetHourStr);
									if(!(offsetHour>=1&&offsetHour<=12)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
									}
								}catch(Exception e){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
								try{
									int offsetMinute=Integer.parseInt(offsetMinuteStr);
									if(!(offsetMinute>=0&&offsetMinute<=59)){
										throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
									}
								}catch(Exception e){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
								}
							}else{
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
						}else if(tagValue.length()==14){
							String hourStr=tagValue.substring(0,2);
							String seperator1=tagValue.substring(2, 3);
							String minuteStr=tagValue.substring(3, 5);
							String seperator2=tagValue.substring(5, 6);
							String secondStr=tagValue.substring(6, 8);
							String seperator3=tagValue.substring(8,9);
							String offsetHourStr=tagValue.substring(9, 11);
							String seperator4=tagValue.substring(11, 12);
							String offsetMinuteStr=tagValue.substring(12, 14);
							if(!seperator1.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!seperator2.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!(seperator3.equals("+")||seperator3.equals("-"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							if(!seperator4.equals(":")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)时间错误");
							}
							try{
								int hour=Integer.parseInt(hourStr);
								if(!(hour>=0&&hour<=23)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)小时错误");
							}
							try{
								int minute=Integer.parseInt(minuteStr);
								if(!(minute>=0&&minute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)分钟错误");
							}
							try{
								int second=Integer.parseInt(secondStr);
								if(!(second>=0&&second<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)秒钟错误");
							}
							try{
								int offsetHour=Integer.parseInt(offsetHourStr);
								if(!(offsetHour>=1&&offsetHour<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
							}
							try{
								int offsetMinute=Integer.parseInt(offsetMinuteStr);
								if(!(offsetMinute>=0&&offsetMinute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
							}
						}else {
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)长度错误");
						}
					}else if(format.equals("TZTimestamp")){
						if(tagValue.length()<15){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)长度错误");
						}
						String yearStr=tagValue.substring(0, 4);
						String monthStr=tagValue.substring(4, 6);
						String dayStr=tagValue.substring(6, 8);
						String seperator1=tagValue.substring(8, 9);
						String hourStr=tagValue.substring(9, 11);
						String seperator2=tagValue.substring(11, 12);
						String minuteStr=tagValue.substring(12, 14);
						if(!seperator1.equals("-")){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
						}
						if(!seperator2.equals(":")){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
						}
						try{
							int year=Integer.parseInt(yearStr);
							if(year<0){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)年份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)年份错误");
						}
						try{
							int month=Integer.parseInt(monthStr);
							if(!(month>=1&&month<=12)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)月份错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)月份错误");
						}
						try{
							int day=Integer.parseInt(dayStr);
							if(!(day>=1&&day<=31)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
						}
						try{
							int hour=Integer.parseInt(hourStr);
							if(!(hour>=0&&hour<=23)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)小时错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)小时错误");
						}
						try{
							int minute=Integer.parseInt(minuteStr);
							if(!(minute>=0&&minute<=59)){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)分钟错误");
							}
						}catch(Exception e){
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)分钟错误");
						}
						
						if(tagValue.length()==15){
							String Z=tagValue.substring(14, 15);
							if(!Z.equals("Z")){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)Z错误");
							}
						}else if(tagValue.length()==17){
							String seperator3=tagValue.substring(14, 15);
							String offsetHourStr=tagValue.substring(15, 17);
							if(!(seperator3.equals("-")||seperator3.equals("+"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
							}
							try{
								int offsetHour=Integer.parseInt(offsetHourStr);
								if(!(offsetHour>=1&&offsetHour<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
							}
						}else if(tagValue.length()==20){
							String seperator3=tagValue.substring(14, 15);
							String offsetHourStr=tagValue.substring(15, 17);
							String seperator4=tagValue.substring(17, 18);
							String offsetMinuteStr=tagValue.substring(18, 20);
							if(!(seperator3.equals("-")||seperator3.equals("+"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
							}
							if(!(seperator4.equals("-")||seperator3.equals(":"))){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)日期错误");
							}
							try{
								int offsetHour=Integer.parseInt(offsetHourStr);
								if(!(offsetHour>=1&&offsetHour<=12)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移小时错误");
							}
							try{
								int offsetMinute=Integer.parseInt(offsetMinuteStr);
								if(!(offsetMinute>=0&&offsetMinute<=59)){
									throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
								}
							}catch(Exception e){
								throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimeOnly)偏移分钟错误");
							}
						}else {
							throw new InValidDataException(tagId+"-"+tagValue+":值(TZTimestamp)长度错误");
						}
					}else if(format.equals("data")){
						//TODO
					}else if(format.equals("Pattern")){
						
					}else if(format.equals("Tenor")){
						
					}else if(format.equals("Reserved100Plus")){
						
					}else if(format.equals("Reserved1000Plus")){
						
					}else if(format.equals("Reserved4000Plus")){
						
					}else if(format.equals("XMLData")){
						
					}else if(format.equals("Language")){
						
					}else{
						throw new InValidDataException(tagId+"-"+tagValue+"-"+format+":format类型错误");
					}
				}
			}
			
		}
	}
	
	public String getTagId() {
		return tagId;
	}

	public void setTagId(String tagId) {
		this.tagId = tagId;
	}

	public String getTagValue() {
		return tagValue;
	}

	public void setTagValue(String tagValue) {
		this.tagValue = tagValue;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public boolean isMust() {
		return must;
	}

	public void setMust(boolean must) {
		this.must = must;
	}

}


版权声明:本文为博主原创文章,未经博主允许不得转载。

fix协议封装挑战-测试代码

初步测试工具采用香港证券交易所的一个离线测试工具,测试数据包正确性。 工具名称叫做OCG Simulator 1.2.1。 测试代码比如: TC_QM_03测试案例: package cs.t...
  • hxpjava1
  • hxpjava1
  • 2013年12月03日 12:38
  • 1216

fix协议封装挑战

最近在做金融项目,用到了fix协议,是么是fix协议我就不多说了,由我一个人去封装这个庞然大物,当然很多没用到的我们暂时没封装进去。 下面是我的思路。 msg由个基类BaseMsg compon...
  • hxpjava1
  • hxpjava1
  • 2013年12月02日 17:04
  • 5280

fix协议中消息尾校验方法

fix协议的每一条消息都分为三部分,即:消息头,消息内容,消息尾消息头和消息尾FIX 协议每个消息都包括标准消息头和标准消息尾。在标准消息头和标准消息尾中间的是消息体。消息的类型在标准消息头中标签信息...
  • fengmm521
  • fengmm521
  • 2017年11月04日 21:59
  • 103

fix协议封装挑战-ClientHandlerFactory&ClientMessageHandler

package cs.mina.client.handler; import java.util.HashMap; import java.util.Map; /* *@author(huang...
  • hxpjava1
  • hxpjava1
  • 2017年07月11日 09:17
  • 115

fix协议封装挑战-DbFail

package cs.mina.client.handler; import java.io.Serializable; import java.util.concurrent.locks.Lock...
  • hxpjava1
  • hxpjava1
  • 2017年07月11日 09:20
  • 123

fix协议封装挑战-DbFailExecuteThreadHandler

package cs.mina.client.handler; import java.text.SimpleDateFormat; import java.util.Calendar; impor...
  • hxpjava1
  • hxpjava1
  • 2017年07月11日 09:21
  • 164

Fix协议封装挑战-消息处理

消息处理还没正式开始写,有待完善: 处理器工厂如下: package cs.mina.client.handler; import java.util.HashMap; import java....
  • hxpjava1
  • hxpjava1
  • 2013年12月03日 12:40
  • 904

fix协议封装挑战-工具类

MsgUtil: /* * @headerAndBody 包含消息头+消息体,包含SOH,不包含checksum域 */ public static String ch...
  • hxpjava1
  • hxpjava1
  • 2013年12月03日 12:43
  • 858

fix协议封装挑战-BusinessMessageRejectMessageHandler

package cs.mina.client.handler; import java.util.Calendar; import java.util.Date; import java.util....
  • hxpjava1
  • hxpjava1
  • 2017年07月11日 09:15
  • 151

fix协议介绍-常用资源

最终要的资料就是规范了: http://old.fixprotocol.org/FIXimate3.0/latestEP/    这个是最新规范的web版,消息结构 http://www.f...
  • hxpjava1
  • hxpjava1
  • 2013年12月03日 12:49
  • 1339
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:fix协议封装挑战-数据有效性校验
举报原因:
原因补充:

(最多只允许输入30个字)