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

RepeatFieldParser

public class RepeatFieldParser extends SDPParser
Parser for Repeat field.
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
Constructors Summary
public RepeatFieldParser(String repeatField)
Creates new RepeatFieldsParser.

param
repeatField the repeat times filed to be parsed

        lexer = new Lexer("charLexer", repeatField);
    
protected RepeatFieldParser()
Default constructor.

        super();
    
Methods Summary
public TypedTimegetTypedTime(java.lang.String tokenValue)
Gets the typed time

param
tokenValue to set
return
TypedTime

        TypedTime typedTime = new TypedTime();

        if (tokenValue.endsWith("d")) {
            typedTime.setUnit("d");
            String t = tokenValue.replace('d", ' ");

            typedTime.setTime(Integer.parseInt(t.trim()));
        } else
            if (tokenValue.endsWith("h")) {
            typedTime.setUnit("h");
            String t = tokenValue.replace('h", ' ");
            typedTime.setTime(Integer.parseInt(t.trim()));
        } else
            if (tokenValue.endsWith("m")) {
            typedTime.setUnit("m");
            String t = tokenValue.replace('m", ' ");
            typedTime.setTime(Integer.parseInt(t.trim()));
        } else {
            typedTime.setUnit("s");
            if (tokenValue.endsWith("s")) {
                String t = tokenValue.replace('s", ' ");
                typedTime.setTime(Integer.parseInt(t.trim()));
            } else
                typedTime.setTime(Integer.parseInt(tokenValue.trim()));
        }
        return typedTime;
    
public SDPFieldparse()
Parses the field string.

return
RepeatFields
exception
ParseException if a parsing error occurs

        return this.repeatField();
    
public RepeatFieldrepeatField()
Parses the field string.

return
RepeatFields
exception
ParseException if a parsing error occurs

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

        RepeatField repeatField = new RepeatField();

        lexer.match(LexerCore.ID);
        Token repeatInterval = lexer.getNextToken();
        this.lexer.SPorHT();
        TypedTime typedTime = getTypedTime(repeatInterval.getTokenValue());
        repeatField.setRepeatInterval(typedTime);  

        lexer.match(LexerCore.ID);
        Token activeDuration = lexer.getNextToken();
        this.lexer.SPorHT();
        typedTime = getTypedTime(activeDuration.getTokenValue());
        repeatField.setActiveDuration(typedTime);  

        // The offsets list:
        while (lexer.lookAhead(0) != '\n") {
            lexer.match(LexerCore.ID);
            Token offsets = lexer.getNextToken();
            this.lexer.SPorHT();
            typedTime = getTypedTime(offsets.getTokenValue());
            repeatField.addOffset(typedTime);
        }


        return repeatField;