gt:                 TagEncoder.encode(bao, TagNum.Currency, currency.getValue());
context: /*
   *   Copyright (c) 2006-2016 Marvisan Pty. Ltd. All rights reserved.
   *               Use is subject to license terms.
   */
  
  /*
   * NewOrderCrossMsg43.java
   *
   * $Id: NewOrderCrossMsg43.java,v 1.1 2011-05-12 09:26:09 vrotaru Exp $
   */
  package net.hades.fix.message.impl.v43;
  
  import net.hades.fix.message.FragmentContext;
  import net.hades.fix.message.comp.Instrument;
  import net.hades.fix.message.comp.SpreadOrBenchmarkCurveData;
  import net.hades.fix.message.comp.YieldData;
  import net.hades.fix.message.comp.impl.v43.SpreadOrBenchmarkCurveData43;
  import net.hades.fix.message.comp.impl.v43.Stipulations43;
  import net.hades.fix.message.group.StipulationsGroup;
  import net.hades.fix.message.group.impl.v43.TradingSessionGroup43;
  import net.hades.fix.message.struct.Tag;
  import net.hades.fix.message.type.ApplVerID;
  import net.hades.fix.message.type.SessionRejectReason;
  import net.hades.fix.message.util.MsgUtil;
  
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.nio.ByteBuffer;
  import java.util.Arrays;
  import java.util.ArrayList;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  import java.util.logging.Level;
  
  import javax.xml.bind.annotation.XmlElementRef;
  
  import net.hades.fix.message.Header;
  import net.hades.fix.message.NewOrderCrossMsg;
  import net.hades.fix.message.comp.Stipulations;
  import net.hades.fix.message.comp.impl.v43.Instrument43;
  import net.hades.fix.message.comp.impl.v43.YieldData43;
  import net.hades.fix.message.exception.BadFormatMsgException;
  import net.hades.fix.message.exception.InvalidMsgException;
  import net.hades.fix.message.exception.TagNotPresentException;
  import net.hades.fix.message.group.SideCrossOrdModGroup;
  import net.hades.fix.message.group.TradingSessionGroup;
  import net.hades.fix.message.group.impl.v43.SideCrossOrdModGroup43;
  import net.hades.fix.message.type.BeginString;
  import net.hades.fix.message.type.DiscretionInst;
  import net.hades.fix.message.type.TagNum;
  import net.hades.fix.message.util.TagEncoder;
  
  /**
   * FIX version 4.3 NewOrderCrossMsg implementation.
   *
   * @author <a href="mailto:support@marvisan.com">Support Team</a>
   * @version $Revision: 1.1 $
   * @created 10/05/2011, 9:32:41 AM
   */
  public class NewOrderCrossMsg43 extends NewOrderCrossMsg {
  
      // <editor-fold defaultstate="collapsed" desc="Constants">
  
      private static final long serialVersionUID = 1L;
  
      protected static final Set<Integer> TAGS_V43 = new HashSet<Integer>(Arrays.asList(new Integer[] {
          TagNum.CrossID.getValue(),
          TagNum.CrossType.getValue(),
          TagNum.CrossPrioritization.getValue(),
          TagNum.NoSides.getValue(),
          TagNum.SettlType.getValue(),
          TagNum.SettlDate.getValue(),
          TagNum.HandlInst.getValue(),
          TagNum.ExecInst.getValue(),
          TagNum.MinQty.getValue(),
          TagNum.MaxFloor.getValue(),
          TagNum.ExDestination.getValue(),
          TagNum.NoTradingSessions.getValue(),
          TagNum.ProcessCode.getValue(),
          TagNum.PrevClosePx.getValue(),
          TagNum.LocateReqd.getValue(),
          TagNum.TransactTime.getValue(),
          TagNum.OrdType.getValue(),
          TagNum.PriceType.getValue(),
          TagNum.Price.getValue(),
          TagNum.StopPx.getValue(),
          TagNum.Currency.getValue(),
          TagNum.ComplianceID.getValue(),
          TagNum.IOIID.getValue(),
          TagNum.QuoteID.getValue(),
          TagNum.TimeInForce.getValue(),
          TagNum.EffectiveTime.getValue(),
          TagNum.ExpireDate.getValue(),
          TagNum.ExpireTime.getValue(),
          TagNum.GTBookingInst.getValue(),
          TagNum.MaxShow.getValue(),
          TagNum.PegOffsetValue.getValue(),
          TagNum.DiscretionInst.getValue(),
          TagNum.DiscretionOffsetValue.getValue(),
          TagNum.CancellationRights.getValue(),
          TagNum.MoneyLaunderingStatus.getValue(),
          TagNum.RegistID.getValue(),
          TagNum.Designation.getValue(),
          TagNum.AccruedInterestRate.getValue(),
          TagNum.AccruedInterestAmt.getValue(),
          TagNum.NetMoney.getValue()
      }));
  
      protected static final Set<Integer> SIDE_CROSS_ORD_MOD_GROUP_TAGS = new SideCrossOrdModGroup43().getFragmentAllTags();
      protected static final Set<Integer> INSTRUMENT_COMP_TAGS = new Instrument43().getFragmentAllTags();
      protected static final Set<Integer> TRAD_SESSION_GROUP_TAGS = new TradingSessionGroup43().getFragmentAllTags();
      protected static final Set<Integer> STIPULATIONS_COMP_TAGS = new Stipulations43().getFragmentAllTags();
      protected static final Set<Integer> SPREAD_COMP_TAGS = new SpreadOrBenchmarkCurveData43().getFragmentAllTags();
      protected static final Set<Integer> YIELD_DATA_COMP_TAGS = new YieldData43().getFragmentAllTags();
  
      protected static final Set<Integer> START_COMP_TAGS;
  
      protected static final Set<Integer> ALL_TAGS;
  
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="Static Block">
  
      static {
          ALL_TAGS = new HashSet<Integer>(TAGS_V43);
          ALL_TAGS.addAll(SIDE_CROSS_ORD_MOD_GROUP_TAGS);
          ALL_TAGS.addAll(INSTRUMENT_COMP_TAGS);
          ALL_TAGS.addAll(TRAD_SESSION_GROUP_TAGS);
          ALL_TAGS.addAll(STIPULATIONS_COMP_TAGS);
          ALL_TAGS.addAll(SPREAD_COMP_TAGS);
          ALL_TAGS.addAll(YIELD_DATA_COMP_TAGS);
          START_COMP_TAGS = new HashSet<Integer>(SIDE_CROSS_ORD_MOD_GROUP_TAGS);
          START_COMP_TAGS.addAll(INSTRUMENT_COMP_TAGS);
          START_COMP_TAGS.addAll(TRAD_SESSION_GROUP_TAGS);
          START_COMP_TAGS.addAll(STIPULATIONS_COMP_TAGS);
          START_COMP_TAGS.addAll(SPREAD_COMP_TAGS);
          START_COMP_TAGS.addAll(YIELD_DATA_COMP_TAGS);
      }
  
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="Attributes">
  
      protected Set<Integer> STANDARD_SECURED_TAGS = TAGS_V43;
  
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="Constructors">
  
      public NewOrderCrossMsg43() {
          super();
      }
  
      public NewOrderCrossMsg43(Header header, ByteBuffer rawMsg)
      throws InvalidMsgException, TagNotPresentException, BadFormatMsgException {
          super(header, rawMsg);
          SECURED_TAGS = STANDARD_SECURED_TAGS;
      }
  
      public NewOrderCrossMsg43(BeginString beginString) throws InvalidMsgException {
          super(beginString);
          SECURED_TAGS = STANDARD_SECURED_TAGS;
      }
  
      public NewOrderCrossMsg43(BeginString beginString, ApplVerID applVerID) throws InvalidMsgException {
          super(beginString, applVerID);
          SECURED_TAGS = STANDARD_SECURED_TAGS;
      }
  
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="Public Methods">
  
      @Override
      public Set<Integer> getFragmentTags() {
          return TAGS_V43;
      }
  
      @Override
      public Set<Integer> getFragmentAllTags() {
          return ALL_TAGS;
      }
  
      // ACCESSOR METHODS
      //////////////////////////////////////////
  
      @Override
      public Integer getNoSides() {
          return noSides;
      }
  
      @Override
      public void setNoSides(Integer noSides) {
          this.noSides = noSides;
          if (noSides != null) {
              sideCrossOrdModGroups = new SideCrossOrdModGroup[noSides.intValue()];
              for (int i = 0; i < sideCrossOrdModGroups.length; i++) {
                  sideCrossOrdModGroups[i] = new SideCrossOrdModGroup43(new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired));
              }
          }
      }
  
      @Override
      public SideCrossOrdModGroup[] getSideCrossOrdModGroups() {
          return sideCrossOrdModGroups;
      }
  
      public void setSideCrossOrdModGroups(SideCrossOrdModGroup[] sideCrossOrdModGroups) {
          this.sideCrossOrdModGroups = sideCrossOrdModGroups;
          if (sideCrossOrdModGroups != null) {
              noSides = new Integer(sideCrossOrdModGroups.length);
          }
      }
  
      @Override
      public SideCrossOrdModGroup addSideCrossOrdModGroup() {
          SideCrossOrdModGroup group = new SideCrossOrdModGroup43(new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired));
          List<SideCrossOrdModGroup> groups = new ArrayList<SideCrossOrdModGroup>();
          if (sideCrossOrdModGroups != null && sideCrossOrdModGroups.length > 0) {
              groups = new ArrayList<SideCrossOrdModGroup>(Arrays.asList(sideCrossOrdModGroups));
          }
          groups.add(group);
          sideCrossOrdModGroups = groups.toArray(new SideCrossOrdModGroup[groups.size()]);
          noSides = new Integer(sideCrossOrdModGroups.length);
  
          return group;
      }
  
      @Override
      public SideCrossOrdModGroup deleteSideCrossOrdModGroup(int index) {
          SideCrossOrdModGroup result = null;
          if (sideCrossOrdModGroups != null && sideCrossOrdModGroups.length > 0 && sideCrossOrdModGroups.length > index) {
              List<SideCrossOrdModGroup> groups = new ArrayList<SideCrossOrdModGroup>(Arrays.asList(sideCrossOrdModGroups));
              result = groups.remove(index);
              sideCrossOrdModGroups = groups.toArray(new SideCrossOrdModGroup[groups.size()]);
              if (sideCrossOrdModGroups.length > 0) {
                  noSides = new Integer(sideCrossOrdModGroups.length);
              } else {
                  sideCrossOrdModGroups = null;
                  noSides = null;
              }
          }
  
          return result;
      }
  
      @Override
      public int clearSideCrossOrdModGroups() {
          int result = 0;
          if (sideCrossOrdModGroups != null && sideCrossOrdModGroups.length > 0) {
              result = sideCrossOrdModGroups.length;
              sideCrossOrdModGroups = null;
              noSides = null;
          }
  
          return result;
      }
  
      @Override
      public Instrument getInstrument() {
          return instrument;
      }
  
      @Override
      public void setInstrument() {
          FragmentContext context = new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired);
          this.instrument = new Instrument43(context);
      }
  
      public void setInstrument(Instrument instrument) {
          this.instrument = instrument;
      }
      
      @Override
      public void clearInstrument() {
          this.instrument = null;
      }
  
      @Override
      public Integer getNoTradingSessions() {
          return noTradingSessions;
      }
  
      @Override
      public void setNoTradingSessions(Integer noTradingSessions) {
          this.noTradingSessions = noTradingSessions;
          if (noTradingSessions != null) {
              tradingSessionGroups = new TradingSessionGroup[noTradingSessions.intValue()];
              for (int i = 0; i < tradingSessionGroups.length; i++) {
                  tradingSessionGroups[i] = new TradingSessionGroup43(new FragmentContext(sessionCharset, messageEncoding, validateRequired));
              }
          }
      }
  
      @XmlElementRef
      @Override
      public TradingSessionGroup[] getTradingSessionGroups() {
          return tradingSessionGroups;
      }
  
      public void setTradingSessionGroups(TradingSessionGroup[] tradingSessionGroups) {
          this.tradingSessionGroups = tradingSessionGroups;
          if (tradingSessionGroups != null) {
              noTradingSessions = new Integer(tradingSessionGroups.length);
          }
      }
      @Override
      public TradingSessionGroup addTradingSessionGroup() {
          TradingSessionGroup group = new TradingSessionGroup43(new FragmentContext(sessionCharset, messageEncoding, validateRequired));
          List<TradingSessionGroup> groups = new ArrayList<TradingSessionGroup>();
          if (tradingSessionGroups != null && tradingSessionGroups.length > 0) {
              groups = new ArrayList<TradingSessionGroup>(Arrays.asList(tradingSessionGroups));
          }
          groups.add(group);
          tradingSessionGroups = groups.toArray(new TradingSessionGroup[groups.size()]);
          noTradingSessions = new Integer(tradingSessionGroups.length);
  
          return group;
      }
  
      @Override
      public TradingSessionGroup deleteTradingSessionGroup(int index) {
          TradingSessionGroup result = null;
          if (tradingSessionGroups != null && tradingSessionGroups.length > 0 && tradingSessionGroups.length > index) {
              List<TradingSessionGroup> groups = new ArrayList<TradingSessionGroup>(Arrays.asList(tradingSessionGroups));
              result = groups.remove(index);
              tradingSessionGroups = groups.toArray(new TradingSessionGroup[groups.size()]);
              if (tradingSessionGroups.length > 0) {
                  noTradingSessions = new Integer(tradingSessionGroups.length);
              } else {
                  tradingSessionGroups = null;
                  noTradingSessions = null;
              }
          }
  
          return result;
      }
  
      @Override
      public int clearTradingSessionGroups() {
          int result = 0;
          if (tradingSessionGroups != null && tradingSessionGroups.length > 0) {
              result = tradingSessionGroups.length;
              tradingSessionGroups = null;
              noTradingSessions = null;
          }
  
          return result;
      }
   
      @Override
      public Stipulations getStipulations() {
          return stipulations;
      }
  
      @Override
      public void setStipulations() {
          FragmentContext context = new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired);
          this.stipulations = new Stipulations43(context);
      }
  
      @Override
      public void clearStipulations() {
           this.stipulations = null;
      }
  
      public void setStipulations(Stipulations stipulations) {
          this.stipulations = stipulations;
      }
  
      public StipulationsGroup[] getStipulationsGroups() {
          return stipulations == null ? null : stipulations.getStipulationsGroups();
      }
  
      public void setStipulationsGroups(StipulationsGroup[] stipulationsGroups) {
          if (stipulationsGroups != null) {
              if (stipulations == null) {
                  setStipulations();
              }
              ((Stipulations43) stipulations).setStipulationsGroups(stipulationsGroups);
          }
      }
  
      @Override
      public SpreadOrBenchmarkCurveData getSpreadOrBenchmarkCurveData() {
          return spreadOrBenchmarkCurveData;
      }
  
      @Override
      public void setSpreadOrBenchmarkCurveData() {
          FragmentContext context = new FragmentContext(sessionCharset, messageEncoding, validateRequired);
          this.spreadOrBenchmarkCurveData = new SpreadOrBenchmarkCurveData43(context);
      }
  
      @Override
      public void clearSpreadOrBenchmarkCurveData() {
          this.spreadOrBenchmarkCurveData = null;
      }
  
      public void setSpreadOrBenchmarkCurveData(SpreadOrBenchmarkCurveData spreadOrBenchmarkCurveData) {
          this.spreadOrBenchmarkCurveData = spreadOrBenchmarkCurveData;
      }
  
      @Override
      public YieldData getYieldData() {
          return yieldData;
      }
  
      @Override
      public void setYieldData() {
          FragmentContext context = new FragmentContext(sessionCharset, messageEncoding, validateRequired);
          this.yieldData = new YieldData43(context);
      }
  
      @Override
      public void clearYieldData() {
          this.yieldData = null;
      }
  
      public void setYieldData(YieldData yieldData) {
          this.yieldData = yieldData;
      }
  
      @Override
      public Double getPegOffsetValue() {
          return pegOffsetValue;
      }
  
      @Override
      public void setPegOffsetValue(Double pegOffsetValue) {
          this.pegOffsetValue = pegOffsetValue;
      }
  
      @Override
      public DiscretionInst getDiscretionInst() {
          return discretionInst;
      }
  
      @Override
      public void setDiscretionInst(DiscretionInst discretionInst) {
          this.discretionInst = discretionInst;
      }
  
      @Override
      public Double getDiscretionOffsetValue() {
          return discretionOffsetValue;
      }
  
      @Override
      public void setDiscretionOffsetValue(Double discretionOffsetValue) {
          this.discretionOffsetValue = discretionOffsetValue;
      }
  
      @Override
      public Double getAccruedInterestRate() {
          return accruedInterestRate;
      }
  
      @Override
      public void setAccruedInterestRate(Double accruedInterestRate) {
          this.accruedInterestRate = accruedInterestRate;
      }
  
      @Override
      public Double getAccruedInterestAmt() {
          return accruedInterestAmt;
      }
  
      @Override
      public void setAccruedInterestAmt(Double accruedInterestAmt) {
          this.accruedInterestAmt = accruedInterestAmt;
      }
  
      @Override
      public Double getNetMoney() {
          return netMoney;
      }
  
      @Override
      public void setNetMoney(Double netMoney) {
          this.netMoney = netMoney;
      }
  
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="Protected Methods">
  
      @Override
      protected void validateRequiredTags() throws TagNotPresentException {
          StringBuilder errorMsg = new StringBuilder("Tag value(s) for");
          boolean hasMissingTag = false;
          if (crossID == null || crossID.trim().isEmpty()) {
              errorMsg.append(" [CrossID]");
              hasMissingTag = true;
          }
          if (crossType == null) {
              errorMsg.append(" [CrossType]");
              hasMissingTag = true;
          }
          if (crossPrioritization == null) {
              errorMsg.append(" [CrossPrioritization]");
              hasMissingTag = true;
          }
          if (noSides == null || sideCrossOrdModGroups == null || noSides.intValue() == 0) {
              errorMsg.append(" [NoSides]");
              hasMissingTag = true;
          }
          if (instrument == null || instrument.getSymbol() == null) {
              errorMsg.append(" [Symbol]");
              hasMissingTag = true;
          }
          if (handlInst == null) {
              errorMsg.append(" [HandlInst]");
              hasMissingTag = true;
          }
          if (transactTime == null) {
              errorMsg.append(" [TransactTime]");
              hasMissingTag = true;
          }
          if (ordType == null) {
              errorMsg.append(" [OrdType]");
              hasMissingTag = true;
          }
          errorMsg.append(" is missing.");
          if (hasMissingTag) {
              throw new TagNotPresentException(errorMsg.toString());
          }
      }
  
      @Override
      protected byte[] encodeFragmentSecured(boolean secured) throws TagNotPresentException, BadFormatMsgException {
          byte[] result = new byte[0];
          ByteArrayOutputStream bao = new ByteArrayOutputStream();
          try {
              if (MsgUtil.isTagInList(TagNum.CrossID, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.CrossID, crossID);
              }
              if (crossType != null && MsgUtil.isTagInList(TagNum.CrossType, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.CrossType, crossType.getValue());
              }
              if (crossPrioritization != null && MsgUtil.isTagInList(TagNum.CrossPrioritization, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.CrossPrioritization, crossPrioritization.getValue());
              }
              if (noSides != null && MsgUtil.isTagInList(TagNum.NoSides, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.NoSides, noSides);
                  if (sideCrossOrdModGroups != null && sideCrossOrdModGroups.length == noSides.intValue()) {
                      for (int i = 0; i < noSides.intValue(); i++) {
                          if (sideCrossOrdModGroups[i] != null) {
                              bao.write(sideCrossOrdModGroups[i].encode(getMsgSecureTypeForFlag(secured)));
                          }
                      }
                  } else {
                      String error = "SideCrossOrdModGroups field has been set but there is no data or the number of groups does not match.";
                      LOGGER.severe(error);
                      throw new BadFormatMsgException(SessionRejectReason.IncorrectCountForGroups, getHeader().getMsgType(),
                              TagNum.NoSides.getValue(), error);
                  }
              }
              if (instrument != null) {
                  bao.write(instrument.encode(getMsgSecureTypeForFlag(secured)));
              }
              if (MsgUtil.isTagInList(TagNum.SettlType, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.SettlType, settlType);
              }
              if (MsgUtil.isTagInList(TagNum.SettlDate, SECURED_TAGS, secured)) {
                  TagEncoder.encodeDate(bao, TagNum.SettlDate, settlDate);
              }
              if (handlInst != null && MsgUtil.isTagInList(TagNum.HandlInst, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.HandlInst, handlInst.getValue());
              }
              if (MsgUtil.isTagInList(TagNum.ExecInst, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.ExecInst, execInst);
              }
              if (MsgUtil.isTagInList(TagNum.MinQty, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.MinQty, minQty);
              }
              if (MsgUtil.isTagInList(TagNum.MaxFloor, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.MaxFloor, maxFloor);
              }
              if (MsgUtil.isTagInList(TagNum.ExDestination, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.ExDestination, exDestination);
              }
              if (noTradingSessions != null && MsgUtil.isTagInList(TagNum.NoTradingSessions, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.NoTradingSessions, noTradingSessions);
                  if (tradingSessionGroups != null && tradingSessionGroups.length == noTradingSessions.intValue()) {
                      for (int i = 0; i < noTradingSessions.intValue(); i++) {
                          if (tradingSessionGroups[i] != null) {
                              bao.write(tradingSessionGroups[i].encode(getMsgSecureTypeForFlag(secured)));
                          }
                      }
                  } else {
                      String error = "TradingSessionsGroup field has been set but there is no data or the number of groups does not match.";
                      LOGGER.severe(error);
                      throw new BadFormatMsgException(SessionRejectReason.IncorrectCountForGroups, getHeader().getMsgType(),
                              TagNum.NoTradingSessions.getValue(), error);
                  }
              }
              if (processCode != null && MsgUtil.isTagInList(TagNum.ProcessCode, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.ProcessCode, processCode.getValue());
              }
              if (MsgUtil.isTagInList(TagNum.PrevClosePx, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.PrevClosePx, prevClosePx);
              }
              if (MsgUtil.isTagInList(TagNum.LocateReqd, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.LocateReqd, locateReqd);
              }
              if (MsgUtil.isTagInList(TagNum.TransactTime, SECURED_TAGS, secured)) {
                  TagEncoder.encodeUtcTimestamp(bao, TagNum.TransactTime, transactTime);
              }
              if (stipulations != null) {
                  bao.write(stipulations.encode(getMsgSecureTypeForFlag(secured)));
              }
              if (ordType != null && MsgUtil.isTagInList(TagNum.OrdType, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.OrdType, ordType.getValue());
              }
              if (priceType != null && MsgUtil.isTagInList(TagNum.PriceType, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.PriceType, priceType.getValue());
              }
              if (MsgUtil.isTagInList(TagNum.Price, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.Price, price);
              }
              if (MsgUtil.isTagInList(TagNum.StopPx, SECURED_TAGS, secured)) {
                  TagEncoder.encode(bao, TagNum.StopPx, stopPx);
              }
              if (spreadOrBenchmarkCurveData != null) {
                  bao.write(spreadOrBenchmarkCurveData.encode(getMsgSecureTypeForFlag(secured)));
              }
              if (yieldData != null) {
                  bao.write(yieldData.encode(getMsgSecureTypeForFlag(secured)));
              }
              if (currency != null && MsgUtil.isTagInList(TagNum.Currency, SECURED_TAGS, secured)) {
  