FileDocCategorySizeDatePackage
OriginFieldParser.javaAPI DocphoneME MR2 API (J2ME)4715Wed May 02 18:00:42 BST 2007gov.nist.javax.sdp.parser

OriginFieldParser

public class OriginFieldParser extends SDPParser
Origin field parser.
version
1.0

Fields Summary
Constructors Summary
public OriginFieldParser(String originField)
Creates new OriginFieldParser.

param
originField origin field to be parsed

        lexer = new Lexer("charLexer", originField);
    
protected OriginFieldParser()
Default constructor.

        super();
    
Methods Summary
public OriginFieldoriginField()
Perform the origin field parsing.

return
the parsed origin field
exception
ParseException if a parsing error occurs

        try {
            OriginField originField = new OriginField();

            lexer.match('o");
            lexer.SPorHT();
            lexer.match('=");
            lexer.SPorHT();

            lexer.match(LexerCore.ID);
            Token userName = lexer.getNextToken();
            originField.setUsername(userName.getTokenValue());
            this.lexer.SPorHT();

            lexer.match(LexerCore.ID);
            Token sessionId = lexer.getNextToken();
            originField.setSessId(Long.parseLong(sessionId.getTokenValue()));
            this.lexer.SPorHT();

            lexer.match(LexerCore.ID);
            Token sessionVersion = lexer.getNextToken();
            originField.setSessVersion(Long.parseLong(
                                            sessionVersion.getTokenValue()));
            this.lexer.SPorHT();

            lexer.match(LexerCore.ID);
            Token networkType = lexer.getNextToken();
            originField.setNettype(networkType.getTokenValue());
            this.lexer.SPorHT();

            lexer.match(LexerCore.ID);
            Token addressType = lexer.getNextToken();
            originField.setAddrtype(addressType.getTokenValue());
            this.lexer.SPorHT();

            String host = lexer.getRest();
            Lexer lexer = new Lexer("charLexer", host);
            HostNameParser hostNameParser = new HostNameParser(lexer);
            Host h = hostNameParser.host();
            originField.setAddress(h);

            return originField;
        } catch (SdpException e) {
            throw new ParseException(lexer.getBuffer(), lexer.getPtr());
        } catch (NumberFormatException nfe) {
            throw new ParseException(lexer.getBuffer(), lexer.getPtr());
        }
    
public SDPFieldparse()
Perform the origin field parsing.

return
the parsed origin field
exception
ParseException if a parsing error occurs

        return originField();