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

FromParser

public class FromParser extends AddressParametersParser
From header parser.
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
Constructors Summary
FromParser()
Default constructor.

public FromParser(String from)
Constructor with initial From header string.

param
from initial From header

        super(from);
    
protected FromParser(Lexer lexer)
Constructor with initial lexer engine.

param
lexer initial lexer engine

        super(lexer);
    
Methods Summary
public Headerparse()
Invokes parser for From header field.

return
the parsed From header
exception
ParseException if a parsing error occurs

        
        FromHeader from = new FromHeader();
        
        this.lexer.match(TokenTypes.FROM);
        this.lexer.SPorHT();
        this.lexer.match(':");
        this.lexer.SPorHT();
        super.parse(from);
        this.lexer.match('\n");
        if (((Address)from.getAddress()).getAddressType() ==
                Address.ADDRESS_SPEC) {
            // the parameters are header parameters.
            if (from.getAddress().getURI() instanceof SipURI) {
                SipURI sipUri = (SipURI) from.getAddress().getURI();
                NameValueList parms = sipUri.getUriParms();
                if (parms != null && ! parms.isEmpty()) {
                    from.setParameters(parms);
                    sipUri.removeUriParms();
                }
            }
        }
        return from;