rawMessage = sipMessages;
bufferPointer = 0; bodyIsString = false;
    public SIPMessage  parseSIPMessage(String sipMessages )    throws ParseException {        // Handle line folding and evil DOS CR-LF sequences        rawMessage = sipMessages;        Vector retval = new Vector();        String pmessage = sipMessages.trim();        bodyIsString = true;                    this.contentLength = 0;            if (pmessage.trim().equals("")) return null;                        pmessage += "\n\n";            StringBuffer message = new StringBuffer(pmessage);            // squeeze out the leading crlf sequences.            while(message.charAt(0) == '\r' || message.charAt(0) == '\n') {                bufferPointer ++;                message.deleteCharAt(0);            }                        // squeeze out the crlf sequences and make them uniformly CR            String message1 = message.toString();            int length;            length = message1.indexOf("\r\n\r\n");            if (length > 0 ) length += 4;            if (length == -1) {                length = message1.indexOf("\n\n");                if (length == -1)                    throw new ParseException("no trailing crlf",0);            } else length += 2;                                    // Get rid of CR to make it uniform.            for ( int k = 0; k < length ; k++ ) {                if (message.charAt(k) == '\r' ) {                    message.deleteCharAt(k);                    length --;                }            }                                    if (debugFlag ) {                for (int k = 0 ; k < length; k++) {                    rawMessage1 = rawMessage1 + "[" + message.charAt(k) +"]";                }            }                        // The following can be written more efficiently in a single pass            // but it is somewhat tricky.            java.util.StringTokenizer tokenizer = new java.util.StringTokenizer            (message.toString(),"\n",true);            StringBuffer cooked_message = new StringBuffer();            try {                while( tokenizer.hasMoreElements() ) {                    String nexttok = tokenizer.nextToken();                    // Ignore blank lines with leading spaces or tabs.                    if (nexttok.trim().equals("")) cooked_message.append("\n");                    else cooked_message.append(nexttok);                }            } catch (NoSuchElementException ex) {            }                        message1 = cooked_message.toString();            length = message1.indexOf("\n\n") + 2;                        // Handle continuations - look for a space or a tab at the start            // of the line and append it to the previous line.                                    for ( int k = 0 ; k < length - 1 ;  ) {                if (cooked_message.charAt(k) == '\n') {                    if ( cooked_message.charAt(k+1) == '\t' ||                    cooked_message.charAt(k+1) == ' ') {                        cooked_message.deleteCharAt(k);                        cooked_message.deleteCharAt(k);                        length --;                        length --;                        if ( k == length) break;                        continue;                    }                    if ( cooked_message.charAt(k+1) == '\n') {                        cooked_message.insert(k,'\n');                        length ++;                        k ++;                    }                }                k++;            }            cooked_message.append("\n\n");                                    // Separate the string out into substrings for            // error reporting.                                    currentMessage = cooked_message.toString();            if (Parser.debug) Debug.println(currentMessage);            bufferPointer = currentMessage.indexOf("\n\n") + 3 ;            SIPMessage sipmsg = this.parseMessage(currentMessage);	    if (readBody && sipmsg.getContentLength() != null && 		sipmsg.getContentLength().getContentLength() != 0) {		this.contentLength = 		     sipmsg.getContentLength().getContentLength();		String body = this.getMessageBody();		sipmsg.setMessageContent(body);	    }	    return sipmsg;    }