Ejemplo n.º 1
0
 /**
  * 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();
 }
Ejemplo n.º 2
0
  /**
   * Create a SipURI
   *
   * @param user -- the user
   * @param host -- the host.
   */
  public javax.sip.address.SipURI createSipURI(String user, String host) throws ParseException {
    if (host == null) throw new NullPointerException("null host");

    StringBuffer uriString = new StringBuffer("sip:");
    if (user != null) {
      uriString.append(user);
      uriString.append("@");
    }

    // if host is an IPv6 string we should enclose it in sq brackets
    if (host.indexOf(':') != host.lastIndexOf(':') && host.trim().charAt(0) != '[')
      host = '[' + host + ']';

    uriString.append(host);

    StringMsgParser smp = new StringMsgParser();
    try {

      SipUri sipUri = smp.parseSIPUrl(uriString.toString());
      return sipUri;
    } catch (ParseException ex) {
      throw new ParseException(ex.getMessage(), 0);
    }
  }