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 /**
     32  * Parser for Subject  header.
     33  *
     34  * @version 1.2
     35  *
     36  * @author Olivier Deruelle   <br/>
     37  * @author M. Ranganathan   <br/>
     38  *
     39  *
     40  */
     41 public class SubjectParser extends HeaderParser {
     42 
     43     /**
     44      * Creates a new instance of SubjectParser
     45      * @param subject the header to parse
     46      */
     47     public SubjectParser(String subject) {
     48         super(subject);
     49     }
     50 
     51     /**
     52      * Constructor
     53      * @param lexer the lexer to use to parse the header
     54      */
     55     protected SubjectParser(Lexer lexer) {
     56         super(lexer);
     57     }
     58 
     59     /**
     60      * parse the String message
     61      * @return SIPHeader (Subject object)
     62      * @throws SIPParseException if the message does not respect the spec.
     63      */
     64     public SIPHeader parse() throws ParseException {
     65         Subject subject = new Subject();
     66         if (debug)
     67             dbg_enter("SubjectParser.parse");
     68 
     69         try {
     70             headerName(TokenTypes.SUBJECT);
     71 
     72             this.lexer.SPorHT();
     73 
     74             String s = this.lexer.getRest();
     75             subject.setSubject(s.trim());
     76 
     77         } finally {
     78             if (debug)
     79                 dbg_leave("SubjectParser.parse");
     80         }
     81 
     82         return subject;
     83     }
     84 
     85     /** Test program
     86     public static void main(String args[]) throws ParseException {
     87     String subject[] = {
     88             "Subject: Where is the Moscone?\n",
     89             "Subject: Need more boxes\n"
     90             };
     91 
     92     for (int i = 0; i < subject.length; i++ ) {
     93         SubjectParser parser =
     94           new SubjectParser(subject[i]);
     95         Subject s= (Subject) parser.parse();
     96         System.out.println("encoded = " +s.encode());
     97     }
     98 
     99     }
    100      */
    101 }
    102 /*
    103  * $Log: SubjectParser.java,v $
    104  * Revision 1.7  2009/07/17 18:58:05  emcho
    105  * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
    106  *
    107  * Revision 1.6  2006/07/13 09:02:17  mranga
    108  * Issue number:
    109  * Obtained from:
    110  * Submitted by:  jeroen van bemmel
    111  * Reviewed by:   mranga
    112  * Moved some changes from jain-sip-1.2 to java.net
    113  *
    114  * CVS: ----------------------------------------------------------------------
    115  * CVS: Issue number:
    116  * CVS:   If this change addresses one or more issues,
    117  * CVS:   then enter the issue number(s) here.
    118  * CVS: Obtained from:
    119  * CVS:   If this change has been taken from another system,
    120  * CVS:   then name the system in this line, otherwise delete it.
    121  * CVS: Submitted by:
    122  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    123  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    124  * CVS:   address here. If this is your work then delete this line.
    125  * CVS: Reviewed by:
    126  * CVS:   If we are doing pre-commit code reviews and someone else has
    127  * CVS:   reviewed your changes, include their name(s) here.
    128  * CVS:   If you have not had it reviewed then delete this line.
    129  *
    130  * Revision 1.3  2006/06/19 06:47:27  mranga
    131  * javadoc fixups
    132  *
    133  * Revision 1.2  2006/06/16 15:26:28  mranga
    134  * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
    135  *
    136  * Revision 1.1.1.1  2005/10/04 17:12:36  mranga
    137  *
    138  * Import
    139  *
    140  *
    141  * Revision 1.4  2004/01/22 13:26:32  sverker
    142  * Issue number:
    143  * Obtained from:
    144  * Submitted by:  sverker
    145  * Reviewed by:   mranga
    146  *
    147  * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
    148  *
    149  * CVS: ----------------------------------------------------------------------
    150  * CVS: Issue number:
    151  * CVS:   If this change addresses one or more issues,
    152  * CVS:   then enter the issue number(s) here.
    153  * CVS: Obtained from:
    154  * CVS:   If this change has been taken from another system,
    155  * CVS:   then name the system in this line, otherwise delete it.
    156  * CVS: Submitted by:
    157  * CVS:   If this code has been contributed to the project by someone else; i.e.,
    158  * CVS:   they sent us a patch or a set of diffs, then include their name/email
    159  * CVS:   address here. If this is your work then delete this line.
    160  * CVS: Reviewed by:
    161  * CVS:   If we are doing pre-commit code reviews and someone else has
    162  * CVS:   reviewed your changes, include their name(s) here.
    163  * CVS:   If you have not had it reviewed then delete this line.
    164  *
    165  */
    166