code: public void encode(AsnOutputStream aos) throws EncodeException {
  
          if (this.originatingTransactionId == null || this.originatingTransactionId.length != 4)
              throw new EncodeException("Error while encoding TCQueryMessage: originatingTransactionId 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 TCQueryMessage: neither dialogPortion nor componentPortion is defined");
  
          try {
              if (this.dialogTermitationPermission)
                  aos.writeTag(Tag.CLASS_PRIVATE, false, TCQueryMessage._TAG_QUERY_WITH_PERM);
              else
                  aos.writeTag(Tag.CLASS_PRIVATE, false, TCQueryMessage._TAG_QUERY_WITHOUT_PERM);
              int pos = aos.StartContentDefiniteLength();
  
              aos.writeOctetString(Tag.CLASS_PRIVATE, TCQueryMessage._TAG_TRANSACTION_ID, this.originatingTransactionId);
  
              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 TCQueryMessage: " + e.getMessage(), e);
          } catch (AsnException e) {
              throw new EncodeException("AsnException while encoding TCQueryMessage: " + e.getMessage(), e);
          }
  
      }
docs: /*
  (non-Javadoc)
  
  @see org.restcomm.protocols.ss7.tcap.asn.Encodable#encode(org.mobicents.protocols .asn.AsnOutputStream)