All Downloads are FREE. Search and download functionalities are using the official Maven repository.

android.gov.nist.javax.sip.header.ims.PVisitedNetworkID Maven / Gradle / Ivy

There is a newer version: 1.3.0-91
Show newest version
/*
* Conditions Of Use
*
* This software was developed by employees of the National Institute of
* Standards and Technology (NIST), an agency of the Federal Government.
* Pursuant to title 15 Untied States Code Section 105, works of NIST
* employees are not subject to copyright protection in the United States
* and are considered to be in the public domain.  As a result, a formal
* license is not needed to use the software.
*
* This software is provided by NIST as a service and is expressly
* provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  NIST does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement
*
* .
*
*/
/*******************************************
 * PRODUCT OF PT INOVACAO - EST DEPARTMENT *
 *******************************************/

package android.gov.nist.javax.sip.header.ims;

import java.text.ParseException;

import android.javax.sip.header.ExtensionHeader;
import android.javax.sip.header.Parameters;

import android.gov.nist.core.Token;

/**
 * P-Visited-Network-ID SIP Private Header: RFC 3455.
 *
 *
 * @author ALEXANDRE MIGUEL SILVA SANTOS - Nú 10045401
 */



public class PVisitedNetworkID
    extends android.gov.nist.javax.sip.header.ParametersHeader
    implements PVisitedNetworkIDHeader, SIPHeaderNamesIms, ExtensionHeader {

    /**
     * visited Network ID
     */
    private String networkID;

    // issued by Miguel Freitas
    private boolean isQuoted;


    public PVisitedNetworkID() {

        super(P_VISITED_NETWORK_ID);

    }

    public PVisitedNetworkID(String networkID) {

        super(P_VISITED_NETWORK_ID);
        setVisitedNetworkID(networkID);

    }

    public PVisitedNetworkID(Token tok) {

        super(P_VISITED_NETWORK_ID);
        setVisitedNetworkID(tok.getTokenValue());

    }

    public StringBuilder encodeBody(StringBuilder retval) {

//        StringBuilder retval = new StringBuilder();

        if (getVisitedNetworkID() != null)
        {
            // issued by Miguel Freitas
            if (isQuoted)
                retval.append(DOUBLE_QUOTE).append(getVisitedNetworkID()).append(DOUBLE_QUOTE);
            else
                retval.append(getVisitedNetworkID());
        }

        if (!parameters.isEmpty()) {
            retval.append(SEMICOLON);
            this.parameters.encode(retval);
        }

        return retval;

    }

    /**
     * Set the visited network ID as a string. The value will be quoted in the header.
     * @param networkID - string value
     */
    public void setVisitedNetworkID(String networkID) {
        if (networkID == null)
            throw new NullPointerException(" the networkID parameter is null");

        this.networkID = networkID;

        // issued by Miguel Freitas
        this.isQuoted = true;
    }

    /**
     * Set the visited network ID as a token
     * @param networkID - token value
     */
    public void setVisitedNetworkID(Token networkID) {
        if (networkID == null)
            throw new NullPointerException(" the networkID parameter is null");

        this.networkID = networkID.getTokenValue();

        // issued by Miguel Freitas
        this.isQuoted = false;
    }

    /**
     * Get the visited network ID value of this header
     */
    public String getVisitedNetworkID() {
        return networkID;
    }


    public void setValue(String value) throws ParseException {
        throw new ParseException (value,0);

    }


    public boolean equals(Object other)
    {
        if (other instanceof PVisitedNetworkIDHeader)
        {
            PVisitedNetworkIDHeader o = (PVisitedNetworkIDHeader) other;
            return (this.getVisitedNetworkID().equals( o.getVisitedNetworkID() )
                && this.equalParameters( (Parameters) o ));
        }
        return false;
    }


    public Object clone() {
        PVisitedNetworkID retval = (PVisitedNetworkID) super.clone();
        if (this.networkID != null)
            retval.networkID = this.networkID;
        retval.isQuoted = this.isQuoted;
        return retval;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy