public SIPHeader parse() throws ParseException { ContentType contentType = new ContentType(); 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; }
/** * parse the Accept String header * * @return SIPHeader (AcceptList object) * @throws SIPParseException if the message does not respect the spec. */ public SIPHeader parse() throws ParseException { if (debug) dbg_enter("AcceptParser.parse"); AcceptList list = new AcceptList(); try { headerName(TokenTypes.ACCEPT); Accept accept = new Accept(); accept.setHeaderName(SIPHeaderNames.ACCEPT); this.lexer.SPorHT(); this.lexer.match(TokenTypes.ID); Token token = lexer.getNextToken(); accept.setContentType(token.getTokenValue()); this.lexer.match('/'); this.lexer.match(TokenTypes.ID); token = lexer.getNextToken(); accept.setContentSubType(token.getTokenValue()); this.lexer.SPorHT(); super.parse(accept); list.add(accept); while (lexer.lookAhead(0) == ',') { this.lexer.match(','); this.lexer.SPorHT(); accept = new Accept(); this.lexer.match(TokenTypes.ID); token = lexer.getNextToken(); accept.setContentType(token.getTokenValue()); this.lexer.match('/'); this.lexer.match(TokenTypes.ID); token = lexer.getNextToken(); accept.setContentSubType(token.getTokenValue()); this.lexer.SPorHT(); super.parse(accept); list.add(accept); } return list; } finally { if (debug) dbg_leave("AcceptParser.parse"); } }
protected void parse(AddressParametersHeader addressParametersHeader) throws ParseException { dbg_enter("AddressParametersParser.parse"); try { AddressParser addressParser = new AddressParser(this.getLexer()); AddressImpl addr = addressParser.address(); addressParametersHeader.setAddress(addr); lexer.SPorHT(); if (this.lexer.hasMoreChars() && this.lexer.lookAhead(0) != '\0' && this.lexer.lookAhead(0) != '\n' && this.lexer.startsId()) { super.parseNameValueList(addressParametersHeader); } else super.parse(addressParametersHeader); } catch (ParseException ex) { throw ex; } finally { dbg_leave("AddressParametersParser.parse"); } }