Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Conditions Of Use
   *
   * This software was developed by employees of the National Institute of
   * Standards and Technology (NIST), an agency of the Federal Government.
   * Pursuant to title 15 Untied States Code Section 105, works of NIST
   * employees are not subject to copyright protection in the United States
   * and are considered to be in the public domain.  As a result, a formal
   * license is not needed to use the software.
  *
  * This software is provided by NIST as a service and is expressly
  * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
  * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
  * AND DATA ACCURACY.  NIST does not warrant or make any representations
  * regarding the use of the software or the results thereof, including but
  * not limited to the correctness, accuracy, reliability or usefulness of
  * the software.
  *
  * Permission to use this software is contingent upon your acceptance
  * of the terms of this agreement
  *
  * .
  *
  */
 package gov.nist.javax.sip.parser;
 
 
 
 
Lexer class for the parser.

Author(s):
M. Ranganathan
Version:
1.2
 
 public class Lexer extends LexerCore {
    
get the header name of the line

Returns:
the header name (stuff before the :) bug fix submitted by zvali@dev.java.net
 
     public static String getHeaderName(String line) {
         if (line == null)
             return null;
         String headerName = null;
         try {
             int begin = line.indexOf(":");
             headerName = null;
             if (begin >= 1)
                 headerName = line.substring(0, begin).trim();
         } catch (IndexOutOfBoundsException e) {
             return null;
         }
         return headerName;
     }
 
     public Lexer(String lexerNameString buffer) {
         super(lexerNamebuffer);
         this.selectLexer(lexerName);
     }

    
get the header value of the line

Returns:
String
 
     public static String getHeaderValue(String line) {
         if (line == null)
             return null;
         String headerValue = null;
         try {
             int begin = line.indexOf(":");
             headerValue = line.substring(begin + 1);
         } catch (IndexOutOfBoundsException e) {
             return null;
         }
         return headerValue;
     }
 
     public void selectLexer(String lexerName) {
         synchronized () {
             // Synchronization Bug fix by Robert Rosen.
              = (Hashtable.get(lexerName);
             this. = lexerName;
             if ( == null) {
                 addLexer(lexerName);
                 if (lexerName.equals("method_keywordLexer")) {
                     addKeyword(..);
                    addKeyword(..);
                    addKeyword(..);
                    addKeyword(..);
                    addKeyword(..);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..);
                    addKeyword(..);
                    addKeyword(..);
                    // JvB: added to support RFC3903
                    addKeyword(..);
                } else if (lexerName.equals("command_keywordLexer")) {
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    // And now the dreaded short forms....
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .); // JvB: added
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .); // Bug
                                                                                // fix
                                                                                // by
                                                                                // Mario
                                                                                // Mantak
                    addKeyword(..toUpperCase(), .); // Bug fix by Jozef Saniga
                    
                    // JvB: added to support RFC3903
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    // pmusgrave: Add RFC4028 and ReferredBy
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    // pmusgrave RFC3891
                    addKeyword(..toUpperCase(),
                            .);
                    //jean deruelle RFC3911
                    addKeyword(..toUpperCase(),
                            .);
                    // IMS Headers
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    // issued by Miguel Freitas
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(.
                            .toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    addKeyword(..toUpperCase(),
                            .);
                    // added by aayush@rancore
                    addKeyword(..toUpperCase(),
                            .);
                    // added by aayush@rancore
                    addKeyword(..toUpperCase(),
                            .);
                    // added by aayush@rancore
                    addKeyword(..toUpperCase(),
                            .);
                    // added by aayush@rancore
                    addKeyword(..toUpperCase(),
                            .);
                    // added by aayush@rancore
                    addKeyword(..toUpperCase(),
                            .);
                    
                    // added References header
                    addKeyword(..toUpperCase(),.);
                    // end //
                } else if (lexerName.equals("status_lineLexer")) {
                    addKeyword(..toUpperCase(), .);
                } else if (lexerName.equals("request_lineLexer")) {
                    addKeyword(..toUpperCase(), .);
                } else if (lexerName.equals("sip_urlLexer")) {
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                    addKeyword(..toUpperCase(), .);
                }
            }
        }
    }
New to GrepCode? Check out our FAQ X