}
public SIPHeader parse() throws ParseException {
// past the header name and the colon.
headerName(TokenTypes.CONTACT);
ContactList retval = new ContactList();
while (true) {
Contact contact = new Contact();
if (lexer.lookAhead(0) == '*') {
final char next = lexer.lookAhead(1);
if (next == ' ' || next == '\t' || next == '\r' || next == '\n') {
this.lexer.match('*');
contact.setWildCardFlag(true);
} else {
super.parse(contact);
}
} else {
super.parse(contact);
}
AddressImpl address = (AddressImpl) contact.getAddress();
URI uri = contact.getAddress().getURI();
/*
* When the header field value contains a display name, the URI
* including all URI parameters is enclosed in "<" and ">". If no "<"
* and ">" are present, all parameters after the URI are header
* parameters, not URI parameters.
*/
if (address.getAddressType() == AddressImpl.ADDRESS_SPEC
&& uri instanceof SipUri) {
SipUri sipUri = (SipUri) uri;
HashSet parameterNames = new HashSet();
for (Iterator it = sipUri.getParameterNames(); it.hasNext(); ) {
parameterNames.add(it.next());
}
// This avoids the concurrent modification exception.
for (Iterator it = parameterNames.iterator(); it.hasNext();) {
String name = (String) it.next();
String val = sipUri.getParameter(name);
sipUri.removeParameter(name);
contact.setParameter(name,val);
}
}
retval.add(contact);
this.lexer.SPorHT();
char la = lexer.lookAhead(0);
if (la == ',') {
this.lexer.match(',');
this.lexer.SPorHT();