/** * Parse and return a structure for a SIP URL. * * @return a URL structure for a SIP url. * @throws ParsException if there was a problem parsing. */ public SipUri sipURL() throws ParseException { if (debug) dbg_enter("sipURL"); SipUri retval = new SipUri(); try { lexer.match(TokenTypes.SIP); lexer.match(':'); retval.setScheme(TokenNames.SIP); int m = lexer.markInputPosition(); try { String user = user(); // char la; // la = lexer.lookAhead(0); // name:password@hostPort lexer.match(':'); String password = password(); lexer.match('@'); HostNameParser hnp = new HostNameParser(this.getLexer()); HostPort hp = hnp.hostPort(); retval.setUser(user); retval.setUserPassword(password); retval.setHostPort(hp); } catch (ParseException ex) { // name@hostPort try { lexer.rewindInputPosition(m); String user = user(); lexer.match('@'); HostNameParser hnp = new HostNameParser(this.getLexer()); HostPort hp = hnp.hostPort(); retval.setUser(user); retval.setHostPort(hp); } catch (ParseException e) { // hostPort lexer.rewindInputPosition(m); HostNameParser hnp = new HostNameParser(this.getLexer()); HostPort hp = hnp.hostPort(); retval.setHostPort(hp); } } lexer.selectLexer("charLexer"); while (lexer.hasMoreChars()) { if (lexer.lookAhead(0) != ';') break; lexer.consume(1); NameValue parms = uriParam(); if (parms != null) retval.setUriParameter(parms); } if (lexer.hasMoreChars() && lexer.lookAhead(0) == '?') { lexer.consume(1); while (lexer.hasMoreChars()) { NameValue parms = qheader(); retval.setQHeader(parms); if (lexer.hasMoreChars() && lexer.lookAhead(0) != '&') break; else lexer.consume(1); } } return retval; } finally { if (debug) dbg_leave("sipURL"); } }