Package gov.nist.javax.sip.header

Examples of gov.nist.javax.sip.header.SIPHeader


   */
  public void removeHeader(String headerName, boolean top) {

    String headerNameLowerCase = SIPHeaderNamesCache
        .toLowerCase(headerName);
    SIPHeader toRemove = (SIPHeader) nameTable.get(headerNameLowerCase);
    // nothing to do then we are done.
    if (toRemove == null)
      return;
    if (toRemove instanceof SIPHeaderList) {
      SIPHeaderList<?> hdrList = (SIPHeaderList<?>) toRemove;
      if (top)
        hdrList.removeFirst();
      else
        hdrList.removeLast();
      // Clean up empty list
      if (hdrList.isEmpty()) {
        Iterator<SIPHeader> li = this.headers.iterator();
        while (li.hasNext()) {
          SIPHeader sipHeader = (SIPHeader) li.next();
          if (sipHeader.getName().equalsIgnoreCase(
              headerNameLowerCase))
            li.remove();
        }

        // JvB: also remove it from the nameTable! Else NPE in
        // DefaultRouter
        nameTable.remove(headerNameLowerCase);
      }
    } else {
      this.nameTable.remove(headerNameLowerCase);
      if (toRemove instanceof From) {
        this.fromHeader = null;
      } else if (toRemove instanceof To) {
        this.toHeader = null;
      } else if (toRemove instanceof CSeq) {
        this.cSeqHeader = null;
      } else if (toRemove instanceof CallID) {
        this.callIdHeader = null;
      } else if (toRemove instanceof MaxForwards) {
        this.maxForwardsHeader = null;
      } else if (toRemove instanceof ContentLength) {
        this.contentLengthHeader = null;
      }
      Iterator<SIPHeader> li = this.headers.iterator();
      while (li.hasNext()) {
        SIPHeader sipHeader = (SIPHeader) li.next();
        if (sipHeader.getName().equalsIgnoreCase(headerName))
          li.remove();
      }
    }

  }
View Full Code Here


    if (headerName == null)
      throw new NullPointerException("null arg");
    String headerNameLowerCase = SIPHeaderNamesCache
        .toLowerCase(headerName);
    SIPHeader removed = (SIPHeader) nameTable.remove(headerNameLowerCase);
    // nothing to do then we are done.
    if (removed == null)
      return;

    // Remove the fast accessor fields.
    if (removed instanceof From) {
      this.fromHeader = null;
    } else if (removed instanceof To) {
      this.toHeader = null;
    } else if (removed instanceof CSeq) {
      this.cSeqHeader = null;
    } else if (removed instanceof CallID) {
      this.callIdHeader = null;
    } else if (removed instanceof MaxForwards) {
      this.maxForwardsHeader = null;
    } else if (removed instanceof ContentLength) {
      this.contentLengthHeader = null;
    }

    Iterator<SIPHeader> li = this.headers.iterator();
    while (li.hasNext()) {
      SIPHeader sipHeader = (SIPHeader) li.next();
      if (sipHeader.getName().equalsIgnoreCase(headerNameLowerCase))
        li.remove();

    }
  }
View Full Code Here

  }

  private Header getHeaderLowerCase(String lowerCaseHeaderName) {
    if (lowerCaseHeaderName == null)
      throw new NullPointerException("bad name");
    SIPHeader sipHeader = (SIPHeader) nameTable.get(lowerCaseHeaderName);
    if (sipHeader instanceof SIPHeaderList)
      return (Header) ((SIPHeaderList) sipHeader).getFirst();
    else
      return (Header) sipHeader;
  }
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public ListIterator<SIPHeader> getHeaders(String headerName) {
    if (headerName == null)
      throw new NullPointerException("null headerName");
    SIPHeader sipHeader = (SIPHeader) nameTable.get(SIPHeaderNamesCache
        .toLowerCase(headerName));
    // empty iterator
    if (sipHeader == null)
      return new LinkedList<SIPHeader>().listIterator();
    if (sipHeader instanceof SIPHeaderList) {
View Full Code Here

   *            a header name from which to retrieve the list.
   * @return -- a list of headers with that name.
   */
  @SuppressWarnings("unchecked")
  private List<SIPHeader> getHeaderList(String headerName) {
    SIPHeader sipHeader = (SIPHeader) nameTable.get(SIPHeaderNamesCache
        .toLowerCase(headerName));
    if (sipHeader == null)
      return null;
    else if (sipHeader instanceof SIPHeaderList)
      return  (List<SIPHeader>) (((SIPHeaderList<?>) sipHeader).getHeaderList());
View Full Code Here

   * @param sipHeader --
   *            sip header to add.
   */
  public void addHeader(Header sipHeader) {
    // Content length is never stored. Just computed.
    SIPHeader sh = (SIPHeader) sipHeader;
    try {
      if ((sipHeader instanceof ViaHeader)
          || (sipHeader instanceof RecordRouteHeader)) {
        attachHeader(sh, false, true);
      } else {
View Full Code Here

  public void addHeader(String sipHeader) {
    String hdrString = sipHeader.trim() + "\n";
    try {
      HeaderParser parser = ParserFactory.createParser(sipHeader);
      SIPHeader sh = parser.parse();
      this.attachHeader(sh, false);
    } catch (ParseException ex) {
      this.unrecognizedHeaders.add(hdrString);
    }
  }
View Full Code Here

   */
  public ListIterator<String> getHeaderNames() {
    Iterator<SIPHeader> li = this.headers.iterator();
    LinkedList<String> retval = new LinkedList<String>();
    while (li.hasNext()) {
      SIPHeader sipHeader = (SIPHeader) li.next();
      String name = sipHeader.getName();
      retval.add(name);
    }
    return retval.listIterator();
  }
View Full Code Here

    if (nameTable.size() != otherMessage.nameTable.size()) {
      return false;
    }

    while (it.hasNext()) {
      SIPHeader mine = (SIPHeader) it.next();
      SIPHeader his = (SIPHeader) (otherMessage.nameTable
          .get(SIPHeaderNamesCache.toLowerCase(mine.getName())));
      if (his == null) {
        return false;
      } else if (!his.equals(mine)) {
        return false;
      }
    }
    return true;
  }
View Full Code Here

    this.setBranch( via, method );
    newRequest.setHeader(via);
    newRequest.setHeader(cseq);
    Iterator headerIterator = getHeaders();
    while (headerIterator.hasNext()) {
      SIPHeader nextHeader = (SIPHeader) headerIterator.next();
      // Some headers do not belong in a Request ....
      if (SIPMessage.isResponseHeader(nextHeader)
        || nextHeader instanceof ViaList
        || nextHeader instanceof CSeq
        || nextHeader instanceof ContentType
View Full Code Here

TOP

Related Classes of gov.nist.javax.sip.header.SIPHeader

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.