Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
An example that illustrates template matching on SIP headers and messages. This uses regular expressions for matching on portions of sip messages. This is useful for situations when say you want to match with certain response classes or request URIs or whatever. You construct a match template that can consist of portions that are exact matches and portions that use regular expressions for matching. This example uses plain strings for patters but you can do wildcard matching.
package examples.nistgoodies.match;
import javax.sip.*;
public class MatchTest {
static final String message1 = "INVITE SIP/2.0\r\n"+
"From: ;tag=1234\r\n"+
"Call-ID: 0ha0isnda977644900765@\r\n"+
"CSeq: 9 INVITE\r\n"+
"Via: SIP/2.0/UDP\r\n"+
"Content-Type: application/sdp\r\n"+
"o=mhandley 29739 7272939 IN IP4\r\n" +
"c=IN IP4\r\n" +
"m=video 3227 RTP/AVP 31\r\n" +
"m=audio 4921 RTP/AVP 12\r\n" +
"a=rtpmap:31 LPC\r\n";
    public static void mainString[] args  ) throws Exception {
        SipFactory sipFactory = null;
        sipFactory = SipFactory.getInstance();
        MessageFactory messageFactory = sipFactory.createMessageFactory();
        Message message = messageFactory.createRequest();
        // Create an empty request.
        Message matchTemplate = messageFactory.createRequest(null);
        HeaderFactory headerFactory = sipFactory.createHeaderFactory();
        CSeqHeader cseqHeader =
        gov.nist.javax.sip.header.CSeq cseq = (CSeq)cseqHeader;
        boolean retval =
        ..println("match returned = " + retval);
        retval = ((SIPRequestmessage).match((SIPRequest)matchTemplate);
        ..println("match returned = " + retval);
New to GrepCode? Check out our FAQ X