Perform the media type field parsing
if (ParserCore.debug) dbg_enter("mediaField");
try {
MediaField mediaField = new MediaField();
lexer.match('m");
lexer.SPorHT();
lexer.match('=");
lexer.SPorHT();
lexer.match(Lexer.ID);
Token media = lexer.getNextToken();
mediaField.setMedia(media.getTokenValue());
lexer.SPorHT();
lexer.match(Lexer.ID);
Token port = lexer.getNextToken();
mediaField.setPort(Integer.parseInt(port.getTokenValue()));
lexer.SPorHT();
// Some strange media formatting from Sun Ray systems with media
if (lexer.hasMoreChars() && lexer.lookAhead(1) == '\n")
return mediaField;
if (lexer.lookAhead(0) == '/") {
// The number of ports is present:
lexer.consume(1);
lexer.match(Lexer.ID);
Token portsNumber = lexer.getNextToken();
mediaField.setNports(Integer.parseInt
(portsNumber.getTokenValue()));
lexer.SPorHT();
}
lexer.match(Lexer.ID);
Token token = lexer.getNextToken();
this.lexer.SPorHT();
String transport = token.getTokenValue();
if (lexer.lookAhead(0) == '/") {
lexer.consume(1);
lexer.match(Lexer.ID);
Token transportTemp = lexer.getNextToken();
transport = transport + "/" + transportTemp.getTokenValue();
lexer.SPorHT();
}
mediaField.setProto(transport);
// The formats list:
Vector formatList = new Vector();
while (lexer.hasMoreChars()) {
if (lexer.lookAhead(0) == '\n" || lexer.lookAhead(0) == '\r")
break;
lexer.SPorHT();
// while(lexer.lookAhead(0) == ' ') lexer.consume(1);
lexer.match(Lexer.ID);
Token tok = lexer.getNextToken();
lexer.SPorHT();
String format = tok.getTokenValue().trim();
if (! format.equals(""))
formatList.addElement(format);
}
mediaField.setFormats(formatList);
return mediaField;
} catch (NumberFormatException e) {
throw new ParseException(lexer.getBuffer(), lexer.getPtr());
} finally {
dbg_leave("mediaField");
}