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

ParameterLessParser

public class ParameterLessParser extends HeaderParser
Parser for parameterless headers.

Fields Summary
Constructors Summary
protected ParameterLessParser()
Default constructor.

public ParameterLessParser(String value)
Constructor with header value.

param
value full header value respresented as a string

        super(value);
    
protected ParameterLessParser(Lexer lexer)
Constructor with initial lexer engine.

param
lexer initial lexer engine

        super(lexer);
    
Methods Summary
public Headerparse()
Invokes parser for a parameterless header.

return
the parsed ParameterLessHeader
throws
ParseException if a parsing error occurs

        try {
            String name = lexer.getNextToken(':");
            lexer.consume(1);
            String value = lexer.getLine().trim();

            // Some parameterless headers (for ex., RACK) have corresponding
            // classes but share this parser so we have to check the name
            // of header to decide which class to create.
            ParameterLessHeader retval;

            if (name.equalsIgnoreCase(Header.RACK)) {
                retval = new RAckHeader();
                retval.setHeaderValue(value);
            } else if (name.equalsIgnoreCase(Header.RSEQ)) {
                retval = new RSeqHeader();
                retval.setHeaderValue(value);
            } else {
                retval = new ParameterLessHeader(name, value);
            }

            return retval;
        } catch (Exception e) {
            throw new ParseException("Error in parse(): " + e.getMessage(), 0);
        }