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

TimeFieldParser

public class TimeFieldParser extends SDPParser
Time field parser.
version
1.0

Fields Summary
Constructors Summary
public TimeFieldParser(String timeField)
Creates new TimeFieldParser.

param
timeField the time field to be parsed

        lexer = new Lexer("charLexer", timeField);
    
protected TimeFieldParser()
Default constructor.

         super(); 
    
Methods Summary
private longgetTime()
Gets the time value.

return
the time value
exception
if a parsing error occurs

        try {
            String startTime = this.lexer.number();
            return Long.parseLong(startTime);
        } catch (NumberFormatException ex) {
            throw  lexer.createParseException();
        }

    
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
TimeField
exception
ParseException is a parsing error occurs

        return timeField();
    
public TimeFieldtimeField()
Parses the field string.

return
TimeField
exception
ParseException is a parsing error occurs

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

        TimeField timeField = new TimeField();

        long st = this.getTime();
        timeField.setStartTime(st);
        lexer.SPorHT();

        st = this.getTime();
        timeField.setStopTime(st);

        return timeField;