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 java.text.ParseException;
     30 import javax.sip.*;
     31 
     32 /**
     33  * Parser for SIP Expires Parser. Converts from SIP Date to the
     34  * internal storage (Calendar).
     35  *
     36  * @version 1.2 $Revision: 1.8 $ $Date: 2009/07/17 18:58:00 $
     37  *
     38  * @author M. Ranganathan   <br/>
     39  *
     40  *
     41  */
     42 public class ExpiresParser extends HeaderParser {
     43 
     44     /**
     45      * protected constructor.
     46      * @param text is the text of the header to parse
     47      */
     48     public ExpiresParser(String text) {
     49         super(text);
     50     }
     51 
     52     /**
     53      * constructor.
     54      * @param lexer is the lexer passed in from the enclosing parser.
     55      */
     56     protected ExpiresParser(Lexer lexer) {
     57         super(lexer);
     58     }
     59 
     60     /**
     61      * Parse the header.
     62      */
     63     public SIPHeader parse() throws ParseException {
     64         Expires expires = new Expires();
     65         if (debug)
     66             dbg_enter("parse");
     67         try {
     68             lexer.match(TokenTypes.EXPIRES);
     69             lexer.SPorHT();
     70             lexer.match(':');
     71             lexer.SPorHT();
     72             String nextId = lexer.getNextId();
     73             lexer.match('\n');
     74             try {
     75                 int delta = Integer.parseInt(nextId);
     76                 expires.setExpires(delta);
     77                 return expires;
     78             } catch (NumberFormatException ex) {
     79                 throw createParseException("bad integer format");
     80             } catch (InvalidArgumentException ex) {
     81                 throw createParseException(ex.getMessage());
     82             }
     83         } finally {
     84             if (debug)
     85                 dbg_leave("parse");
     86         }
     87 
     88     }
     89 
     90 
     91 
     92 }
     93 /*
     94  * $Log: ExpiresParser.java,v $
     95  * Revision 1.8  2009/07/17 18:58:00  emcho
     96  * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
     97  *
     98  * Revision 1.7  2006/07/13 09:02:12  mranga
     99  * Issue number:
    100  * Obtained from:
    101  * Submitted by:  jeroen van bemmel
    102  * Reviewed by:   mranga
    103  * Moved some changes from jain-sip-1.2 to java.net
    104  *
    105  * CVS: ----------------------------------------------------------------------
    106  * CVS: Issue number:
    107  * CVS:   If this change addresses one or more issues,
    108  * CVS:   then enter the issue number(s) here.
    109  * CVS: Obtained from:
    110  * CVS:   If this change has been taken from another system,
    111  * CVS:   then name the system in this line, otherwise delete it.
    112  * CVS: Submitted by:
    113  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    114  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    115  * CVS:   address here. If this is your work then delete this line.
    116  * CVS: Reviewed by:
    117  * CVS:   If we are doing pre-commit code reviews and someone else has
    118  * CVS:   reviewed your changes, include their name(s) here.
    119  * CVS:   If you have not had it reviewed then delete this line.
    120  *
    121  * Revision 1.3  2006/06/19 06:47:27  mranga
    122  * javadoc fixups
    123  *
    124  * Revision 1.2  2006/06/16 15:26:28  mranga
    125  * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
    126  *
    127  * Revision 1.1.1.1  2005/10/04 17:12:35  mranga
    128  *
    129  * Import
    130  *
    131  *
    132  * Revision 1.5  2004/08/10 21:35:44  mranga
    133  * Reviewed by:   mranga
    134  * move test cases out to another package
    135  *
    136  * Revision 1.4  2004/01/22 13:26:31  sverker
    137  * Issue number:
    138  * Obtained from:
    139  * Submitted by:  sverker
    140  * Reviewed by:   mranga
    141  *
    142  * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
    143  *
    144  * CVS: ----------------------------------------------------------------------
    145  * CVS: Issue number:
    146  * CVS:   If this change addresses one or more issues,
    147  * CVS:   then enter the issue number(s) here.
    148  * CVS: Obtained from:
    149  * CVS:   If this change has been taken from another system,
    150  * CVS:   then name the system in this line, otherwise delete it.
    151  * CVS: Submitted by:
    152  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    153  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    154  * CVS:   address here. If this is your work then delete this line.
    155  * CVS: Reviewed by:
    156  * CVS:   If we are doing pre-commit code reviews and someone else has
    157  * CVS:   reviewed your changes, include their name(s) here.
    158  * CVS:   If you have not had it reviewed then delete this line.
    159  *
    160  */
    161