• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package gov.nist.javax.sip.parser.extensions;
2 
3 
4 import java.text.ParseException;
5 import gov.nist.javax.sip.header.*;
6 import gov.nist.javax.sip.header.extensions.*;
7 import gov.nist.javax.sip.parser.*;
8 
9 
10 /**
11  * ReferredBy Header parser.
12  *
13  * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
14  *
15  * Based on JAIN ReferToParser
16  *
17  */
18 public class ReferredByParser extends AddressParametersParser {
19 
20     /**
21      * Creates new ToParser
22      * @param referBy String to set
23      */
ReferredByParser(String referBy)24     public ReferredByParser(String referBy) {
25         super(referBy);
26     }
27 
ReferredByParser(Lexer lexer)28     protected ReferredByParser(Lexer lexer) {
29         super(lexer);
30     }
parse()31     public SIPHeader parse() throws ParseException {
32 
33         headerName(TokenTypes.REFERREDBY_TO);
34         ReferredBy referBy = new ReferredBy();
35         super.parse(referBy);
36         this.lexer.match('\n');
37         return referBy;
38     }
39 
main(String args[])40     public static void main(String args[]) throws ParseException {
41         String to[] =
42             {   "Referred-By: <sip:dave@denver.example.org?" +
43                     "Replaces=12345%40192.168.118.3%3Bto-tag%3D12345%3Bfrom-tag%3D5FFE-3994>\n",
44                 "Referred-By: <sip:+1-650-555-2222@ss1.wcom.com;user=phone>;tag=5617\n",
45                 "Referred-By: T. A. Watson <sip:watson@bell-telephone.com>\n",
46                 "Referred-By: LittleGuy <sip:UserB@there.com>\n",
47                 "Referred-By: sip:mranga@120.6.55.9\n",
48                 "Referred-By: sip:mranga@129.6.55.9 ; tag=696928473514.129.6.55.9\n" };
49 
50         for (int i = 0; i < to.length; i++) {
51             ReferredByParser tp = new ReferredByParser(to[i]);
52             ReferredBy t = (ReferredBy) tp.parse();
53             System.out.println("encoded = " + t.encode());
54 
55         }
56     }
57 }
58 /*
59  * $Log:
60  *
61  */
62 
63 
64