public void encode(AsnOutputStream aos) throws EncodeException {

        if (this.originatingTransactionId == null || this.originatingTransactionId.length != 4)
            throw new EncodeException("Error while encoding TCConversationMessage: originatingTransactionId is not defined or has not a length 4");
        if (this.destinationTransactionId == null || this.destinationTransactionId.length != 4)
            throw new EncodeException("Error while encoding TCConversationMessage: destinationTransactionId is not defined or has not a length 4");

        // TODO: should we send a Component without both components and dialogPortion ?
        if ((this.component == null || this.component.length == 0) && this.dp == null)
            throw new EncodeException("Error while encoding TCConversationMessage: neither dialogPortion nor componentPortion is defined");

        try {
            if (this.dialogTermitationPermission)
                aos.writeTag(Tag.CLASS_PRIVATE, false, TCConversationMessage._TAG_CONVERSATION_WITH_PERM);
            else
                aos.writeTag(Tag.CLASS_PRIVATE, false, TCConversationMessage._TAG_CONVERSATION_WITHOUT_PERM);
            int pos = aos.StartContentDefiniteLength();

            byte[] buf = new byte[8];
            System.arraycopy(this.originatingTransactionId, 0, buf, 0, 4);
            System.arraycopy(this.destinationTransactionId, 0, buf, 4, 4);
            aos.writeOctetString(Tag.CLASS_PRIVATE, TCQueryMessage._TAG_TRANSACTION_ID, buf);

            if (this.dp != null)
                this.dp.encode(aos);

            if (component != null && component.length > 0) {
                aos.writeTag(Tag.CLASS_PRIVATE, false, TCQueryMessage._TAG_COMPONENT_SEQUENCE);
                int pos2 = aos.StartContentDefiniteLength();
                for (Component c : this.component) {
                    c.encode(aos);
                }
                aos.FinalizeContent(pos2);
            }

            aos.FinalizeContent(pos);

        } catch (IOException e) {
            throw new EncodeException("IOException while encoding TCConversationMessage: " + e.getMessage(), e);
        } catch (AsnException e) {
            throw new EncodeException("AsnException while encoding TCConversationMessage: " + e.getMessage(), e);
        }
    }
public void encode ( AsnOutputStream aos ) throws EncodeException { if ( this . originatingTransactionId == null || this . originatingTransactionId . length != 4 ) throw new EncodeException ( "Error while encoding TCConversationMessage: originatingTransactionId is not defined or has not a length 4" ) ; if ( this . destinationTransactionId == null || this . destinationTransactionId . length != 4 ) throw new EncodeException ( "Error while encoding TCConversationMessage: destinationTransactionId is not defined or has not a length 4" ) ; if ( ( this . component == null || this . component . length == 0 ) && this . dp == null ) throw new EncodeException ( "Error while encoding TCConversationMessage: neither dialogPortion nor componentPortion is defined" ) ; try { if ( this . dialogTermitationPermission ) aos . writeTag ( Tag . CLASS_PRIVATE , false , TCConversationMessage . _TAG_CONVERSATION_WITH_PERM ) ; else aos . writeTag ( Tag . CLASS_PRIVATE , false , TCConversationMessage . _TAG_CONVERSATION_WITHOUT_PERM ) ; int pos = aos . StartContentDefiniteLength ( ) ; byte [ ] buf = new byte [ 8 ] ; System . arraycopy ( this . originatingTransactionId , 0 , buf , 0 , 4 ) ; System . arraycopy ( this . destinationTransactionId , 0 , buf , 4 , 4 ) ; aos . writeOctetString ( Tag . CLASS_PRIVATE , TCQueryMessage . _TAG_TRANSACTION_ID , buf ) ; if ( this . dp != null ) this . dp . encode ( aos ) ; if ( component != null && component . length > 0 ) { aos . writeTag ( Tag . CLASS_PRIVATE , false , TCQueryMessage . _TAG_COMPONENT_SEQUENCE ) ; int pos2 = aos . StartContentDefiniteLength ( ) ; for ( Component c : this . component ) { c . encode ( aos ) ; } aos . FinalizeContent ( pos2 ) ; } aos . FinalizeContent ( pos ) ; } catch ( IOException e ) { throw new EncodeException ( "IOException while encoding TCConversationMessage: " + e . getMessage ( ) , e ) ; } catch ( AsnException e ) { throw new EncodeException ( "AsnException while encoding TCConversationMessage: " + e . getMessage ( ) , e ) ; } }
/*
(non-Javadoc)

@see org.restcomm.protocols.ss7.tcap.asn.Encodable#encode(org.mobicents.protocols .asn.AsnOutputStream)