gt:           irep_field = (IrepField) irep_node;
context: /*
   * =============================================================================== / / Filename :
   * PalComp.jj / Module : PalComp / System : PAL / Author : Jianbin Zhao /
   * /================================================================================ / This file is
   * copyright and the property of Telecoms Network Test Division, / Agilent Technologies Ltd. It must
   * not be copied (in whole or in part), used / for manufacture or otherwise disclosed without prior
   * written consent. Any / copies of this file made by any method must also include a copy of this
   * legend. / Upon request this document shall be returned to the Quality Manager. / Uncontrolled
   * copies of this document are available on request from the Quality / Manager. There shall be no
   * exceptions to the terms and conditions set forth / herein except as authorised by the Quality
   * Manager. / / COPYRIGHT ASD, Agilent Technolgies 2006
   * ===============================================================================
   */
  
  package comp;
  
  import java.util.*;
  import irep.*;
  import main.PalSetting;
  
  public class ConverterMaster {
    public class BlockCaller {
      public Hashtable _callers = new Hashtable();
    }
  
    CompProtocol _protocol = null;
    Vector _nextLayerCalls = new Vector();
    Vector _nextLayerAttrs = new Vector();
    boolean _haveSortBlocks = false;
    HashMap<Integer, IrepBlock> _trees = new HashMap<Integer, IrepBlock>();
    Hashtable _parsedBlocks = new Hashtable();
    Hashtable _palBlocks = new Hashtable();
    Hashtable _seqs = new Hashtable();
    Hashtable _seqOfs = new Hashtable();
    Hashtable _sets = new Hashtable();
    Hashtable _setOfs = new Hashtable();
    Hashtable _components = new Hashtable();
    Hashtable _calledCaller = new Hashtable();
    Hashtable _funcNodes = new Hashtable();
    Hashtable _compToIrep = new Hashtable();
    Hashtable _irepToComp = new Hashtable();
    Hashtable _callToBlock = new Hashtable();
    int _pass = 0;
    int _blockIndex = 0;
    Hashtable _createdBlocks = new Hashtable();
  
    public IrepProtocol Convert(CompProtocol protocol, VarList global_vars, Vector select_list,
        Vector seg_fmts, IrepSegList seg_list, RegexList reg_exprs, Vector field_refs,
        PalSetting pal_settings, boolean is_lookahead, int appMasks, Hashtable anonRanges) {
      CompBlock prot_block = null;
      IrepProtocol irep_prot = null;
  
      _protocol = protocol;
  
      prot_block = (CompBlock) protocol.Blocks().get(0);
  
      _pass = 1;
      _parsedBlocks.clear();
      Gothrough(prot_block);
  
      // change for CR:IQ00204578
      if (PalComp._initBlock != null) {
        Gothrough(PalComp._initBlock);
      }
  
      _pass = 2;
      _parsedBlocks.clear();
      Gothrough(prot_block);
  
      // change for CR:IQ00204578
      if (PalComp._initBlock != null) {
        Gothrough(PalComp._initBlock);
      }
  
      BuildIrepTree();
  
      irep_prot =
          new IrepProtocol(_trees, global_vars.VarDefs(), select_list, seg_fmts, seg_list,
              reg_exprs.Regexs(), new Hashtable(), field_refs);
      irep_prot._isLookAhead = is_lookahead;
      irep_prot.SetAppMasks(appMasks);
      irep_prot._anonRanges = anonRanges;
  
      // change for CR:IQ00204578
      if (PalComp._initBlock != null) {
        IrepTlv init = (IrepTlv) _compToIrep.get(PalComp._initBlock);
        if (init != null) {
          irep_prot.setInitBlock(init._nodeId);
        }
      }
  
      // set protocol block
      IrepTlv prot = (IrepTlv)_compToIrep.get(_protocol.Blocks().get(0));
      if (prot != null) {
        irep_prot.set_initNodeId(prot._nodeId);
      }
  
      return irep_prot;
    }
  
    public void CheckBlockAttributes(CompBlock block) {
      // 1. ORDER VARIABLE and CHOOSE can not be present at the same block
      CompBlockAttr attr = null;
      String err_msg = "";
      int i;
      CompNode comp_node;
      CompBlockCall block_call;
  
      attr = block.Attrs();
      if (attr._orderType == CompBlockAttr.ATTR_ORDER_VARIABLE
          && attr.ChooseType() != CompBlockAttr.ATTR_VALUE_UNKNOWN) {
        err_msg =
            "Error at line number " + block._lineNumber + " in block " + block.Name()
                + "; ORDER VARIABLE and CHOOSE can not be present at the same block";
  
        System.out.println(err_msg);
      }
  
      // 2. if a block has choose 1 attribute, then all its contents should be block calls and
      // those blocks calls (or its called block) must have present if attribute
      if (attr.ChooseType() == CompBlockAttr.ATTR_CHOOSE_1) {
        for (i = 0; i < block.Content().size(); i++) {
          comp_node = (CompNode) block.Content().get(i);
  
          if (comp_node.NodeType() != CompNode.COMP_NODE_TYPE_BLOCK_CALL) {
            err_msg =
                "Error at line number " + block._lineNumber + " in block " + block.Name()
                    + "; all the contents of choose block should be block calls.";
  
            System.out.println(err_msg);
          } else {
            block_call = (CompBlockCall) comp_node;
            if (block_call._calledBlock.Attrs().PresentIfType() == CompBlockAttr.ATTR_VALUE_UNKNOWN) {
              err_msg =
                  "Error at line number " + block._lineNumber + " in block " + block.Name()
                      + "; block call:" + block_call.Name() + " should have a present if attribute.";
  
              System.out.println(err_msg);
            }
          }
        }
      }
    }
  
  
    public void Gothrough(CompBlock block) {
      CompBlockCall call = null;
      CompBlockAttr attr = null;
      Iterator it = null;
      CompNode node = null;
  
      if (_parsedBlocks.containsKey(block)) {
        return;
      }
  
      if (_pass == 1) {
        CheckBlockAttributes(block);
      }
  
      _parsedBlocks.put(block, block);
  
      attr = block.Attrs();
  
      switch (attr.SizeType()) {
        case CompBlockAttr.ATTR_SIZE_TERMINATED:
          call = (CompBlockCall) attr.SizeAttr();
          Gothrough(call._calledBlock);
          break;
  
        case CompBlockAttr.ATTR_SIZE_IF:
          if (attr.SizeThenType() == CompBlockAttr.ATTR_SIZE_TERMINATED) {
            call = (CompBlockCall) attr.SizeThenAttr();
  
            if (_pass == 1) {
              BindCalledCaller(call._calledBlock, block);
            }
  
            Gothrough(call._calledBlock);
          }
  
          if (attr.SizeElseType() == CompBlockAttr.ATTR_SIZE_TERMINATED) {
            call = (CompBlockCall) attr.SizeThenAttr();
  
            if (_pass == 1) {
              BindCalledCaller(call._calledBlock, block);
            }
  
            Gothrough(call._calledBlock);
          }
  
          break;
      }
  
      if (_pass == 1) {
        for (it = block.Content().iterator(); it.hasNext();) {
          node = (CompNode) it.next();
          Gothrough(block, node);
        }
  
        DetermineBlockType(block);
      } else {
        ConvertBlock(block);
      }
    }
  
    void BindCalledCaller(CompBlock called, CompBlock caller) {
      BlockCaller block_caller = null;
  
      if (_calledCaller.containsKey(called)) {
        block_caller = (BlockCaller) _calledCaller.get(called);
        block_caller._callers.put(caller, caller);
      } else {
        block_caller = new BlockCaller();
        block_caller._callers.put(caller, caller);
        _calledCaller.put(called, block_caller);
      }
    }
  
    void Gothrough(CompBlock caller, CompNode node) {
      CompBlockCall call = null;
  
      switch (node.NodeType()) {
        case CompNode.COMP_NODE_TYPE_INLINE_BLOCK:
        case CompNode.COMP_NODE_TYPE_PROTOBLOCK_CALL:
          if (_pass == 1) {
            BindCalledCaller((CompBlock) node, caller);
          }
  
          Gothrough((CompBlock) node);
          break;
  
        case CompNode.COMP_NODE_TYPE_BLOCK_CALL:
        case CompNode.COMP_NODE_TYPE_NEXT_LAYER_CALL:
          call = (CompBlockCall) node;
  
          if (_pass == 1) {
            BindCalledCaller(call._calledBlock, caller);
          }
  
          Gothrough(call._calledBlock);
  
          break;
      }
    }
  
    boolean CheckAnchorApplicationAtFirst(CompBlock comp_block) {
      boolean has_tag_or_len = false;
      int i = 0;
      CompField comp_field = null;
      CompNode comp_node = null;
  
      for (i = 0; i < comp_block.Content().size(); i++) {
        comp_node = (CompNode) comp_block.Content().get(i);
  
        switch (comp_node.NodeType()) {
          case CompNode.COMP_NODE_TYPE_FIELD:
            comp_field = (CompField) comp_node;
  
            if (comp_field.FieldType() == CompField.FIELD_TYPE_TAG
                || comp_field.FieldType() == CompField.FIELD_TYPE_TAG_CONTENTS
                || comp_field.FieldType() == CompField.FIELD_TYPE_LENGTH
                || comp_field.FieldType() == CompField.FIELD_TYPE_LENGHT_CONTENTS
                || comp_field.FieldType() == CompField.FIELD_TYPE_BER_LENGTH) {
              has_tag_or_len = true;
            }
            break;
  
          case CompNode.COMP_NODE_TYPE_ANCHOR:
            if (((CompAnchor) comp_node)._anchorType == CompAnchor.COMP_NODE_TYPE_APP_SPEC) {
              if (!has_tag_or_len) {
                return true;
              }
            }
            break;
          default:
            break;
        }
      }
  
      return false;
    }
  
    public void DetermineBlockType(CompBlock block) {
      CompNode node = null;
      CompBlockAttr attr = null;
      CompField fld = null;
      CompBlockCall call = null;
      int i = 0;
      int component_num = 0;
      CompNode last_comp = null;
      int if_level = 0;
      CompBlock child_block = null;
  
      attr = block.Attrs();
  
      // if anchor application is before tag,length, convert to pal block
      if (CheckAnchorApplicationAtFirst(block)) {
        _palBlocks.put(block, block);
        return;
      }
  
      if (attr.ChooseType() != CompBlockAttr.ATTR_VALUE_UNKNOWN || block._name.equals("NEXT_LAYER")) {
        _palBlocks.put(block, block);
        return;
      }
  
      // search tags
      search_tags: for (i = 0; i < block.Content().size(); i++) {
        node = (CompNode) block.Content().get(i);
  
        switch (node.NodeType()) {
          case CompNode.COMP_NODE_TYPE_BLOCK_CALL:
          case CompNode.COMP_NODE_TYPE_NEXT_LAYER_CALL:
          case CompNode.COMP_NODE_TYPE_INLINE_BLOCK:
            break search_tags;
  
          case CompNode.COMP_NODE_TYPE_FIELD:
            fld = (CompField) node;
  
            if (if_level != 0) {
              break search_tags;
            }
  
            if (fld.FieldType() == CompField.FIELD_TYPE_TAG
                || fld.FieldType() == CompField.FIELD_TYPE_TAG_CONTENTS) {} else {
              break search_tags;
            }
  
            break;
  
          case CompNode.COMP_NODE_TYPE_IF_BEGIN:
            if_level++;
            break;
  
          case CompNode.COMP_NODE_TYPE_IF_END:
            if_level--;
            break;
        }
      }
  
      // search length
      search_length: for (/* continue */; i < block.Content().size(); i++) {
        node = (CompNode) block.Content().get(i);
  
        switch (node.NodeType()) {
          case CompNode.COMP_NODE_TYPE_BLOCK_CALL:
          case CompNode.COMP_NODE_TYPE_NEXT_LAYER_CALL:
          case CompNode.COMP_NODE_TYPE_INLINE_BLOCK:
            break search_length;
  
          case CompNode.COMP_NODE_TYPE_FIELD:
            fld = (CompField) node;
  
            if (if_level != 0) {
              break search_length;
            }
  
            if (fld.FieldType() == CompField.FIELD_TYPE_LENGTH
                || fld.FieldType() == CompField.FIELD_TYPE_LENGHT_CONTENTS
                || fld.FieldType() == CompField.FIELD_TYPE_BER_LENGTH) {} else {
              break search_length;
            }
            break;
  
          case CompNode.COMP_NODE_TYPE_IF_BEGIN:
            if_level++;
            break;
  
          case CompNode.COMP_NODE_TYPE_IF_END:
            if_level--;
            break;
        }
      }
  
      search_value: for (/* continue */; i < block.Content().size(); i++) {
        node = (CompNode) block.Content().get(i);
  
        switch (node.NodeType()) {
          case CompNode.COMP_NODE_TYPE_FIELD:
            component_num++;
            last_comp = node;
  
            fld = (CompField) node;
  
            if (fld.FieldType() == CompField.FIELD_TYPE_TAG
                || fld.FieldType() == CompField.FIELD_TYPE_TAG_CONTENTS) {
              _palBlocks.put(block, block);
              return;
            }
  
            if (fld.FieldType() == CompField.FIELD_TYPE_LENGTH
                || fld.FieldType() == CompField.FIELD_TYPE_LENGHT_CONTENTS
                || fld.FieldType() == CompField.FIELD_TYPE_BER_LENGTH) {
              _palBlocks.put(block, block);
              return;
            }
            break;
  
          case CompNode.COMP_NODE_TYPE_INLINE_BLOCK:
          case CompNode.COMP_NODE_TYPE_PROTOBLOCK_CALL:
          case CompNode.COMP_NODE_TYPE_BLOCK_CALL:
          case CompNode.COMP_NODE_TYPE_NEXT_LAYER_CALL:
            component_num++;
            last_comp = node;
            break;
        }
      }
  
      if (component_num > 1 || component_num == 0 /* XXX */) {
        _seqs.put(block, block);
        return;
      }
  
      attr = null;
  
      switch (last_comp.NodeType()) {
        case CompNode.COMP_NODE_TYPE_INLINE_BLOCK:
        case CompNode.COMP_NODE_TYPE_PROTOBLOCK_CALL:
          child_block = (CompBlock) last_comp;
          attr = child_block.Attrs();
          break;
  
        case CompNode.COMP_NODE_TYPE_BLOCK_CALL:
        case CompNode.COMP_NODE_TYPE_NEXT_LAYER_CALL:
          call = (CompBlockCall) last_comp;
          attr = call.Attrs();
          break;
      }
  
      if (attr == null || attr._positionPointerId != -1
          || attr._sortType == CompBlockAttr.ATTR_SORT_REVERSED) {
        if (attr != null
            && (attr._orderType == CompBlockAttr.ATTR_ORDER_VARIABLE || attr._countAttr.size() != 0)) {
          _palBlocks.put(block, block);
        } else {
          _components.put(block, block);
        }
  
        return;
      }
  
      if (attr._orderType != CompBlockAttr.ATTR_ORDER_VARIABLE) {
        if (attr._countAttr.size() != 0) {
          _seqOfs.put(block, block);
        } else {
          _components.put(block, block);
        }
      } else {
        if (attr._sizeType != CompBlockAttr.ATTR_SIZE_CONSTRUCTED
            || attr._presentIfType != CompBlockAttr.ATTR_VALUE_UNKNOWN
            || attr._positionPointerId != -1 || attr._sortType != CompBlockAttr.ATTR_SORT_NULL
            || attr._align != 1 || attr._pad != 0 /*
                                                   * || attr._encodingRule !=
                                                   * PalOption.PAL_OPTION_UNKNOWN ||
                                                   * attr._encodingUnit !=
                                                   * PalOption.PAL_OPTION_UNKNOWN ||
                                                   * attr._octetAligned !=
                                                   * PalOption.PAL_OPTION_UNKNOWN
                                                   */) {
          _palBlocks.put(block, block);
        } else if (attr._countAttr.size() == 0) {
          _sets.put(block, block);
        } else {
          _setOfs.put(block, block);
        }
      }
    }
  
    public IrepBlock ConvertBlock(CompBlock block) {
      if (_palBlocks.containsKey(block)) {
        return ConvertToPalBlock(block);
      } else if (_seqs.containsKey(block)) {
        return ConvertToSeq(block);
      } else if (_seqOfs.containsKey(block)) {
        return ConvertToSeqOf(block);
      } else if (_sets.containsKey(block)) {
        return ConvertToSet(block);
      } else if (_setOfs.containsKey(block)) {
        return ConvertToSetOf(block);
      } else if (_components.containsKey(block)) {
        return ConvertToComponent(block);
      }
  
      return null;
    }
  
    public IrepBlock ConvertToSeqOf(CompBlock block) {
      Vector children = null;
      IrepSeqOf seq_of = new IrepSeqOf();
      Iterator it = null;
      CompNode node = null;
  
      _compToIrep.put(block, seq_of);
      _irepToComp.put(seq_of, block);
  
      // seq_of._nodeId = _blockIndex++;
  
      SetupTlvAttributes(seq_of, block);
  
      for (it = block.Content().iterator(); it.hasNext();) {
        node = (CompNode) it.next();
        Gothrough(block, node);
      }
  
      children = ConvertChildren(seq_of, block);
  
      DetermineSeqOfChildren(seq_of, children);
  
      return seq_of;
    }
  
    IrepBlock ConvertToSetOf(CompBlock block) {
      Vector children = null;
      IrepSetOf set_of = new IrepSetOf();
      Iterator it = null;
      CompNode node = null;
  
      _compToIrep.put(block, set_of);
      _irepToComp.put(set_of, block);
  
      // set_of._nodeId = _blockIndex++;
  
      SetupTlvAttributes(set_of, block);
  
      for (it = block.Content().iterator(); it.hasNext();) {
        node = (CompNode) it.next();
        Gothrough(block, node);
      }
  
      children = ConvertChildren(set_of, block);
  
      DetermineSetOfChildren(set_of, children);
  
      return set_of;
    }
  
    IrepBlock ConvertToComponent(CompBlock block) {
      Vector children = null;
      IrepComponent comp = new IrepComponent();
      Iterator it = null;
      CompNode node = null;
  
      _compToIrep.put(block, comp);
      _irepToComp.put(comp, block);
  
      // comp._nodeId = _blockIndex++;
  
      SetupTlvAttributes(comp, block);
  
      for (it = block.Content().iterator(); it.hasNext();) {
        node = (CompNode) it.next();
        Gothrough(block, node);
      }
  
      children = ConvertChildren(comp, block);
  
      DetermineComponentChildren(comp, children);
  
      return comp;
    }
  
    IrepBlock ConvertToSeq(CompBlock block) {
      Vector children = null;
      IrepSeq seq = new IrepSeq();
      Iterator it = null;
      CompNode node = null;
  
      _compToIrep.put(block, seq);
      _irepToComp.put(seq, block);
  
      // seq._nodeId = _blockIndex++;
  
      SetupTlvAttributes(seq, block);
  
      for (it = block.Content().iterator(); it.hasNext();) {
        node = (CompNode) it.next();
        Gothrough(block, node);
      }
  
      children = ConvertChildren(seq, block);
  
      DetermineSeqChildren(seq, children);
  
      return seq;
    }
  
    IrepBlock ConvertToSet(CompBlock block) {
      Vector children = null;
      IrepSet set = new IrepSet();
      Iterator it = null;
      CompNode node = null;
  
      _compToIrep.put(block, set);
      _irepToComp.put(set, block);
  
      // set._nodeId = _blockIndex++;
  
      SetupTlvAttributes(set, block);
  
      for (it = block.Content().iterator(); it.hasNext();) {
        node = (CompNode) it.next();
        Gothrough(block, node);
      }
  
      children = ConvertChildren(set, block);
  
      DetermineSetChildren(set, children);
  
      return set;
    }
  
    public IrepBlock ConvertToPalBlock(CompBlock block) {
      Vector children = null;
      IrepPalBlock pal_block = new IrepPalBlock();
      Iterator it = null;
      CompNode node = null;
      CompBlockAttr attr = null;
  
      _compToIrep.put(block, pal_block);
      _irepToComp.put(pal_block, block);
  
      // pal_block._nodeId = _blockIndex++;
  
      SetupTlvAttributes(pal_block, block);
  
      attr = block.Attrs();
      pal_block._chooseType = attr._chooseType;
      pal_block._chooseRange = attr._chooseRange;
      pal_block._chooseLayerId = attr._chooseLayerId; /* Enhanced for IQ00210285 */
      pal_block._chooseExpr = attr._chooseExpr;
  
      for (it = block.Content().iterator(); it.hasNext();) {
        node = (CompNode) it.next();
        Gothrough(block, node);
      }
  
      children = ConvertChildren(pal_block, block);
  
      DeterminePalBlockChildren(pal_block, children);
  
      return pal_block;
    }
  
    void AddFuncNode(IrepNode func_node) {
      _funcNodes.put(func_node, func_node);
    }
  
    boolean CanBeFunction(IrepTlv tlv) {
      boolean flag = false;
      IrepPalBlock pal_block = null;
  
      if (tlv._name.equals("NEXT_LAYER")) {
        flag = true;
      }
  
      if (tlv._isTermBlock) {
        flag = true;
      }
  
      if (tlv._numRefs > 0) {
        flag = true;
      }
  
      if (tlv._positionPointerId != -1) {
        flag = true;
      }
  
      if (tlv._sortType != IrepBlock.ATTR_SORT_NULL) {
        flag = true;
      }
  
      if (tlv._align != 1) {
        flag = true;
      }
  
      if (tlv._pad != 0) {
        flag = true;
      }
  
      if (tlv._sizeType != IrepTlv.ATTR_SIZE_CONSTRUCTED) {
        flag = true;
      }
  
      if (tlv._presentIfType != IrepTlv.ATTR_VALUE_UNKNOWN) {
        flag = true;
      }
  
      if (tlv._blockType == IrepBlock.BLOCK_TYPE_SEQ_OF
          || tlv._blockType == IrepBlock.BLOCK_TYPE_SET_OF
          || tlv._blockType == IrepBlock.BLOCK_TYPE_SET) {
        flag = true;
      }
  
      if (tlv._blockType == IrepBlock.BLOCK_TYPE_PAL_BLOCK) {
        pal_block = (IrepPalBlock) tlv;
  
        if (pal_block._chooseType != IrepPalBlock.CHOOSE_UNKNOWN) {
          flag = true;
        }
      }
  
      // change for CR:IQ00204578
      if (tlv._isInitBlock) {
        flag = true;
      }
  
      return flag;
    }
  
    Vector ConvertChildren(IrepTlv tlv, CompBlock comp_block) {
      Iterator it = null;
      CompNode comp_node = null;
      IrepNode irep_node = null;
      Vector irep_children = new Vector();
  
      for (it = comp_block.Content().iterator(); it.hasNext();) {
        comp_node = (CompNode) it.next();
        irep_node = ConvertCompNodeToIrepNode(comp_node);
  
        if (irep_node != null) {
          irep_children.add(irep_node);
        }
      }
  
      FindTermBlockCall(comp_block.Attrs(), tlv);
  
      if (tlv._blockType != IrepBlock.BLOCK_TYPE_PAL_BLOCK) {
        DetermineTlvTagAndLength(comp_block, tlv, irep_children);
      }
  
      return irep_children;
    }
  
    void FindTermBlockCall(CompBlockAttr attr, IrepTlv tlv) {
      // this should be done after determine this block type
      CompBlockCall comp_call = null;
      IrepBlockCall irep_call = null;
      IrepTlv temp_tlv = null;
      int attr_type = 0;
  
      switch (attr.SizeType()) {
        case CompBlockAttr.ATTR_SIZE_TERMINATED:
          comp_call = (CompBlockCall) attr.SizeAttr();
          irep_call = (IrepBlockCall) ConvertCompNodeToIrepNode(comp_call);
          tlv._thenTermBlockCall = irep_call;
          break;
  
        case CompBlockAttr.ATTR_SIZE_IF:
          attr_type = attr.SizeThenType();
  
          if (attr_type == CompBlockAttr.ATTR_SIZE_TERMINATED) {
            comp_call = (CompBlockCall) attr.SizeThenAttr();
            irep_call = (IrepBlockCall) ConvertCompNodeToIrepNode(comp_call);
            tlv._thenTermBlockCall = irep_call;
          }
  
          attr_type = attr.SizeElseType();
  
          if (attr_type == CompBlockAttr.ATTR_SIZE_TERMINATED) {
            comp_call = (CompBlockCall) attr.SizeElseAttr();
            irep_call = (IrepBlockCall) ConvertCompNodeToIrepNode(comp_call);
            tlv._elseTermBlockCall = irep_call;
          }
  
          break;
      }
  
      if (irep_call == null) {
        return;
      }
  
      temp_tlv = (IrepTlv) _compToIrep.get(comp_call._calledBlock);
      temp_tlv._isTermBlock = true;
    }
  
    void DetermineTlvTagAndLength(CompBlock comp_block, IrepTlv irep_tlv, Vector irep_children) {
      int i = 0;
      int tag_num = 0;
      int length_num = 0;
      IrepNode irep_node = null;
      IrepField irep_field = null;
      Vector tags = new Vector();
      Vector lengths = new Vector();
  
      // Determine tag number and length number
      for (i = 0; i < irep_children.size(); i++) {
        irep_node = (IrepNode) irep_children.get(i);
  
        switch (irep_node._nodeType) {
          case IrepNode.IREP_NODE_TYPE_FIELD:
  