Package javax.servlet.sip

Examples of javax.servlet.sip.Parameterable


  }

  @Test
  public void testParameterable() throws Exception
  {
    Parameterable orig = new ParameterableImpl("\"Hello World\" <sip:foo@bar.com;transport=tcp>;tag=12345");
    Parameterable readOnly = new ReadOnlyParameterable((Parameterable) orig.clone());
   
    assertEquals(orig, readOnly);
    try { readOnly.setParameter("foo", "bar"); fail();} catch (IllegalStateException e) {}
    try { readOnly.removeParameter("tag"); fail();} catch (IllegalStateException e) {}
    try { readOnly.setValue(""); fail();} catch (IllegalStateException e) {}
   
    assertEquals(orig, readOnly);
    assertEquals(readOnly, orig);
    assertEquals(orig.toString(), readOnly.toString());
    Parameterable clone = (Parameterable) readOnly.clone();
    clone.setParameter("a", "b");
    testSerializable(readOnly);
  }
View Full Code Here


  @Test
  public void testGetParameterable() throws Exception
  {
    SipRequest request = (SipRequest) getMessage(INVITE);
    Parameterable p = request.getParameterableHeader("from");
    assertEquals("Bob <sips:bob@biloxi.example.com>", p.getValue());
    assertEquals("a73kszlfl", p.getParameter("tag"));
   
    // FIXME p = request.getParameterableHeader("Via");
   
    p = request.getParameterableHeader("Accept");
    assertEquals("application/sdp", p.getValue());
    assertEquals("1", p.getParameter("level"));
   
    ListIterator<? extends Parameterable> it = request.getParameterableHeaders("Accept");
    while (it.hasNext())
    {
      int index = it.nextIndex();
      p = (Parameterable) it.next();
      switch (index)
      {
      case 0:
        assertEquals("application/sdp", p.getValue());
        assertEquals("1", p.getParameter("level"));
        break;
      case 1:
        assertEquals("application/x-private", p.getValue());
        assertFalse(p.getParameterNames().hasNext());
        break;
      case 2:
        assertEquals("text/html", p.getValue());
        assertFalse(p.getParameterNames().hasNext());
        break;
      default:
        fail("Too much parameterable");
        break;
      }
View Full Code Here

  {
    _fields.addParameterable(
        SipHeaders.CACHE.lookup("Call-Info"),
        new ParameterableImpl("<sip:foo.org>;appearance-index=1;appearance-state=active"),
        false);
    Parameterable p = _fields.getParameterable(SipHeaders.CACHE.lookup("Call-Info"));
   
    assertEquals("1", p.getParameter("appearance-index"));
    assertEquals("active", p.getParameter("appearance-state"));
    assertEquals("<sip:foo.org>", p.getValue());
   
    _fields.addAddress("Contact", new NameAddr("<sip:foo.org>;tag=1234"), false);
    p = _fields.getParameterable(SipHeaders.CACHE.lookup("contact"));
    assertEquals("1234", p.getParameter("tag"));
   
    Address address = _fields.getAddress(SipHeaders.CONTACT_BUFFER);
    assertEquals("foo.org", ((SipURI) address.getURI()).getHost());
    p = _fields.getParameterableValues("contact").next();
    assertEquals("1234", p.getParameter("tag"));
  }
View Full Code Here

  @Test
  public void testUnknown() throws Exception
  {
    _fields.addString("foo", "value;foo=bar");
    Parameterable p = _fields.getParameterable(SipHeaders.CACHE.lookup("foo"));
    assertEquals("bar", p.getParameter("foo"));
  }
View Full Code Here

 
  public boolean equals(Object o)
  {
    if (o == null || !(o instanceof Parameterable))
      return false;
    Parameterable p = (Parameterable) o;
   
    if (!_value.equals(p.getValue()))
      return false;
   
    for (String key : _parameters.keySet())
    {
      String otherValue = p.getParameter(key);
      if (otherValue != null && !getParameter(key).equalsIgnoreCase(otherValue))
        return false;
    }
    return true;
   
View Full Code Here

    HeaderInfo hi = SipHeaders.getType(buffer);
   
    if (hi.getType() != HeaderInfo.PARAMETERABLE && hi.getType() != HeaderInfo.ADDRESS && hi.getOrdinal() != -1)
      throw new ServletParseException("Header: " + name + " is not of parameterable type");
   
    Parameterable p = getFields().getParameterable(buffer);
   
    if ((isSystemHeader(hi) || isCommitted()) && p != null)
      return new ReadOnlyParameterable(p);
    else
      return p;
View Full Code Here

    public ListIterator<Parameterable> getParameterableValues()
        throws ServletParseException {
        // Verify beforehand that we wont get a "ServletParseException" on next and previous
        for (AddressOrValue parameterable : addressesOrValues) {
            Parameterable p = parameterable.getParameterableValue();

            // Even the Parameterable of a system header should be protected.
            ((ParameterableImpl) p).setReadOnly(_readOnly);
        }
View Full Code Here

     */
    public static void setup(SipServletRequestImpl req)
    throws SessionTargetException {
        ListIterator<Parameterable> lit;

        Parameterable join = null;
        Parameterable replaces = null;
       
        try {
            lit = (ListIterator<Parameterable>)
            req.getParameterableHeaders(Header.JOIN);
        } catch (ServletParseException ex) {
View Full Code Here

        }
    }

    public Parameterable getParameterableValue() throws ServletParseException {
        if (addressOrValue != null) {
            Parameterable parameterable = addressOrValue.getParameterableValue();

            // Even the Parameterable of a system header should be protected.
            ((ParameterableImpl) parameterable).setReadOnly(_readOnly);

            return parameterable;
View Full Code Here

        };
    }

    public ListIterator<Parameterable> getParameterableValues()
        throws ServletParseException {
        Parameterable parameterable = getParameterableValue();
        List<Parameterable> list = new ArrayList<Parameterable>(1);
        if (parameterable != null) {
            list.add(parameterable);
        }
        
View Full Code Here

TOP

Related Classes of javax.servlet.sip.Parameterable

Copyright © 2018 www.massapicom. 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.