FIX.5.0SP2 Message
SequenceReset [type '4']
The sequence reset message is used by the sending application to reset the incoming sequence number on the opposing side.
实现:
package cs.mina.codec.msg;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import cs.mina.exception.InValidDataException;
/*
*@author(huangxiaoping)
*@date 2013-11-27
*/
public class SequenceResetMsg extends BaseMsg {
private Tag gapFillFlag=new Tag("123","Boolean",false);
private Tag newSeqNo=new Tag("36","SeqNum",true);
private Set<String> tagIdsSet=new HashSet<String>();
public SequenceResetMsg(){
tagIdsSet.add("123");
tagIdsSet.add("36");
this.getBodyEntity().getBodyTagList().add(gapFillFlag);
this.getBodyEntity().getBodyTagList().add(newSeqNo);
}
@Override
public void decodeBody() {
Set<String> already=new HashSet<String>();
String[] bodyItems=this.body.split(BaseMsg.SOH);
for(int i=0;i<bodyItems.length;i++){
String[]tagItems=bodyItems[i].split("=");
if(tagItems.length!=2){
throw new InValidDataException("消息格式错误");
}
String tagId=tagItems[0];
if(already.contains(tagId)){
throw new InValidDataException("消息格式错误");
}
already.add(tagId);
if(this.tagIdsSet.contains(tagId)){
List<Tag> tagList=this.bodyEntity.getBodyTagList();
for(int j=0;j<tagList.size();j++){
Tag tag=tagList.get(j);
if(tag.getTagId().equals(tagId)){
tag.setTagValue(tagItems[1]);
break;
}
}
}else{
throw new InValidDataException("消息格式错误,"+tagId+"不在消息体内");
}
}
}
@Override
public void validate() {
this.headEntity.validate();
List<Tag> bodyTagList=this.bodyEntity.getBodyTagList();
for(int i=0;i<bodyTagList.size();i++){
bodyTagList.get(i).validate();
}
this.tailerEntity.validate();
}
public Tag getGapFillFlag() {
return gapFillFlag;
}
public void setGapFillFlag(Tag gapFillFlag) {
this.gapFillFlag = gapFillFlag;
}
public Tag getNewSeqNo() {
return newSeqNo;
}
public void setNewSeqNo(Tag newSeqNo) {
this.newSeqNo = newSeqNo;
}
public Set<String> getTagIdsSet() {
return tagIdsSet;
}
public void setTagIdsSet(Set<String> tagIdsSet) {
this.tagIdsSet = tagIdsSet;
}
}