gt:             if (linesOfTextGroups.length > 0) {
context: /*
   *   Copyright (c) 2006-2016 Marvisan Pty. Ltd. All rights reserved.
   *               Use is subject to license terms.
   */
  
  /*
   * EmailMsg42.java
   *
   * $Id: EmailMsg42.java,v 1.11 2011-04-14 23:44:39 vrotaru Exp $
   */
  package net.hades.fix.message.impl.v42;
  
  import net.hades.fix.message.EmailMsg;
  import net.hades.fix.message.FragmentContext;
  import net.hades.fix.message.Header;
  import net.hades.fix.message.exception.InvalidMsgException;
  import net.hades.fix.message.group.RelatedSymbolGroup;
  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.ArrayList;
  import java.util.Arrays;
  import java.util.Date;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  
  import net.hades.fix.message.exception.BadFormatMsgException;
  import net.hades.fix.message.exception.TagNotPresentException;
  import net.hades.fix.message.group.LinesOfTextGroup;
  import net.hades.fix.message.group.RoutingIDGroup;
  import net.hades.fix.message.group.impl.v42.LinesOfTextGroup42;
  import net.hades.fix.message.group.impl.v42.RelatedSymbolGroup42;
  import net.hades.fix.message.group.impl.v42.RoutingIDGroup42;
  import net.hades.fix.message.type.BeginString;
  import net.hades.fix.message.type.EmailType;
  import net.hades.fix.message.type.TagNum;
  import net.hades.fix.message.util.TagEncoder;
  import java.util.logging.Level;
  
  /**
   * FIX version 4.2 EmailMsg implementation.
   *
   * @author <a href="mailto:support@marvisan.com">Support Team</a>
   * @version $Revision: 1.11 $
   * @created 01/04/2009, 8:41:14 AM
   */
  public class EmailMsg42 extends EmailMsg {
  
      // <editor-fold defaultstate="collapsed" desc="Constants">
  
      private static final long serialVersionUID = 1L;
  
      protected static final Set<Integer> START_COMP_TAGS;
  
      protected static final Set<Integer> ALL_TAGS;
      
      protected static final Set<Integer> LINES_OF_TEXT_GROUP_TAGS = new LinesOfTextGroup42().getFragmentTags();
      protected static final Set<Integer> RELATED_SYM_GROUP_TAGS = new RelatedSymbolGroup42().getFragmentTags();
      protected static final Set<Integer> ROUTING_ID_GROUP_TAGS = new RoutingIDGroup42().getFragmentTags();
  
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="Static Block">
  
      static {
          ALL_TAGS = new HashSet<Integer>(TAGS);
          ALL_TAGS.addAll(START_DATA_TAGS);
          ALL_TAGS.addAll(LINES_OF_TEXT_GROUP_TAGS);
          ALL_TAGS.addAll(RELATED_SYM_GROUP_TAGS);
          ALL_TAGS.addAll(ROUTING_ID_GROUP_TAGS);
          START_COMP_TAGS = new HashSet<Integer>(LINES_OF_TEXT_GROUP_TAGS);
          START_COMP_TAGS.addAll(RELATED_SYM_GROUP_TAGS);
          START_COMP_TAGS.addAll(ROUTING_ID_GROUP_TAGS);
      }
  
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="Attributes">
  
      protected Set<Integer> STANDARD_SECURED_TAGS = ALL_TAGS;
  
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="Constructors">
  
      public EmailMsg42() {
          super();
      }
  
      public EmailMsg42(Header header, ByteBuffer rawMsg)
      throws InvalidMsgException, TagNotPresentException, BadFormatMsgException {
          super(header, rawMsg);
          SECURED_TAGS = STANDARD_SECURED_TAGS;
      }
  
      public EmailMsg42(BeginString beginString) throws InvalidMsgException {
          super(beginString);
          SECURED_TAGS = STANDARD_SECURED_TAGS;
      }
  
      public EmailMsg42(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> getFragmentAllTags() {
          return ALL_TAGS;
      }
  
      // ACCESSOR METHODS
      //////////////////////////////////////////
  
      @Override
      public String getEmailThreadID() {
          return emailThreadID;
      }
  
      @Override
      public void setEmailThreadID(String emailThreadID) {
          this.emailThreadID = emailThreadID;
      }
  
      @Override
      public EmailType getEmailType() {
          return emailType;
      }
  
      @Override
      public void setEmailType(EmailType emailType) {
          this.emailType = emailType;
      }
  
      @Override
      public Date getOrigTime() {
          return origTime;
      }
  
      @Override
      public void setOrigTime(Date origTime) {
          this.origTime = origTime;
      }
  
      @Override
      public String getSubject() {
          return subject;
      }
  
      @Override
      public void setSubject(String subject) {
          this.subject = subject;
      }
  
      @Override
      public Integer getEncodedSubjectLen() {
          return encodedSubjectLen;
      }
  
      @Override
      public void setEncodedSubjectLen(Integer encodedSubjectLen) {
          this.encodedSubjectLen = encodedSubjectLen;
      }
  
      @Override
      public byte[] getEncodedSubject() {
          return encodedSubject;
      }
  
      @Override
      public void setEncodedSubject(byte[] encodedSubject) {
          this.encodedSubject = encodedSubject;
          if (encodedSubjectLen == null) {
              encodedSubjectLen = new Integer(encodedSubject.length);
          }
      }
  
      @Override
      public Integer getNoRoutingIDs() {
          return noRoutingIDs;
      }
  
      @Override
      public void setNoRoutingIDs(Integer noRoutingIDs) {
          this.noRoutingIDs = noRoutingIDs;
          if (noRoutingIDs != null) {
              routingIDGroups = new RoutingIDGroup[noRoutingIDs.intValue()];
              FragmentContext context = new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired);
              for (int i = 0; i < routingIDGroups.length; i++) {
                  routingIDGroups[i] = new RoutingIDGroup42(context);
              }
          }
      }
  
      @Override
      public RoutingIDGroup[] getRoutingIDGroups() {
          return routingIDGroups;
      }
  
      @Override
      public RoutingIDGroup addRoutingIDGroup() {
  
          RoutingIDGroup group = new RoutingIDGroup42(new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired));
          List<RoutingIDGroup> groups = new ArrayList<RoutingIDGroup>();
          if (routingIDGroups != null && routingIDGroups.length > 0) {
              groups = new ArrayList<RoutingIDGroup>(Arrays.asList(routingIDGroups));
          }
          groups.add(group);
          routingIDGroups = groups.toArray(new RoutingIDGroup[groups.size()]);
          noRoutingIDs = new Integer(routingIDGroups.length);
  
          return group;
      }
  
      @Override
      public RoutingIDGroup deleteRoutingIDGroup(int index) {
         RoutingIDGroup result = null;
  
          if (routingIDGroups != null && routingIDGroups.length > 0 && routingIDGroups.length > index) {
              List<RoutingIDGroup> groups = new ArrayList<RoutingIDGroup>(Arrays.asList(routingIDGroups));
              result = groups.remove(index);
              routingIDGroups = groups.toArray(new RoutingIDGroup[groups.size()]);
              if (routingIDGroups.length > 0) {
                  noRoutingIDs = new Integer(routingIDGroups.length);
              } else {
                  routingIDGroups = null;
                  noRoutingIDs = null;
              }
          }
  
          return result;
      }
  
      @Override
      public int clearRoutingIDGroups() {
          int result = 0;
          if (routingIDGroups != null && routingIDGroups.length > 0) {
              result = routingIDGroups.length;
              routingIDGroups = null;
              noRoutingIDs = null;
          }
  
          return result;
      }
  
      @Override
      public Integer getNoRelatedSyms() {
          return noRelatedSyms;
      }
  
      @Override
      public void setNoRelatedSyms(Integer noRelatedSyms) {
          this.noRelatedSyms = noRelatedSyms;
          if (noRelatedSyms != null) {
              relatedSymGroups = new RelatedSymbolGroup[noRelatedSyms.intValue()];
              FragmentContext context = new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired);
              for (int i = 0; i < relatedSymGroups.length; i++) {
                  relatedSymGroups[i] = new RelatedSymbolGroup42(context);
              }
          }
      }
      
      @Override
      public RelatedSymbolGroup[] getRelatedSymGroups() {
          return relatedSymGroups;
      }
  
      @Override
      public RelatedSymbolGroup addRelatedSymGroup() {
  
          RelatedSymbolGroup group = new RelatedSymbolGroup42(new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired));
          List<RelatedSymbolGroup> groups = new ArrayList<RelatedSymbolGroup>();
          if (relatedSymGroups != null && relatedSymGroups.length > 0) {
              groups = new ArrayList<RelatedSymbolGroup>(Arrays.asList(relatedSymGroups));
          }
          groups.add(group);
          relatedSymGroups = groups.toArray(new RelatedSymbolGroup[groups.size()]);
          noRelatedSyms = new Integer(relatedSymGroups.length);
  
          return group;
      }
  
      @Override
      public RelatedSymbolGroup deleteRelatedSymGroup(int index) {
          RelatedSymbolGroup result = null;
  
          if (relatedSymGroups != null && relatedSymGroups.length > 0 && relatedSymGroups.length > index) {
              List<RelatedSymbolGroup> groups = new ArrayList<RelatedSymbolGroup>(Arrays.asList(relatedSymGroups));
              result = groups.remove(index);
              relatedSymGroups = groups.toArray(new RelatedSymbolGroup[groups.size()]);
              if (relatedSymGroups.length > 0) {
                  noRelatedSyms = new Integer(relatedSymGroups.length);
              } else {
                  relatedSymGroups = null;
                  noRelatedSyms = null;
              }
          }
  
          return result;
      }
  
      @Override
      public int clearRelatedSymGroups() {
          int result = 0;
          if (relatedSymGroups != null && relatedSymGroups.length > 0) {
              result = relatedSymGroups.length;
              relatedSymGroups = null;
              noRelatedSyms = null;
          }
  
          return result;
      }
  
      @Override
      public String getOrderID() {
          return orderID;
      }
  
      @Override
      public void setOrderID(String orderID) {
          this.orderID = orderID;
      }
  
      @Override
      public String getClOrdID() {
          return clOrdID;
      }
  
      @Override
      public void setClOrdID(String clOrdID) {
          this.clOrdID = clOrdID;
      }
  
      @Override
      public Integer getNoLinesOfText() {
          return noLinesOfText;
      }
  
      @Override
      public void setNoLinesOfText(Integer noLinesOfText) {
          this.noLinesOfText = noLinesOfText;
          if (noLinesOfText != null) {
              linesOfTextGroups = new LinesOfTextGroup[noLinesOfText.intValue()];
              FragmentContext context = new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired);
              for (int i = 0; i < linesOfTextGroups.length; i++) {
                  linesOfTextGroups[i] = new LinesOfTextGroup42(context);
              }
          }
      }
  
      @Override
      public LinesOfTextGroup[] getLinesOfTextGroups() {
          return linesOfTextGroups;
      }
  
      @Override
      public LinesOfTextGroup addLinesOfTextGroup() {
          LinesOfTextGroup group = new LinesOfTextGroup42(new FragmentContext(sessionCharset, messageEncoding, encryptionRequired, crypter, validateRequired));
          List<LinesOfTextGroup> groups = new ArrayList<LinesOfTextGroup>();
          if (linesOfTextGroups != null && linesOfTextGroups.length > 0) {
              groups = new ArrayList<LinesOfTextGroup>(Arrays.asList(linesOfTextGroups));
          }
          groups.add(group);
          linesOfTextGroups = groups.toArray(new LinesOfTextGroup[groups.size()]);
          noLinesOfText = new Integer(linesOfTextGroups.length);
  
          return group;
      }
  
      @Override
      public LinesOfTextGroup deleteLinesOfTextGroup(int index) {
          LinesOfTextGroup result = null;
          if (linesOfTextGroups != null && linesOfTextGroups.length > 0 && linesOfTextGroups.length > index) {
              List<LinesOfTextGroup> groups = new ArrayList<LinesOfTextGroup>(Arrays.asList(linesOfTextGroups));
              result = groups.remove(index);
              linesOfTextGroups = groups.toArray(new LinesOfTextGroup[groups.size()]);
  