code: public void decode(AsnInputStream ais) throws ParseException {
          this.dialogTermitationPermission = false;
          this.originatingTransactionId = null;
          this.dp = null;
          this.component = null;
  
          try {
              if (ais.getTag() == TCQueryMessage._TAG_QUERY_WITH_PERM)
                  dialogTermitationPermission = true;
              else
                  dialogTermitationPermission = false;
  
              AsnInputStream localAis = ais.readSequenceStream();
  
              // transaction portion
              TransactionID tid = TcapFactory.readTransactionID(localAis);
              if (tid.getFirstElem() == null || tid.getSecondElem() != null) {
                  throw new ParseException(PAbortCause.BadlyStructuredTransactionPortion,
                          "Error decoding TCQueryMessage: transactionId must contain only one transactionId");
              }
              this.originatingTransactionId = tid.getFirstElem();
  
              // dialog portion
              if (localAis.available() == 0) {
                  throw new ParseException(PAbortCause.UnrecognizedDialoguePortionID,
                          "Error decoding TCQueryMessage: neither dialog no component portion is found");
              }
              int tag = localAis.readTag();
              if (tag == DialogPortion._TAG_DIALOG_PORTION) {
                  this.dp = TcapFactory.createDialogPortion(localAis);
                  if (localAis.available() == 0)
                      return;
                  tag = localAis.readTag();
              }
  
              // component portion
              this.component = TcapFactory.readComponents(localAis);
  
          } catch (IOException e) {
              throw new ParseException(PAbortCause.BadlyStructuredDialoguePortion, "IOException while decoding TCQueryMessage: " + e.getMessage(), e);
          } catch (AsnException e) {
              throw new ParseException(PAbortCause.BadlyStructuredDialoguePortion, "AsnException while decoding TCQueryMessage: " + e.getMessage(), e);
          }
  
      }
docs: /*
  (non-Javadoc)
  
  @see org.restcomm.protocols.ss7.tcap.asn.Encodable#decode(org.mobicents.protocols .asn.AsnInputStream)