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

ContentTypeParser

public class ContentTypeParser extends ParametersParser
Parser for content type header. This code is in the public domain.

Fields Summary
Constructors Summary
ContentTypeParser()
Default constructor.

public ContentTypeParser(String contentType)
Constructor with initial content type header string.

param
contentType initial content length header

        super(contentType);
    
protected ContentTypeParser(Lexer lexer)
Constructor with initial lexer engine.

param
lexer initial lexer engine

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

return
the parsed content type header
exception
ParseException if a parsing error occurs

        
        ContentTypeHeader contentType = new ContentTypeHeader();
        if (debug) dbg_enter("ContentTypeParser.parse");
        
        try {
            this.headerName(TokenTypes.CONTENT_TYPE);
            
            // The type:
            lexer.match(TokenTypes.ID);
            Token type = lexer.getNextToken();
            this.lexer.SPorHT();
            contentType.setContentType(type.getTokenValue());
            
            
            // The sub-type:
            lexer.match('/");
            lexer.match(TokenTypes.ID);
            Token subType = lexer.getNextToken();
            this.lexer.SPorHT();
            contentType.setContentSubType(subType.getTokenValue());
            super.parse(contentType);
            this.lexer.match('\n");
        } finally {
            if (debug) dbg_leave("ContentTypeParser.parse");
        }
        return contentType;