⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipaddress.java

📁 jsr-180 (SIP) 实现源码。可以在真实手机上使用
💻 JAVA
字号:
package com.micromethod.sipstack.i;

import com.micromethod.sipstack.ri.SipAddressImpl;

public class SipAddress {

  private SipAddressImpl m_sipAddress = null;

  /**
   * Construct a new SipAddress from string. The string can be either name
   * address: Display Name <sip:user:password@host:port;uri-parameters> or plain
   * SIP URI: sip:user:password@host:port;uri-parameters
   * 
   * @param address
   *          SIP address as String
   * @throws IllegalArgumentException
   *           if there was an error in parsing the address.
   */
  public SipAddress(String address) throws IllegalArgumentException {
    m_sipAddress = new SipAddressImpl(address);
  }

  /**
   * Construct a new SipAddress from display name and URI.
   * 
   * @param displayName
   *          user display name
   * @param uri
   *          SIP URI
   * @throws IllegalArgumentException
   *           if there was an error in parsing the arguments.
   */
  public SipAddress(String displayName, String uri)
      throws IllegalArgumentException {
    m_sipAddress = new SipAddressImpl(displayName, uri);
  }

  /**
   * Returns the display name of SIP address.
   * 
   * @return display name or null if not available
   */
  public String getDisplayName() {
    return m_sipAddress.getDisplayName();
  }

  /**
   * Sets the display name. Empty string "" removes the display name.
   * 
   * @param name
   *          display name
   * @throws IllegalArgumentException
   *           if the display name is invalid
   */
  public void setDisplayName(String name) throws IllegalArgumentException {
    m_sipAddress.setDisplayName(name);
  }

  /**
   * Returns the scheme of SIP address.
   * 
   * @return the scheme of this SIP address e.g. sip or sips
   */
  public String getScheme() {
    return m_sipAddress.getScheme();
  }

  /**
   * Sets the scheme of SIP address. Valid scheme format is defined in RFC 3261
   * [1] p.224
   * 
   * @param scheme
   * @throws IllegalArgumentException
   *           if the scheme is invalid
   */
  public void setScheme(String scheme) throws IllegalArgumentException {
    m_sipAddress.setScheme(scheme);
  }

  /**
   * Returns the user part of SIP address.
   * 
   * @return user part of SIP address. Returns null if the user part is missing.
   */
  public String getUser() {
    return m_sipAddress.getUser();
  }

  /**
   * Sets the user part of SIP address.
   * 
   * @param s
   * @throws IllegalArgumentException
   *           if the user part is invalid
   */
  public void setUser(String s) throws IllegalArgumentException {
    m_sipAddress.setUser(s);
  }

  /**
   * Returns the URI part of the address (without parameters) i.e.
   * scheme:user@host:port.
   * 
   * @return the URI part of the address
   */
  public String getURI() {
    return m_sipAddress.getURI();
  }

  /**
   * Sets the URI part of the SIP address (without parameters) i.e.
   * scheme:user@host:port. Possible URI parameters are ignored.
   * 
   * @param uri
   * @throws IllegalArgumentException
   *           if the URI is invalid
   */
  public void setURI(String uri) throws IllegalArgumentException {
    m_sipAddress.setURI(uri);
  }

  /**
   * Returns the host part of the SIP address.
   * 
   * @return host part of this address.
   */
  public String getHost() {
    return m_sipAddress.getHost();
  }

  /**
   * Sets the host part of the SIP address.
   * 
   * @param host
   * @throws IllegalArgumentException
   *           if the host is invalid
   */
  public void setHost(String host) throws IllegalArgumentException {
    m_sipAddress.setHost(host);
  }

  /**
   * Returns the port number of the SIP address. If port number is not set,
   * return 5060. If the address is wildcard "*" return 0.
   * 
   * @return the port number
   */
  public int getPort() {
    return m_sipAddress.getPort();
  }

  /**
   * Sets the port number of the SIP address. Valid range is 0-65535, where 0
   * means that the port number is removed from the address URI.
   * 
   * @param port
   *          port number, valid range 0-65535, 0 means that port number is
   *          removed from the address URI
   * @throws IllegalArgumentException
   *           if the port number is invalid
   */
  public void setPort(int port) throws IllegalArgumentException {
    m_sipAddress.setPort(port);
  }

  /**
   * Returns the value associated with the named URI parameter.
   * 
   * @param name
   *          the name of the parameter
   * @return the value of the named parameter, or empty string for parameters
   *         without value and null if the parameter is not defined
   */
  public String getParameter(String name) {
    return m_sipAddress.getParameter(name);
  }

  /**
   * Sets the named URI parameter to the specified value. If the value is null
   * the parameter is interpreted as a parameter without value. Existing
   * parameter will be overwritten, otherwise the parameter is added.
   * 
   * @param name
   * @param value
   * @throws IllegalArgumentException
   *           if the parameter is invalid RFC 3261, chapter 19.1.1 SIP and SIPS
   *           URI Components "URI parameters" p.149
   */
  public void setParameter(String name, String value)
      throws IllegalArgumentException {
    m_sipAddress.setParameter(name, value);
  }

  /**
   * Removes the named URI parameter.
   * 
   * @param name
   */
  public void removeParameter(String name) {
    m_sipAddress.removeParameter(name);
  }

  /**
   * Returns a String array of all parameter names.
   * 
   * @return String array of parameter names. Returns null if the address does
   *         not have any parameters.
   */
  public String[] getParameterNames() {
    return m_sipAddress.getParameterNames();
  }

  /**
   * Returns a fully qualified SIP address, with display name, URI and URI
   * parameters. If display name is not specified only a SIP URI is returned. If
   * the port is not explicitly set (to 5060 or other value) it will be omitted
   * from the address URI in returned String.
   * 
   * @return a fully qualified SIP name address, SIP or SIPS URI
   */
  public String toString() {
    return m_sipAddress.toString();
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -