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 gov.nist.javax.sip.header.*;
     29 import gov.nist.core.*;
     30 import java.text.ParseException;
     31 import javax.sip.*;
     32 
     33 /**
     34  * Parser for RAck header.
     35  *
     36  * @version 1.2 $Revision: 1.8 $ $Date: 2009/07/17 18:58:02 $
     37  *
     38  * @author Olivier Deruelle   <br/>
     39  * @author M. Ranganathan   <br/>
     40  *
     41  *
     42  *
     43  * @version 1.0
     44  */
     45 public class RAckParser extends HeaderParser {
     46 
     47     /**
     48      * Creates a new instance of RAckParser
     49      * @param rack the header to parse
     50      */
     51     public RAckParser(String rack) {
     52         super(rack);
     53     }
     54 
     55     /**
     56      * Constructor
     57      * @param lexer the lexer to use to parse the header
     58      */
     59     protected RAckParser(Lexer lexer) {
     60         super(lexer);
     61     }
     62 
     63     /**
     64      * parse the String message
     65      * @return SIPHeader (RAck object)
     66      * @throws SIPParseException if the message does not respect the spec.
     67      */
     68     public SIPHeader parse() throws ParseException {
     69 
     70         if (debug)
     71             dbg_enter("RAckParser.parse");
     72         RAck rack = new RAck();
     73         try {
     74             headerName(TokenTypes.RACK);
     75 
     76             rack.setHeaderName(SIPHeaderNames.RACK);
     77 
     78             try {
     79                 String number = this.lexer.number();
     80                 rack.setRSequenceNumber(Long.parseLong(number));
     81                 this.lexer.SPorHT();
     82                 number = this.lexer.number();
     83                 rack.setCSequenceNumber(Long.parseLong(number));
     84                 this.lexer.SPorHT();
     85                 this.lexer.match(TokenTypes.ID);
     86                 Token token = lexer.getNextToken();
     87                 rack.setMethod(token.getTokenValue());
     88 
     89             } catch (InvalidArgumentException ex) {
     90                 throw createParseException(ex.getMessage());
     91             }
     92             this.lexer.SPorHT();
     93             this.lexer.match('\n');
     94 
     95             return rack;
     96         } finally {
     97             if (debug)
     98                 dbg_leave("RAckParser.parse");
     99         }
    100     }
    101 
    102     /** Test program
    103     public static void main(String args[]) throws ParseException {
    104     String r[] = {
    105             "RAck: 776656 1 INVITE\n"
    106             };
    107 
    108     for (int i = 0; i < r.length; i++ ) {
    109         RAckParser parser =
    110           new RAckParser(r[i]);
    111         RAck ra= (RAck) parser.parse();
    112         System.out.println("encoded = " + ra.encode());
    113     }
    114     }
    115      */
    116 }
    117 /*
    118  * $Log: RAckParser.java,v $
    119  * Revision 1.8  2009/07/17 18:58:02  emcho
    120  * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
    121  *
    122  * Revision 1.7  2006/08/15 21:44:50  mranga
    123  * Issue number:
    124  * Obtained from:
    125  * Submitted by:  mranga
    126  * Reviewed by:   mranga
    127  * Incorporating the latest API changes from Phelim
    128  * CVS: ----------------------------------------------------------------------
    129  * CVS: Issue number:
    130  * CVS:   If this change addresses one or more issues,
    131  * CVS:   then enter the issue number(s) here.
    132  * CVS: Obtained from:
    133  * CVS:   If this change has been taken from another system,
    134  * CVS:   then name the system in this line, otherwise delete it.
    135  * CVS: Submitted by:
    136  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    137  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    138  * CVS:   address here. If this is your work then delete this line.
    139  * CVS: Reviewed by:
    140  * CVS:   If we are doing pre-commit code reviews and someone else has
    141  * CVS:   reviewed your changes, include their name(s) here.
    142  * CVS:   If you have not had it reviewed then delete this line.
    143  *
    144  * Revision 1.6  2006/07/13 09:02:24  mranga
    145  * Issue number:
    146  * Obtained from:
    147  * Submitted by:  jeroen van bemmel
    148  * Reviewed by:   mranga
    149  * Moved some changes from jain-sip-1.2 to java.net
    150  *
    151  * CVS: ----------------------------------------------------------------------
    152  * CVS: Issue number:
    153  * CVS:   If this change addresses one or more issues,
    154  * CVS:   then enter the issue number(s) here.
    155  * CVS: Obtained from:
    156  * CVS:   If this change has been taken from another system,
    157  * CVS:   then name the system in this line, otherwise delete it.
    158  * CVS: Submitted by:
    159  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    160  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    161  * CVS:   address here. If this is your work then delete this line.
    162  * CVS: Reviewed by:
    163  * CVS:   If we are doing pre-commit code reviews and someone else has
    164  * CVS:   reviewed your changes, include their name(s) here.
    165  * CVS:   If you have not had it reviewed then delete this line.
    166  *
    167  * Revision 1.4  2006/06/19 06:47:27  mranga
    168  * javadoc fixups
    169  *
    170  * Revision 1.3  2006/06/16 15:26:28  mranga
    171  * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
    172  *
    173  * Revision 1.2  2006/05/24 06:21:43  mranga
    174  * change to use the long setter
    175  *
    176  * Revision 1.1.1.1  2005/10/04 17:12:35  mranga
    177  *
    178  * Import
    179  *
    180  *
    181  * Revision 1.4  2004/01/22 13:26:31  sverker
    182  * Issue number:
    183  * Obtained from:
    184  * Submitted by:  sverker
    185  * Reviewed by:   mranga
    186  *
    187  * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
    188  *
    189  * CVS: ----------------------------------------------------------------------
    190  * CVS: Issue number:
    191  * CVS:   If this change addresses one or more issues,
    192  * CVS:   then enter the issue number(s) here.
    193  * CVS: Obtained from:
    194  * CVS:   If this change has been taken from another system,
    195  * CVS:   then name the system in this line, otherwise delete it.
    196  * CVS: Submitted by:
    197  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    198  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    199  * CVS:   address here. If this is your work then delete this line.
    200  * CVS: Reviewed by:
    201  * CVS:   If we are doing pre-commit code reviews and someone else has
    202  * CVS:   reviewed your changes, include their name(s) here.
    203  * CVS:   If you have not had it reviewed then delete this line.
    204  *
    205  */
    206