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

Parser

public abstract class Parser extends ParserCore implements TokenTypes
Base parser class.
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
Constructors Summary
protected Parser()
Default constructor.

Methods Summary
protected ParseExceptioncreateParseException(java.lang.String exceptionString)
Creates a ParseException with the provided message.

param
exceptionString message for cause of execption
return
the parser exception

        return new ParseException
                (lexer.getBuffer() + ":" + exceptionString, lexer.getPtr());
    
protected LexergetLexer()
Gets the current lexer engine.

return
the current lexer engine

        return (Lexer) this.lexer;
    
protected java.lang.Stringmethod()
Parses a method. Consumes if a valid method has been found.

return
the parsed method string
exception
ParseException if a parsing error occurs

        try {
            if (debug) dbg_enter("method");
            Vector tokens = this.lexer.peekNextToken(1);
            Token token = (Token) tokens.elementAt(0);
            int tokenType = token.getTokenType();

            if (tokenType == INVITE ||
                    tokenType == ACK ||
                    tokenType == OPTIONS ||
                    tokenType == BYE ||
                    tokenType == REGISTER ||
                    tokenType == CANCEL ||
                    tokenType == SUBSCRIBE ||
                    tokenType == NOTIFY ||
                    tokenType == ID ||
                    tokenType == MESSAGE ||
                    tokenType == INFO ||
                    tokenType == PUBLISH ||
                    tokenType == UPDATE ||
                    tokenType == PRACK ||
                    tokenType == REFER) {
                lexer.consume();
                return token.getTokenValue();
            } else {
                throw createParseException
                        ("Invalid Method");
            }
        } finally {
            if (debug) dbg_leave("method");
        }
    
protected java.lang.StringsipVersion()
Gets the current SIP version string.

return
the SIP version string.
exception
ParseException if a parsing error occurs

        if (debug) dbg_enter("sipVersion");
        try {
            Token tok = lexer.match(SIP);
            if (! tok.getTokenValue().equals("SIP"))
                createParseException("Expecting SIP");
            lexer.match('/");
            tok = lexer.match(ID);
            if (! tok.getTokenValue().equals("2.0"))
                createParseException("Expecting SIP/2.0");

            return "SIP/2.0";
        } finally {
            if (debug) dbg_leave("sipVersion");
        }