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 
     31 /** Parser for Organization header.
     32  *
     33  * @version 1.2 $Revision: 1.8 $ $Date: 2009/07/17 18:58:01 $
     34  *
     35  * @author Olivier Deruelle   <br/>
     36  * @author M. Ranganathan   <br/>
     37  *
     38  *
     39  */
     40 public class OrganizationParser extends HeaderParser {
     41 
     42     /**
     43      * Creates a new instance of OrganizationParser
     44      * @param organization the header to parse
     45      */
     46     public OrganizationParser(String organization) {
     47         super(organization);
     48     }
     49 
     50     /**
     51      * Constructor
     52      * @param lexer the lexer to use to parse the header
     53      */
     54     protected OrganizationParser(Lexer lexer) {
     55         super(lexer);
     56     }
     57 
     58     /**
     59      * parse the String header
     60      * @return SIPHeader (Organization object)
     61      * @throws SIPParseException if the message does not respect the spec.
     62      */
     63     public SIPHeader parse() throws ParseException {
     64 
     65         if (debug)
     66             dbg_enter("OrganizationParser.parse");
     67         Organization organization = new Organization();
     68         try {
     69             headerName(TokenTypes.ORGANIZATION);
     70 
     71             organization.setHeaderName(SIPHeaderNames.ORGANIZATION);
     72 
     73             this.lexer.SPorHT();
     74             String value = this.lexer.getRest();
     75 
     76             organization.setOrganization(value.trim());
     77 
     78             return organization;
     79         } finally {
     80             if (debug)
     81                 dbg_leave("OrganizationParser.parse");
     82         }
     83     }
     84 
     85 
     86 }
     87