/** Get a dialog id given the remote tag. */ public String getDialogId(boolean isServer, String toTag) { From from = (From) this.getFrom(); CallID cid = (CallID) this.getCallId(); StringBuffer retval = new StringBuffer(cid.getCallId()); if (!isServer) { // retval.append(COLON).append(from.getUserAtHostPort()); if (from.getTag() != null) { retval.append(COLON); retval.append(from.getTag()); } // retval.append(COLON).append(to.getUserAtHostPort()); if (toTag != null) { retval.append(COLON); retval.append(toTag); } } else { // retval.append(COLON).append(to.getUserAtHostPort()); if (toTag != null) { retval.append(COLON); retval.append(toTag); } // retval.append(COLON).append(from.getUserAtHostPort()); if (from.getTag() != null) { retval.append(COLON); retval.append(from.getTag()); } } return retval.toString().toLowerCase(); }
protected String hvalue() throws ParseException { StringBuffer retval = new StringBuffer(); while (lexer.hasMoreChars()) { char la = lexer.lookAhead(0); // Look for a character that can terminate a URL. if (la == '+' || la == '?' || la == ':' || la == '[' || la == ']' || la == '/' || la == '$' || la == '_' || la == '-' || la == '"' || la == '!' || la == '~' || la == '*' || la == '.' || la == '(' || la == ')' || Lexer.isAlpha(la) || Lexer.isDigit(la)) { lexer.consume(1); retval.append(la); } else if (la == '%') { retval.append(escaped()); } else break; } return retval.toString(); }
/** Parser for the local phone #. */ private String local_number() throws ParseException { StringBuffer s = new StringBuffer(); if (debug) dbg_enter("local_number"); try { int lc = 0; while (lexer.hasMoreChars()) { char la = lexer.lookAhead(0); if (la == '*' || la == '#' || la == '-' || la == '.' || la == '(' || la == ')' || Lexer.isDigit(la)) { lexer.consume(1); s.append(la); lc++; } else if (lc > 0) break; else throw createParseException("unexepcted " + la); } return s.toString(); } finally { if (debug) dbg_leave("local_number"); } }
/** * Encode into canonical form. * * @return String */ public String encodeBody() { StringBuffer retval = new StringBuffer(LESS_THAN).append(errorInfo.toString()).append(GREATER_THAN); if (!parameters.isEmpty()) { retval.append(SEMICOLON).append(parameters.encode()); } return retval.toString(); }
protected String uricString() { StringBuffer retval = new StringBuffer(); while (true) { String next = uric(); if (next == null) break; retval.append(next); } return retval.toString(); }
/** * Scan forward until you hit a terminating character for a URL. We do not handle non sip urls in * this implementation. * * @return the string that takes us to the end of this URL (i.e. to the next delimiter). */ protected String urlString() throws ParseException { StringBuffer retval = new StringBuffer(); lexer.selectLexer("charLexer"); while (lexer.hasMoreChars()) { char la = lexer.lookAhead(0); // Look for a character that can terminate a URL. if (la == ' ' || la == '\t' || la == '\n' || la == '>' || la == '<') break; lexer.consume(0); retval.append(la); } return retval.toString(); }
protected String password() throws ParseException { StringBuffer retval = new StringBuffer(); while (true) { char la = lexer.lookAhead(0); if (isUnreserved(la) || la == '&' || la == '=' || la == '+' || la == '$' || la == ',') { retval.append(la); lexer.consume(1); } else if (isEscaped()) { String esc = lexer.charAsString(3); retval.append(esc); lexer.consume(3); // bug reported by // Jeff Haynie } else break; } return retval.toString(); }
protected String escaped() throws ParseException { if (debug) dbg_enter("escaped"); try { StringBuffer retval = new StringBuffer(); char next = lexer.lookAhead(0); char next1 = lexer.lookAhead(1); char next2 = lexer.lookAhead(2); if (next == '%' && Lexer.isHexDigit(next1) && Lexer.isHexDigit(next2)) { lexer.consume(3); retval.append(next); retval.append(next1); retval.append(next2); } else throw createParseException("escaped"); return retval.toString(); } finally { if (debug) dbg_leave("escaped"); } }
/** Parser for the base phone number. */ private String base_phone_number() throws ParseException { StringBuffer s = new StringBuffer(); if (debug) dbg_enter("base_phone_number"); try { int lc = 0; while (lexer.hasMoreChars()) { char w = lexer.lookAhead(0); if (Lexer.isDigit(w) || w == '-' || w == '.' || w == '(' || w == ')') { lexer.consume(1); s.append(w); lc++; } else if (lc > 0) break; else throw createParseException("unexpected " + w); } return s.toString(); } finally { if (debug) dbg_leave("base_phone_number"); } }
protected String user() throws ParseException { if (debug) dbg_enter("user"); try { StringBuffer retval = new StringBuffer(); while (lexer.hasMoreChars()) { char la = lexer.lookAhead(0); // if (la == '=') break; if (isUnreserved(la) || isUserUnreserved(la)) { retval.append(la); lexer.consume(1); } else if (isEscaped()) { String esc = lexer.charAsString(3); lexer.consume(3); retval.append(esc); } else break; } return retval.toString(); } finally { if (debug) dbg_leave("user"); } }
/** Name or value of a parameter. */ protected String paramNameOrValue() throws ParseException { StringBuffer retval = new StringBuffer(); while (lexer.hasMoreChars()) { char next = lexer.lookAhead(0); if (next == '[' || next == '[' || next == '/' || next == ':' || next == '&' || next == '+' || next == '$' || isUnreserved(next)) { retval.append(next); lexer.consume(1); } else if (isEscaped()) { String esc = lexer.charAsString(3); lexer.consume(3); retval.append(esc); } else break; } return retval.toString(); }