net.sourceforge.jsdp
Class Origin

java.lang.Object
  extended by net.sourceforge.jsdp.Origin
All Implemented Interfaces:
Serializable, Cloneable, Field

public class Origin
extends Object
implements Field

An Origin represents an o=<field value> field contained in a SDP message. The origin field identifies the originator of the session, that is not necessarily the same entity who is involved in the session. This field contains:

These fields should uniquely identify the session.

Since:
0.1.0
Version:
1.0
Author:
Claudio Di Vita
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface net.sourceforge.jsdp.Field
ATTRIBUTE_FIELD, BANDWITH_FIELD, CONNECTION_FIELD, EMAIL_FIELD, END_OF_FIELD, INFORMATION_FIELD, KEY_FIELD, MEDIA_FIELD, ORIGIN_FIELD, PHONE_FIELD, REPEAT_TIME_FIELD, SESSION_NAME_FIELD, TIME_FIELD, TIMEZONE_FIELD, URI_FIELD, VERSION_FIELD
 
Constructor Summary
  Origin()
          Creates a new Origin.
  Origin(long sessionVersion, String address)
          Creates a new Origin.
protected Origin(Origin origin)
          Creates a new Origin.
  Origin(String address)
          Creates a new Origin.
  Origin(String user, long sessionID, long sessionVersion, String address)
          Creates a new Origin.
  Origin(String user, long sessionVersion, String address)
          Creates a new Origin.
 
Method Summary
 Object clone()
          Returns a clone of this field.
 String getAddress()
          Returns the session originator host address.
 String getAddressType()
          Returns the address type.
 String getNetType()
          Returns the network type.
 long getSessionID()
          Returns the session identifier.
 long getSessionVersion()
          Returns the session version.
 char getType()
          Returns the type character for the field
 String getUser()
          Returns the name of the session originator.
static Origin parse(String field)
          Parse an input string and constructs the equivalent origin field.
 void setAddress(String address)
          Sets the session originator host address.
 void setSessionID(long sessionID)
          Sets the session identifier.
 void setSessionVersion(long sessionVersion)
          Sets the session version.
 void setUser(String user)
          Sets the name of the session originator.
 String toString()
          Returns a string representation of the field.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Origin

public Origin()
       throws SDPException
Creates a new Origin. The values are sets as follows:

o=<user> <current time as NTP> <current time as NTP> <localhost name>

The <user> value is the name of the OS user that invokes this method.

Throws:
SDPException - if no IP address for the local host could be found, or the current user name contains characters that are not allowed

Origin

public Origin(long sessionVersion,
              String address)
       throws SDPException
Creates a new Origin. The session id was generated automatically using NTP and the user value is set with the name of the OS user that invokes this constructor.

Parameters:
sessionVersion - the session version
address - the session originator host address
Throws:
SDPException - if one or more parameter provided are not valid

Origin

protected Origin(Origin origin)
Creates a new Origin. This constructor is used to implement the clone() method, because this class has a default constructor that performs some operations that aren't required while cloning a field.

Parameters:
origin - the Origin to clone

Origin

public Origin(String address)
       throws SDPException
Creates a new Origin. Both session identifier and session version were generated automatically using NTP and the user value is set with the name of the OS user that invokes this constructor.

Parameters:
address - the session originator host address
Throws:
SDPException - if the address are not valid

Origin

public Origin(String user,
              long sessionID,
              long sessionVersion,
              String address)
       throws SDPException
Creates a new Origin.

Parameters:
user - the name of the session originator
sessionID - the session identifier
sessionVersion - the session version
address - the session originator host address
Throws:
SDPException - if one or more parameter provided are not valid

Origin

public Origin(String user,
              long sessionVersion,
              String address)
       throws SDPException
Creates a new Origin.

Parameters:
user - the name of the session originator
sessionVersion - the session version
address - the session originator host address
Throws:
SDPException - if one or more parameter provided are not valid
Method Detail

parse

public static Origin parse(String field)
                    throws SDPParseException
Parse an input string and constructs the equivalent origin field.

Parameters:
field - the string to parse
Returns:
a new Origin instance
Throws:
SDPParseException - if an error occurs while parsing

clone

public Object clone()
Returns a clone of this field.

Specified by:
clone in interface Field
Overrides:
clone in class Object
Returns:
a clone of this field

getAddress

public String getAddress()
Returns the session originator host address.

Returns:
the session originator host address

getAddressType

public String getAddressType()
Returns the address type.

Returns:
the address type

getNetType

public String getNetType()
Returns the network type.

Returns:
the network type. Because SDP was used in Internet, this method always returns IN

getSessionID

public long getSessionID()
Returns the session identifier.

Returns:
the session identifier

getSessionVersion

public long getSessionVersion()
Returns the session version.

Returns:
the session version

getType

public char getType()
Returns the type character for the field

Specified by:
getType in interface Field
Returns:
The field type character: o

getUser

public String getUser()
Returns the name of the session originator.

Returns:
the session originator's name

setAddress

public void setAddress(String address)
                throws SDPException
Sets the session originator host address.

Parameters:
address - the session originator host address
Throws:
SDPException - if the address is not valid

setSessionID

public void setSessionID(long sessionID)
                  throws SDPException
Sets the session identifier.

Parameters:
sessionID - the session identifier
Throws:
SDPException - if the session identifier is negative

setSessionVersion

public void setSessionVersion(long sessionVersion)
                       throws SDPException
Sets the session version.

Parameters:
sessionVersion - the session version
Throws:
SDPException - if the session version is negative

setUser

public void setUser(String user)
             throws SDPException
Sets the name of the session originator.

Parameters:
user - the name of the session creator
Throws:
SDPException - if the name is not valid (for example it contains spaces)

toString

public String toString()
Returns a string representation of the field. The representation has the form: <type>=<value>.

Specified by:
toString in interface Field
Overrides:
toString in class Object
Returns:
the string representation of the field


Copyright © 2004-2008. All Rights Reserved.