if (getOriginalRequest().getRequestURI().equals( ((SIPRequest) messageToTest).getRequestURI()) && (skipFrom || originalFromTag.equals(thisFromTag)) && (skipTo || originalToTag.equals(thisToTag)) && getOriginalRequest().getCallId().getCallId() .equals( messageToTest.getCallId() .getCallId()) && getOriginalRequest().getCSeq() .getSequenceNumber() == messageToTest .getCSeq().getSequenceNumber() && topViaHeader.equals(getOriginalRequest() .getViaHeaders().getFirst())) {
transactionMatches = true; }
    public boolean isMessagePartOfTransaction(SIPMessage messageToTest) {        // List of Via headers in the message to test        ViaList viaHeaders;        // Topmost Via header in the list        Via topViaHeader;        // Branch code in the topmost Via header        String messageBranch;        // Flags whether the select message is part of this transaction        boolean transactionMatches;        transactionMatches = false;        // Compensation for retransmits after OK has been dispatched        // as suggested by Antonis Karydas. Cancel Processing is        // special because we want to look for the invite        if (((SIPRequest) messageToTest).getMethod().equals(Request.CANCEL)                || ((((SIPTransactionStack) getSIPStack())                        .isDialogCreated(((SIPRequest) messageToTest)                                .getMethod())) || !isTerminated())) {            // Get the topmost Via header and its branch parameter            viaHeaders = messageToTest.getViaHeaders();            if (viaHeaders != null) {                topViaHeader = (Via) viaHeaders.getFirst();                messageBranch = topViaHeader.getBranch();                if (messageBranch != null) {                    // If the branch parameter exists but                    // does not start with the magic cookie,                    if (!messageBranch                            .startsWith(SIPConstants.BRANCH_MAGIC_COOKIE)) {                        // Flags this as old                        // (RFC2543-compatible) client                        // version                        messageBranch = null;                    }                }                // If a new branch parameter exists,                if (messageBranch != null && this.getBranch() != null) {                    if (getBranch().equals(messageBranch)                            && topViaHeader.getSentBy().equals(                                    ((Via) getOriginalRequest().getViaHeaders()                                            .getFirst()).getSentBy())) {                        // Matching server side transaction with only the                        // branch parameter.                        transactionMatches = true;                    }                    // If this is an RFC2543-compliant message,                    // This code is really here for backwards compatibility. It is a weak                    // check.                } else {                    // If RequestURI, To tag, From tag,                    // CallID, CSeq number, and top Via                    // headers are the same,                    String originalFromTag = super.fromTag;                    String thisFromTag = messageToTest.getFrom().getTag();                    boolean skipFrom = (originalFromTag == null || thisFromTag == null);                    String originalToTag = super.toTag;                    String thisToTag = messageToTest.getTo().getTag();                    boolean skipTo = (originalToTag == null || thisToTag == null);                    if (getOriginalRequest().getRequestURI().equals(                            ((SIPRequest) messageToTest).getRequestURI())                            && (skipFrom || originalFromTag.equals(thisFromTag))                            && (skipTo || originalToTag.equals(thisToTag))                            && getOriginalRequest().getCallId().getCallId()                                    .equals(                                            messageToTest.getCallId()                                                    .getCallId())                            && getOriginalRequest().getCSeq()                                    .getSequenceNumber() == messageToTest                                    .getCSeq().getSequenceNumber()                            && topViaHeader.equals(getOriginalRequest()                                    .getViaHeaders().getFirst())) {                        transactionMatches = true;                    }                }            }        }        return transactionMatches;    }