Package gov.nist.javax.sip.header

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


     * @param top -- flag that indicates which end of header list to process.
     */
    public void removeHeader(String headerName, boolean top) {

        String headerNameLowerCase = SIPHeaderNamesCache.toLowerCase(headerName);
        SIPHeader toRemove = (SIPHeader) headerTable.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
                headerTable.remove(headerNameLowerCase);
            }
        } else {
            this.headerTable.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


    public void removeHeader(String headerName) {

        if (headerName == null)
            throw new NullPointerException("null arg");
        String headerNameLowerCase = SIPHeaderNamesCache.toLowerCase(headerName);
        SIPHeader removed = (SIPHeader) headerTable.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

    }

    protected Header getHeaderLowerCase(String lowerCaseHeaderName) {
        if (lowerCaseHeaderName == null)
            throw new NullPointerException("bad name");
        SIPHeader sipHeader = (SIPHeader) headerTable.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) headerTable.get(SIPHeaderNamesCache
                .toLowerCase(headerName));
        // empty iterator
        if (sipHeader == null)
            return new LinkedList<SIPHeader>().listIterator();
        if (sipHeader instanceof SIPHeaderList) {
View Full Code Here

     * @param headerName -- 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) headerTable.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 {
                attachHeader(sh, false, false);
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.getUnrecognizedHeadersList().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 (headerTable.size() != otherMessage.headerTable.size()) {
            return false;
        }

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

     */
    public LinkedList<String> getMessageAsEncodedStrings() {
        LinkedList<String> retval = new LinkedList<String>();
        Iterator<SIPHeader> li = headers.iterator();
        while (li.hasNext()) {
            SIPHeader sipHeader = (SIPHeader) li.next();
            if (sipHeader instanceof SIPHeaderList) {
                SIPHeaderList< ? > shl = (SIPHeaderList< ? >) sipHeader;
                retval.addAll(shl.getHeadersAsEncodedStrings());
            } else {
                retval.add(sipHeader.encode());
            }
        }

        return retval;
    }
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.