src/main/java/pityoulish/sockets/client/TLVResponseParserImpl.java
protected void parseMessageBatch(MsgBoardTLV mbtlv, Visitor visitor)
    throws Exception
  {
    // The binary protocol specifies an order for the nested TLVs.
    // The Marker and an optional Missed indicator appear before the messages.

    MsgBoardTLV nested = mbtlv.getNestedTLV();
    if (nested == null)
       throw new Exception
         (Catalog.MISSING_NESTED_TLV_3.format(mbtlv.getType(),
                                              mbtlv.getStart(),
                                              MsgBoardType.MARKER));
    if (nested.getType() != MsgBoardType.MARKER)
       throw new Exception
         (Catalog.UNEXPECTED_TLV_3.format(nested.getType(),
                                          nested.getStart(),
                                          MsgBoardType.MARKER));
    if (nested.getEnd() > mbtlv.getEnd())
       throw new Exception
         (Catalog.OVERLONG_TLV_2.format(nested.getType(),
                                        nested.getStart()));
    String marker = parseStringValue(nested, "US-ASCII");

    boolean missed = false;
    nested = nested.getNextTLV(mbtlv.getEnd());
    if ((nested != null) && (nested.getType() == MsgBoardType.MISSED))
     {
       missed = true;
       nested = nested.getNextTLV(mbtlv.getEnd());
     }

    visitor.enterMessageBatch(marker, missed);

    while (nested != null)
     {
       if (nested.getType() != MsgBoardType.MESSAGE)
          throw new Exception
            (Catalog.UNEXPECTED_TLV_3.format(nested.getType(),
                                             nested.getStart(),
                                             MsgBoardType.MESSAGE));
       if (nested.getEnd() > mbtlv.getEnd())
          throw new Exception
            (Catalog.OVERLONG_TLV_2.format(nested.getType(),
                                           nested.getStart()));

       parseMessage(nested, visitor);
       nested = nested.getNextTLV(mbtlv.getEnd());
     }

    visitor.leaveMessageBatch();
  }
/**
   * Parses a message batch and calls the visitor.
   *
   * @param mbtlv       the TLV with the message batch
   * @param visitor     the visitor to invoke on the message batch elements
   *
   * @throws Exception in case of a problem
   */
Parses a message batch and calls the visitor.
@param mbtlv       the TLV with the message batch
@param visitor     the visitor to invoke on the message batch elements

@throws Exception in case of a problem
Parses a message batch and calls the visitor . @param mbtlv the TLV with the message batch @param visitor the visitor to invoke on the message batch elements @throws Exception in case of a problem
protected void parseMessageBatch(MsgBoardTLV mbtlv, Visitor visitor)
    throws Exception
  {
    MsgBoardTLV nested = mbtlv.getNestedTLV();
    if (nested == null)
       throw new Exception
         (Catalog.MISSING_NESTED_TLV_3.format(mbtlv.getType(),
                                              mbtlv.getStart(),
                                              MsgBoardType.MARKER));
    if (nested.getType() != MsgBoardType.MARKER)
       throw new Exception
         (Catalog.UNEXPECTED_TLV_3.format(nested.getType(),
                                          nested.getStart(),
                                          MsgBoardType.MARKER));
    if (nested.getEnd() > mbtlv.getEnd())
       throw new Exception
         (Catalog.OVERLONG_TLV_2.format(nested.getType(),
                                        nested.getStart()));
    String marker = parseStringValue(nested, "US-ASCII");
    boolean missed = false;
    nested = nested.getNextTLV(mbtlv.getEnd());
    if ((nested != null) && (nested.getType() == MsgBoardType.MISSED))
     {
       missed = true;
       nested = nested.getNextTLV(mbtlv.getEnd());
     }
    visitor.enterMessageBatch(marker, missed);
    while (nested != null)
     {
       if (nested.getType() != MsgBoardType.MESSAGE)
          throw new Exception
            (Catalog.UNEXPECTED_TLV_3.format(nested.getType(),
                                             nested.getStart(),
                                             MsgBoardType.MESSAGE));
       if (nested.getEnd() > mbtlv.getEnd())
          throw new Exception
            (Catalog.OVERLONG_TLV_2.format(nested.getType(),
                                           nested.getStart()));
       parseMessage(nested, visitor);
       nested = nested.getNextTLV(mbtlv.getEnd());
     }
    visitor.leaveMessageBatch();
  }
protected void parseMessageBatch ( MsgBoardTLV mbtlv , Visitor visitor ) throws Exception { MsgBoardTLV nested = mbtlv . getNestedTLV ( ) ; if ( nested == null ) throw new Exception ( Catalog . MISSING_NESTED_TLV_3 . format ( mbtlv . getType ( ) , mbtlv . getStart ( ) , MsgBoardType . MARKER ) ) ; if ( nested . getType ( ) != MsgBoardType . MARKER ) throw new Exception ( Catalog . UNEXPECTED_TLV_3 . format ( nested . getType ( ) , nested . getStart ( ) , MsgBoardType . MARKER ) ) ; if ( nested . getEnd ( ) > mbtlv . getEnd ( ) ) throw new Exception ( Catalog . OVERLONG_TLV_2 . format ( nested . getType ( ) , nested . getStart ( ) ) ) ; String marker = parseStringValue ( nested , "US-ASCII" ) ; boolean missed = false ; nested = nested . getNextTLV ( mbtlv . getEnd ( ) ) ; if ( ( nested != null ) && ( nested . getType ( ) == MsgBoardType . MISSED ) ) { missed = true ; nested = nested . getNextTLV ( mbtlv . getEnd ( ) ) ; } visitor . enterMessageBatch ( marker , missed ) ; while ( nested != null ) { if ( nested . getType ( ) != MsgBoardType . MESSAGE ) throw new Exception ( Catalog . UNEXPECTED_TLV_3 . format ( nested . getType ( ) , nested . getStart ( ) , MsgBoardType . MESSAGE ) ) ; if ( nested . getEnd ( ) > mbtlv . getEnd ( ) ) throw new Exception ( Catalog . OVERLONG_TLV_2 . format ( nested . getType ( ) , nested . getStart ( ) ) ) ; parseMessage ( nested , visitor ) ; nested = nested . getNextTLV ( mbtlv . getEnd ( ) ) ; } visitor . leaveMessageBatch ( ) ; }
Parses a message batch and calls the visitor.
Parses a message batch and calls the visitor .
// The binary protocol specifies an order for the nested TLVs. // The Marker and an optional Missed indicator appear before the messages.