Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * 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 NIST/ITL Advanced Networking Technologies Division (ANTD). * /
 
 package gov.nist.javax.sdp.fields;
 
Origin Field SDP header

Author(s):
Olivier Deruelle <deruelle@antd.nist.gov>
M. Ranganathan
Version:
JSR141-PUBLIC-REVIEW (subject to change).
 
 public class OriginField extends SDPField implements javax.sdp.Origin {
     protected String username;
     //protected long sessId;
     //protected long sessVersion;
     protected String nettype// IN
     protected String addrtype// IPV4/6
     protected Host address;
     private String sessIdString;
     private String sessVersionString;
 
     public OriginField() {
         super();
     }

    
Returns the name of the session originator.

Returns:
the string username.
Throws:
javax.sdp.SdpParseException
 
     public String getUsername() throws SdpParseException {
         return ;
     }
    
Get the sessionID member.
 
     public long getSessId() {
 
         return Long.valueOf(this.).longValue();
     }
 
     public String getSessIdAsString() {
         return this.;
     }
    
Get the sessionVersion member.
 
     public long getSessVersion() {
 
         return Long.valueOf().longValue();
     }
 
     public String getSessVersionAsString() {
         return this.;
     }
    
Get the netType member.
 
     public String getNettype() {
         return ;
     }
    
Get the address type member.
 
     public String getAddrtype() {
         return ;
    }
    
Get the host member.
    public Host getHost() {
        return ;
    }
    
Set the sessId member
    public void setSessId(long s) {
        this. =  Long.toString(s);
    }

    
This is a work around for some implementations that do not set a long session id.
    public void setSessionId(String sessId) {
        this. = sessId;
    }
    
Set the sessVersion member
    public void setSessVersion(long s) {
         =  Long.toString(s);
    }

    
Set the session version as a string.
    public void setSessVersion(String s) {
        this. = s;
    }
    
Set the nettype member
    public void setNettype(String n) {
         = n;
    }
    
Set the addrtype member
    public void setAddrtype(String a) {
         = a;
    }
    
Set the address member
    public void setAddress(Host a) {
         = a;
    }

    
Sets the name of the session originator.

Parameters:
user the string username.
Throws:
javax.sdp.SdpException if the parameter is null
    public void setUsername(String userthrows SdpException {
        if (user == null)
            throw new SdpException("The user parameter is null");
        else {
            this. = user;
        }
    }

    
Returns the unique identity of the session.

Returns:
the session id.
Throws:
javax.sdp.SdpParseException
    public long getSessionId() throws SdpParseException {
        return getSessId();
    }

    
Sets the unique identity of the session.

Parameters:
id the session id.
Throws:
javax.sdp.SdpException if the id is <0
    public void setSessionId(long idthrows SdpException {
        if (id < 0)
            throw new SdpException("The is parameter is <0");
        else
            setSessId(id);
    }

    
Returns the unique version of the session.

Returns:
the session version.
Throws:
javax.sdp.SdpException
    public long getSessionVersion() throws SdpParseException {
        return getSessVersion();
    }

    
Sets the unique version of the session.

Parameters:
version the session version.
Throws:
javax.sdp.SdpException if the version is <0
    public void setSessionVersion(long versionthrows SdpException {
        if (version < 0)
            throw new SdpException("The version parameter is <0");
        else
            setSessVersion(version);
    }

    
Returns the type of the network for this Connection.

Returns:
the string network type.
Throws:
javax.sdp.SdpParseException
    public String getAddress() throws SdpParseException {
        Host addr = getHost();
        if (addr == null)
            return null;
        else
            return addr.getAddress();
    }

    
Returns the type of the address for this Connection.

Returns:
the string address type.
Throws:
javax.sdp.SdpParseException
    public String getAddressType() throws SdpParseException {
        return getAddrtype();
    }

    
Returns the type of the network for this Connection

Returns:
the string network type.
Throws:
javax.sdp.SdpParseException
    public String getNetworkType() throws SdpParseException {
        return getNettype();
    }

    
Sets the type of the address for this Connection.

Parameters:
addr string address type.
Throws:
javax.sdp.SdpException if the addr is null
    public void setAddress(String addrthrows SdpException {
        if (addr == null)
            throw new SdpException("The addr parameter is null");
        else {
            Host host = getHost();
            if (host == null)
                host = new Host();
            host.setAddress(addr);
            setAddress(host);
        }
    }

    
Returns the type of the network for this Connection.

Parameters:
type the string network type.
Throws:
javax.sdp.SdpException if the type is null
    public void setAddressType(String typethrows SdpException {
        if (type == null)
            throw new SdpException("The type parameter is <0");
        else
            setAddrtype(type);
    }

    
Sets the type of the network for this Connection.

Parameters:
type the string network type.
Throws:
javax.sdp.SdpException if the type is null
    public void setNetworkType(String typethrows SdpException {
        if (type == null)
            throw new SdpException("The type parameter is <0");
        else
            setNettype(type);
    }

    
Get the string encoded version of this object

Since:
v1.0
    public String encode() {
        String addressStr = null;
        if ( != null){
            addressStr = .encode();
            //it appears that SDP does not allow square brackets
            //in the connection address (see RFC4566) so make sure
            //we lose them
            if(Host.isIPv6Reference(addressStr))
            {
                //the isIPv6Reference == true means we have a minimum
                //of 2 symbols, so substring bravely
                addressStr = addressStr
                    .substring(1, addressStr.length()-1);
            }
        }
        return 
            + 
            + .
            + 
            + .
            + 
            + .
            + 
            + .
            + 
            + .
            + addressStr
            + .;
    }
    public Object clone() {
        OriginField retval = (OriginFieldsuper.clone();
        if (this. != null)
            retval.address = (Hostthis..clone();
        return retval;
    }
New to GrepCode? Check out our FAQ X