⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 headerparser.java

📁 Java SIP
💻 JAVA
字号:
/* * This file was derived from libdissipate, an open source SIP library. The original file  * was modified on 1/23/2001.  Please see * http://www.div8.net/dissipate for more information. * * Copyright (c) 2000 Billy Biggs <bbiggs@div8.net> * * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at your * option) any later version. *  * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public * License for more details. *  * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB.  If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * *//** * class HeaderParser *  * Container class for the header parsing function used by dissipate.  This * should be fixed and moved somewhere more appropriate. * * This code has been generated using C2J++ * C2J++ is based on Chris Laffra's C2J (laffra@watson.ibm.com) * Read general disclaimer distributed with C2J++ before using this code * For information about C2J++, send mail to Ilya_Tilevich@ibi.com */package org.mitre.jsip;import java.util.StringTokenizer;public class HeaderParser{    /**     * HeaderParser     */    public HeaderParser( String headbuf )     {	lines = new StringTokenizer( headbuf, "\n" );    }    public boolean hasMoreLines() {	return lines.hasMoreTokens();    }    /**     * Returns the position where the header ends, the body begins, and the     * length of the body of the header.     *     * @param buf     *///      public boolean parse( String buf )//      {//  	try {//  	    int pos   = 0;//  	    int start = 0;//  	    int len   = 0;	    //  	    //	    buf.trim();//  	    StringBuffer sbuf = new StringBuffer(buf);	    //  	    // Get field name//  	    while( pos < bufEnd ) {//  		if ( sbuf.charAt(pos) == ':' ) {//  		    break;//  		}//  		pos++;//  	    }//  	    len = pos;	    //  	    // Remove any white space at end of field-name//  	    //while( len > 0 ) {//  	    //	if( !isspace( buf[ len - 1 ] ) ) break;//  	    //	len--;//  	    //}	    //  	    headerend = len;	    //  	    if( pos < bufEnd && sbuf.charAt(pos) == ':') {//  		pos++;//  	    }	//  	    // Skip spaces and tabs (but not newline!)//  	    while( pos < bufEnd ) {//  		if( sbuf.charAt(pos) != ' ' && sbuf.charAt(pos) != '\t' ) break;//  		pos++;//  	    }	    //  	    start = pos;//  	    len = 0;//  	    // Get field body//  	    while( pos < bufEnd ) {//  		if( sbuf.charAt(pos) == '\n' ) {//  		    // Are we at the end of the string?//  		    if( pos == bufEnd - 1 ) {//  			pos++;//  			break;//  		    }		    //  		    // Is this really the end of the field body, and not just//  		    // the end of a wrapped line?//  		    else if( sbuf.charAt(pos + 1) != ' ' && sbuf.charAt( pos + 1 ) != '\t' ) {//  			pos++;//  			break;//  		    }//  		}//  		pos++;//  	    }	    //  	    // Remove white space at end of field-body (*** LOOK AT ***)//  	    //while( pos > start ) {//  	    //	if( !isspace( buf[ pos - 1 ] ) ) break;//  	    //		pos--;//  	    //}	    //  	    len = pos - start;//  	    bodystart = start;//  	    bodylength = len;//  	    return true;//  	} catch (Exception e) {//  	    // any kind of exception (NullPointer, ArrayIndex, ect) will just return false//  	    System.err.println("Couldn't parse header");//  	    return false;//  	}//      }        public String getLine() {	return lines.nextToken();    }    // class variables//      int bodystart;//      int bodylength;//      int headerend;//      long bufEnd;    StringTokenizer lines;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -