private boolean buildPayload ( WsByteBuffer xmitBuffer ) { if ( tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "buildPayload" , xmitBuffer ) ; if ( tc . isDebugEnabled ( ) ) JFapUtils . debugTraceWsByteBufferInfo ( this , tc , xmitBuffer , "xmitBuffer" ) ; boolean payloadFinished = false ; int amountCopied , amountToCopy ; if ( xmitDataBuffers . length == 0 ) { if ( tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "payload finished" ) ; payloadFinished = true ; } else { do { amountToCopy = xmitDataBuffers [ currentXmitDataBufferIndex ] . remaining ( ) ; if ( amountToCopy > transmissionRemaining ) amountToCopy = transmissionRemaining ; amountCopied = JFapUtils . copyWsByteBuffer ( xmitDataBuffers [ currentXmitDataBufferIndex ] , xmitBuffer , amountToCopy ) ; if ( tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "amountToCopy=" + amountToCopy + " amountCopied=" + amountCopied + " currentXmitDataBufferIndex=" + currentXmitDataBufferIndex ) ; transmissionRemaining -= amountCopied ; if ( amountCopied == amountToCopy ) { ++ currentXmitDataBufferIndex ; payloadFinished = ( currentXmitDataBufferIndex == xmitDataBuffers . length ) ; } if ( ( amountCopied < amountToCopy ) || ( transmissionRemaining < 1 ) ) { exhausedXmitBuffer = true ; } } while ( ( amountCopied == amountToCopy ) && ( ! payloadFinished ) && ( ! exhausedXmitBuffer ) ) ; } if ( tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "buildPayload" , "" + payloadFinished ) ; return payloadFinished ; }
Builds a transmission payload into the supplied buffer . This may be done incrementally by multiple invocations in the case that the supplied buffer is smaller than the payload being built .