Home | History | Annotate | Download | only in parser
      1 /*
      2 * Conditions Of Use
      3 *
      4 * This software was developed by employees of the National Institute of
      5 * Standards and Technology (NIST), an agency of the Federal Government.
      6 * Pursuant to title 15 Untied States Code Section 105, works of NIST
      7 * employees are not subject to copyright protection in the United States
      8 * and are considered to be in the public domain.  As a result, a formal
      9 * license is not needed to use the software.
     10 *
     11 * This software is provided by NIST as a service and is expressly
     12 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
     13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
     14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
     15 * AND DATA ACCURACY.  NIST does not warrant or make any representations
     16 * regarding the use of the software or the results thereof, including but
     17 * not limited to the correctness, accuracy, reliability or usefulness of
     18 * the software.
     19 *
     20 * Permission to use this software is contingent upon your acceptance
     21 * of the terms of this agreement
     22 *
     23 * .
     24 *
     25 */
     26 package gov.nist.javax.sip.parser;
     27 
     28 import java.text.ParseException;
     29 import gov.nist.javax.sip.header.*;
     30 
     31 /**
     32  * To Header parser.
     33  *
     34  * @version 1.2 $Revision: 1.8 $ $Date: 2009/07/17 18:58:03 $
     35  *
     36  * @author Olivier Deruelle   <br/>
     37  *
     38  *
     39  *
     40  */
     41 public class ReferToParser extends AddressParametersParser {
     42 
     43     /**
     44      * Creates new ToParser
     45      * @param referTo String to set
     46      */
     47     public ReferToParser(String referTo) {
     48         super(referTo);
     49     }
     50 
     51     protected ReferToParser(Lexer lexer) {
     52         super(lexer);
     53     }
     54     public SIPHeader parse() throws ParseException {
     55 
     56         headerName(TokenTypes.REFER_TO);
     57         ReferTo referTo = new ReferTo();
     58         super.parse(referTo);
     59         this.lexer.match('\n');
     60         return referTo;
     61     }
     62 
     63     public static void main(String args[]) throws ParseException {
     64         String to[] =
     65             {   "Refer-To: <sip:dave (at) denver.example.org?" +
     66                     "Replaces=12345%40192.168.118.3%3Bto-tag%3D12345%3Bfrom-tag%3D5FFE-3994>\n",
     67                 "Refer-To: <sip:+1-650-555-2222 (at) ss1.wcom.com;user=phone>;tag=5617\n",
     68                 "Refer-To: T. A. Watson <sip:watson (at) bell-telephone.com>\n",
     69                 "Refer-To: LittleGuy <sip:UserB (at) there.com>\n",
     70                 "Refer-To: sip:mranga (at) 120.6.55.9\n",
     71                 "Refer-To: sip:mranga (at) 129.6.55.9 ; tag=696928473514.129.6.55.9\n" };
     72 
     73         for (int i = 0; i < to.length; i++) {
     74             ReferToParser tp = new ReferToParser(to[i]);
     75             ReferTo t = (ReferTo) tp.parse();
     76             System.out.println("encoded = " + t.encode());
     77 
     78         }
     79     }
     80 }
     81 /*
     82  * $Log: ReferToParser.java,v $
     83  * Revision 1.8  2009/07/17 18:58:03  emcho
     84  * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
     85  *
     86  * Revision 1.7  2006/07/13 09:02:21  mranga
     87  * Issue number:
     88  * Obtained from:
     89  * Submitted by:  jeroen van bemmel
     90  * Reviewed by:   mranga
     91  * Moved some changes from jain-sip-1.2 to java.net
     92  *
     93  * CVS: ----------------------------------------------------------------------
     94  * CVS: Issue number:
     95  * CVS:   If this change addresses one or more issues,
     96  * CVS:   then enter the issue number(s) here.
     97  * CVS: Obtained from:
     98  * CVS:   If this change has been taken from another system,
     99  * CVS:   then name the system in this line, otherwise delete it.
    100  * CVS: Submitted by:
    101  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    102  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    103  * CVS:   address here. If this is your work then delete this line.
    104  * CVS: Reviewed by:
    105  * CVS:   If we are doing pre-commit code reviews and someone else has
    106  * CVS:   reviewed your changes, include their name(s) here.
    107  * CVS:   If you have not had it reviewed then delete this line.
    108  *
    109  * Revision 1.3  2006/06/19 06:47:27  mranga
    110  * javadoc fixups
    111  *
    112  * Revision 1.2  2006/06/16 15:26:28  mranga
    113  * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
    114  *
    115  * Revision 1.1.1.1  2005/10/04 17:12:35  mranga
    116  *
    117  * Import
    118  *
    119  *
    120  * Revision 1.5  2005/03/29 03:50:01  mranga
    121  * Issue number:
    122  * Obtained from:
    123  * Submitted by:  mranga
    124  *
    125  * Remove transaction for early bye.
    126  * Reviewed by:
    127  * CVS: ----------------------------------------------------------------------
    128  * CVS: Issue number:
    129  * CVS:   If this change addresses one or more issues,
    130  * CVS:   then enter the issue number(s) here.
    131  * CVS: Obtained from:
    132  * CVS:   If this change has been taken from another system,
    133  * CVS:   then name the system in this line, otherwise delete it.
    134  * CVS: Submitted by:
    135  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    136  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    137  * CVS:   address here. If this is your work then delete this line.
    138  * CVS: Reviewed by:
    139  * CVS:   If we are doing pre-commit code reviews and someone else has
    140  * CVS:   reviewed your changes, include their name(s) here.
    141  * CVS:   If you have not had it reviewed then delete this line.
    142  *
    143  * Revision 1.4  2005/03/27 14:00:14  mranga
    144  * Issue number:
    145  * Obtained from:
    146  * Submitted by:  mranga
    147  * Reviewed by:   mranga
    148  *
    149  * Added example
    150  * CVS: ----------------------------------------------------------------------
    151  * CVS: Issue number:
    152  * CVS:   If this change addresses one or more issues,
    153  * CVS:   then enter the issue number(s) here.
    154  * CVS: Obtained from:
    155  * CVS:   If this change has been taken from another system,
    156  * CVS:   then name the system in this line, otherwise delete it.
    157  * CVS: Submitted by:
    158  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    159  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    160  * CVS:   address here. If this is your work then delete this line.
    161  * CVS: Reviewed by:
    162  * CVS:   If we are doing pre-commit code reviews and someone else has
    163  * CVS:   reviewed your changes, include their name(s) here.
    164  * CVS:   If you have not had it reviewed then delete this line.
    165  *
    166  * Revision 1.3  2004/01/22 13:26:31  sverker
    167  * Issue number:
    168  * Obtained from:
    169  * Submitted by:  sverker
    170  * Reviewed by:   mranga
    171  *
    172  * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
    173  *
    174  * CVS: ----------------------------------------------------------------------
    175  * CVS: Issue number:
    176  * CVS:   If this change addresses one or more issues,
    177  * CVS:   then enter the issue number(s) here.
    178  * CVS: Obtained from:
    179  * CVS:   If this change has been taken from another system,
    180  * CVS:   then name the system in this line, otherwise delete it.
    181  * CVS: Submitted by:
    182  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    183  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    184  * CVS:   address here. If this is your work then delete this line.
    185  * CVS: Reviewed by:
    186  * CVS:   If we are doing pre-commit code reviews and someone else has
    187  * CVS:   reviewed your changes, include their name(s) here.
    188  * CVS:   If you have not had it reviewed then delete this line.
    189  *
    190  */
    191