FileDocCategorySizeDatePackage
StatusLineParser.javaAPI DocphoneME MR2 API (J2ME)3535Wed May 02 18:00:42 BST 2007gov.nist.siplite.parser

StatusLineParser

public class StatusLineParser extends Parser
Parser for the SIP status line.
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
Constructors Summary
public StatusLineParser(String statusLine)
Constructor with initial status line string.

param
statusLine initial status line

        this.lexer = new Lexer("status_lineLexer", statusLine);
    
public StatusLineParser(Lexer lexer)
Constructor with initial lexer engine.

param
lexer initial lexer engine

        this.lexer = lexer;
        this.lexer.selectLexer("status_lineLexer");
    
Methods Summary
public StatusLineparse()
Parses the status line message.

return
Header the status line object
throws
ParseException if errors occur during the parsing

        try {
            if (debug) dbg_enter("parse");
            StatusLine retval = new StatusLine();
            String version = this.sipVersion();
            retval.setSipVersion(version);
            lexer.SPorHT();
            int scode = statusCode();
            retval.setStatusCode(scode);
            lexer.SPorHT();
            String rp = reasonPhrase();
            retval.setReasonPhrase(rp);
            lexer.SPorHT();
            return retval;
        } finally {
            if (debug) dbg_leave("parse");
        }
    
protected java.lang.StringreasonPhrase()
Gets the reason phrase.

return
the reason phrase
exception
ParseException of a parsing error occurs

        return this.lexer.getRest().trim();
    
protected intstatusCode()
Gets the status code from the parsed line.

return
the status code
exception
ParseException if a parsing error occurs

        String scode = this.lexer.number();
        if (debug) dbg_enter("statusCode");
        try {
            int retval = Integer.parseInt(scode);
            return retval;
        } catch (NumberFormatException ex) {
            throw new ParseException(lexer.getBuffer() +
                    ":" + ex.getMessage(), lexer.getPtr());
        } finally {
            if (debug) dbg_leave("statusCode");
        }