Examples of TelURL


Examples of javax.servlet.sip.TelURL

  public boolean equals(Object o)
  {
    if (o == null || !(o instanceof TelURL))
      return false;
   
    TelURL other = (TelURL) o;
   
    if (!_scheme.equals(other.getScheme()))
      return false;
   
    if (!removeVisualChar(getPhoneNumber()).equals(removeVisualChar(other.getPhoneNumber())))
      return false;
   
    if (isGlobal() != other.isGlobal())
      return false;
       
    for (String key : _params.keySet())
    {
      String otherValue = other.getParameter(key);
      if (otherValue != null && !getParameter(key).equalsIgnoreCase(otherValue))
        return false;
    }
    return true;
  }
View Full Code Here

Examples of javax.servlet.sip.TelURL

  }

  @Test
  public void testTelUrl() throws Exception
  {
    TelURL orig = new TelURLImpl("tel:+3398648;user=phone");
    TelURL readOnly = new ReadOnlyTelURL((TelURL) orig.clone());
   
    assertEquals(orig, readOnly);
    try { readOnly.setParameter("foo", "bar"); fail();} catch (IllegalStateException e) {}
    try { readOnly.removeParameter("user");   fail();} catch (IllegalStateException e) {}
    assertEquals(orig, readOnly);
    assertEquals(readOnly, orig);
    assertEquals(orig.toString(), readOnly.toString());
    URI clone = (URI) readOnly.clone();
    clone.setParameter("a", "b");
    testSerializable(readOnly);
  }
View Full Code Here

Examples of javax.servlet.sip.TelURL

{

  @Test
  public void testSetPhoneNumber() throws Exception
  {
    TelURL url = (TelURL) URIFactory.parseURI("tel:+1-212-555-0101");
    assertEquals("1-212-555-0101", url.getPhoneNumber());
    assertNull(url.getPhoneContext());
    url.setPhoneNumber("+123-456");
    assertEquals("123-456", url.getPhoneNumber());
    url.setPhoneNumber("123-456", "atlanta.com");
    assertEquals("123-456", url.getPhoneNumber());
    assertEquals("atlanta.com", url.getPhoneContext());
    try  { url.setPhoneNumber("+1/3"); fail();} catch (IllegalArgumentException e) {  }
    try  { url.setPhoneNumber("1-212-555-0101"); fail();} catch (IllegalArgumentException e) {}
    try  { url.setPhoneNumber("+1-212-555-0101", "atlanta.com"); fail();} catch (IllegalArgumentException e) {}
  } 
View Full Code Here

Examples of javax.servlet.sip.TelURL

  @Test
  public void testParameters() throws Exception
  {
    String tel = "tel:863-1234;phone-context=+1-914-555";
    TelURL url = (TelURL) URIFactory.parseURI(tel);
    assertEquals("863-1234", url.getPhoneNumber());
    assertEquals("+1-914-555", url.getPhoneContext());
    assertFalse(url.isGlobal());
  }
View Full Code Here

Examples of javax.servlet.sip.TelURL

            if (elements.length > 3) {
                if (req.getRequestURI() instanceof SipURI) {
                    SipURI sipUri = (SipURI) req.getRequestURI();
                    return sipUri.getParameter(elements[3]);
                } else {
                    TelURL telUrl = (TelURL) req.getRequestURI();
                    return telUrl.getParameter(elements[3]);
                }
            }
        }

        // General Headers
View Full Code Here

Examples of javax.servlet.sip.TelURL

                    break;
                }

                if (UriUtil.isTelephoneNumber(canonicalizedUri)) {
                    TelURL telUrl = null;

                    if (canonicalizedUri.isSipURI()) {
                        try {
                            telUrl = UriUtil.convertToTelURL((SipURI) canonicalizedUri);
                        } catch (UriUtilException e) {
View Full Code Here

Examples of javax.servlet.sip.TelURL

        }

        if (uri.isSipURI() && !UriUtil.isTelephoneNumber(uri)) {
            return ((SipURI) uri).getUser();
        } else if (uri.isSipURI() && UriUtil.isTelephoneNumber(uri)) {
            TelURL telUrl;

            try {
                telUrl = UriUtil.convertToTelURL((SipURI) uri);

                return telUrl.getPhoneNumber();
            } catch (UriUtilException e) {
                throw new IllegalStateException("Unknown type of Uri:" + uri, e);
            }
        } else if (UriUtil.isTelUrl(uri)) {
            return ((TelURL) uri).getPhoneNumber();
View Full Code Here

Examples of javax.servlet.sip.TelURL

    }

    private URI internalNormalize(URI uri) {
        assert UriUtil.isTelephoneNumber(uri);

        TelURL telUrl;

        if (uri.isSipURI()) {
            try {
                telUrl = UriUtil.convertToTelURL((SipURI) uri);
            } catch (UriUtilException e) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE, "Failed to convert SIP-URI to Tel-URL: ", e);
                }

                return null;
            }
        } else if (UriUtil.isTelUrl(uri)) {
            telUrl = (TelURL) uri;
        } else {
            return uri;
        }

        if (!telUrl.isGlobal()) {
            String globalNumber = resolver.normalize(telUrl.getPhoneNumber(), telUrl.getPhoneContext());

            if (globalNumber != null) {
                telUrl.setPhoneNumber(globalNumber);
                telUrl.removeParameter(TelURLImpl.PHONE_CONTEXT);
            }
        }

        if (uri.isSipURI()) {
            SipURI sipUri = (SipURI) uri.clone();
View Full Code Here

Examples of javax.servlet.sip.TelURL

        if (!isTelephoneNumber(uri)) {
            throw new TelUrlResolverException("The uri is not a phone number:" +
                uri);
        }

        TelURL telUrl = null;

        if (uri.isSipURI()) {
            try {
                telUrl = UriUtil.convertToTelURL((SipURI) uri);
            } catch (UriUtilException e) {
                throw new TelUrlResolverException("Could not convert URI: \"" +
                    uri + "\" to Tel-URL", e);
            }

            if (logger.isLoggable(Level.FINEST)) {
                logger.log(Level.FINEST,
                    "Sip-URI was converted to Tel-URL: " + telUrl);
            }
        } else if (uri.getScheme().equals(SipFactoryImpl.TEL_URI_PROTOCOL)) {
            telUrl = (TelURL) uri;
        }

        String phoneNumber;

        if (telUrl.isGlobal()) {
            phoneNumber = telUrl.getPhoneNumber();
        } else {
            String phoneContext;

            if ((phoneContext = telUrl.getPhoneContext()) == null) {
                throw new TelUrlResolverException("The local number is missing a phone-context: "+telUrl);
            } else {
                phoneNumber = normalize(telUrl.getPhoneNumber(), phoneContext);

                if (phoneNumber == null) {
                    throw new TelUrlResolverException("Could not normalize the phone number: "+telUrl);
                }
                if (logger.isLoggable(Level.FINEST)) {
View Full Code Here

Examples of javax.servlet.sip.TelURL

        if (!isTelephoneNumber(uri)) return uri;
       
        if (uri.isSipURI()) {
            // Since we are modifying the uri we need a copy
            SipURI tmpUri = (SipURI) uri.clone();
            TelURL telUrl;
            try {
                telUrl = convertToTelURL(tmpUri);
                if (telUrl.isGlobal()) {
                    telUrl.setPhoneNumber("+" + com.ericsson.ssa.sip.UriUtil.cleanupPhonenumber(telUrl.getPhoneNumber()));
                } else {
                    telUrl.setPhoneNumber(com.ericsson.ssa.sip.UriUtil.cleanupPhonenumber(telUrl.getPhoneNumber()), telUrl.getPhoneContext());
                }
                tmpUri.setUser(getAsSipUriUser(telUrl));
            } catch (UriUtilException e) {
                // This was not a phone number. Silently ignore
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.