net.sourceforge.jsdp
Class SessionDescription

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

public class SessionDescription
extends Object
implements Description

A SessionDescription represents the data defined by the Session Description Protocol.

The session description holds information about the originator of a session, the media types that a client can support and the host and port on which the client will listen for that media. It also holds timing information for the session (e.g. start, end, repeat, time zone) and bandwidth supported for the session.

For further information please refer to RFC 4566.

Since:
0.1.0
Version:
1.1
Author:
Claudio Di Vita
See Also:
TimeDescription, MediaDescription, Serialized Form

Field Summary
protected  HashMap attributes
          The attribute fields
protected  HashMap bandwiths
          The bandwith fields
protected  Connection c
          The connection field
protected  ArrayList emails
          The email fields
protected  Information i
          The information field
protected  Key k
          The key field
protected  ArrayList mediaDescriptions
          The media descriptions
protected  Origin o
          The origin field
protected  ArrayList phones
          The phone fields
protected  SessionName s
          The session name field
protected  ArrayList timeDescriptions
          The time descriptions
protected  Uri u
          The uri field
protected  Version v
          The version field
protected  TimeZone z
          The time zone field
 
Constructor Summary
protected SessionDescription()
          Creates a SessionDescription.
protected SessionDescription(SessionDescription sd)
          Creates a SessionDescription.
  SessionDescription(Version v, Origin o, SessionName s, TimeDescription td)
          Creates a SessionDescription.
 
Method Summary
 void addAttribute(Attribute field)
          Adds an attribute field.
 void addBandwith(Bandwith bandwith)
          Adds a bandwith field.
 void addEmail(Email field)
          Adds an email field.
 void addMediaDescription(MediaDescription md)
          Adds a media description.
 void addPhone(Phone field)
          Adds a phone field.
 void addTimeDescription(TimeDescription td)
          Adds a time description.
 void clearAttributes()
          Remove all attribute fields contained in the description.
 void clearBandwiths()
          Remove all bandwith fields contained in the session description.
 void clearEmails()
          Remove all email fields contained in the session description.
 void clearMediaDescriptions()
          Remove all media descriptions contained in the session description.
 void clearPhones()
          Remove all phone fields contained in the session description.
 Object clone()
          Returns a clone of this description.
 Attribute getAttribute(String name)
          Returns the attribute with the specified name.
 Attribute getAttribute(String name, int index)
          Returns a specified occurence of an attribute with the specified name.
 Attribute[] getAttributes()
          Returns all attribute fields.
 Attribute[] getAttributes(String name)
          Returns the attributes with the specified name.
 int getAttributesCount(String name)
          Returns the number of attributes with a specified name
 Bandwith getBandwith(String modifier)
          Returns the bandwith field with a specified modifier.
 Bandwith[] getBandwiths()
          Returns the bandwith fields.
 Connection getConnection()
          Returns the connection field.
 Email[] getEmails()
          Returns the email fields.
 Information getInformation()
          Returns the information field.
 Key getKey()
          Returns the key field.
 MediaDescription[] getMediaDescriptions()
          Returns the media descriptions.
 int getMediaDescriptionsCount()
          Returns the number of media descriptions.
 Origin getOrigin()
          Returns the origin field.
 Phone[] getPhones()
          Returns the phone fields.
 SessionName getSessionName()
          Returns the session name field.
 TimeDescription[] getTimeDescriptions()
          Returns the time descriptions.
 TimeZone getTimeZone()
          Returns the time zone field.
 Uri getUri()
          Returns the uri field.
 Version getVersion()
          Returns the version field.
 boolean hasAttribute(String name)
          Indicates if an attribute with a specified name is present.
 boolean hasConnection()
          Indicates if the connection field is present.
 boolean hasEmails()
          Indicates if one or more email fields are present.
 boolean hasInformation()
          Indicates if the information field is present.
 boolean hasKey()
          Indicates if the encryption key field is present.
 boolean hasPhones()
          Indicates if one or more phone fields are present.
 boolean hasTimeZone()
          Indicates if the timezone field is present.
 boolean hasUri()
          Indicates if the uri field is present
 Attribute removeAttribute(String name)
          Removes the attribute field with an associated name.
 Attribute removeAttribute(String name, int index)
          Removes a specified occurence of an attribute with the specified name.
 Attribute[] removeAttributes(String name)
          Remove all occurencies of attributes with the specified name.
 Bandwith removeBandwith(String modifier)
          Remove the bandwith field with an associated modifier
 void setAttributes(Attribute[] fields)
          Set attribute fields.
 void setBandwiths(Bandwith[] fields)
          Set bandwith fields.
 void setConnection(Connection c)
          Sets the connection field.
 void setEmails(Email[] fields)
          Sets email fields.
 void setInformation(Information i)
          Sets the information field.
 void setKey(Key k)
          Sets the encryption key field.
 void setMediaDescriptions(MediaDescription[] descriptions)
          Sets media descriptions.
 void setOrigin(Origin o)
          Sets the origin field.
 void setPhones(Phone[] fields)
          Sets phone fields.
 void setSessionName(SessionName s)
          Sets session name field.
 void setTimeDescriptions(TimeDescription[] descriptions)
          Sets time descriptions.
 void setTimeZone(TimeZone z)
          Sets the timezone field.
 void setUri(Uri u)
          Sets the uri field.
 void setVersion(Version v)
          Sets the version field.
 String toString()
          Returns a string representation of this description.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

v

protected Version v
The version field


o

protected Origin o
The origin field


s

protected SessionName s
The session name field


i

protected Information i
The information field


u

protected Uri u
The uri field


emails

protected ArrayList emails
The email fields


phones

protected ArrayList phones
The phone fields


c

protected Connection c
The connection field


bandwiths

protected HashMap bandwiths
The bandwith fields


timeDescriptions

protected ArrayList timeDescriptions
The time descriptions


z

protected TimeZone z
The time zone field


k

protected Key k
The key field


attributes

protected HashMap attributes
The attribute fields


mediaDescriptions

protected ArrayList mediaDescriptions
The media descriptions

Constructor Detail

SessionDescription

protected SessionDescription()
Creates a SessionDescription.


SessionDescription

protected SessionDescription(SessionDescription sd)
Creates a SessionDescription. This constructor is used to implement the @link #clone()} method.

Parameters:
sd - the SessionDescription to clone

SessionDescription

public SessionDescription(Version v,
                          Origin o,
                          SessionName s,
                          TimeDescription td)
                   throws IllegalArgumentException
Creates a SessionDescription.

Parameters:
v - the version field
o - the origin field
s - the session name field
td - the time description
Throws:
IllegalArgumentException - if one or more parameters are null
Method Detail

addAttribute

public void addAttribute(Attribute field)
                  throws IllegalArgumentException
Adds an attribute field. If an Attribute with the same name is already present it will be added.

Parameters:
field - the attribute field to set
Throws:
IllegalArgumentException - if the field is null

addBandwith

public void addBandwith(Bandwith bandwith)
                 throws IllegalArgumentException
Adds a bandwith field. If a Bandwith with the same modifier is already present it will be replaced.

Parameters:
bandwith - the bandwith field to set
Throws:
IllegalArgumentException - if the bandwith field is null

addEmail

public void addEmail(Email field)
              throws IllegalArgumentException
Adds an email field.

Parameters:
field - the email field to add
Throws:
IllegalArgumentException - if the field is null

addMediaDescription

public void addMediaDescription(MediaDescription md)
                         throws IllegalArgumentException,
                                SDPException
Adds a media description.

Parameters:
md - the media description to add
Throws:
IllegalArgumentException - if the media description is null
SDPException - if both session and media description doesn't have a connection field

addPhone

public void addPhone(Phone field)
              throws IllegalArgumentException
Adds a phone field.

Parameters:
field - the phone field to add
Throws:
IllegalArgumentException - tf the field is null

addTimeDescription

public void addTimeDescription(TimeDescription td)
                        throws IllegalArgumentException
Adds a time description.

Parameters:
td - the time description to set
Throws:
IllegalArgumentException - if the description is null

clearAttributes

public void clearAttributes()
Remove all attribute fields contained in the description.


clearBandwiths

public void clearBandwiths()
Remove all bandwith fields contained in the session description.


clearEmails

public void clearEmails()
Remove all email fields contained in the session description.


clearMediaDescriptions

public void clearMediaDescriptions()
Remove all media descriptions contained in the session description.


clearPhones

public void clearPhones()
Remove all phone fields contained in the session description.


clone

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

Specified by:
clone in interface Description
Overrides:
clone in class Object
Returns:
a clone of this description

getAttributes

public Attribute[] getAttributes()
Returns all attribute fields.

Returns:
an array that contains the attribute fields contained in the description

getAttribute

public Attribute getAttribute(String name)
Returns the attribute with the specified name. If there are multiple occurencies of attributes with that name, the first one is returned

Parameters:
name - the name of the attribute
Returns:
an attribute field

getAttribute

public Attribute getAttribute(String name,
                              int index)
Returns a specified occurence of an attribute with the specified name.

Parameters:
name - the name of the attribute
index - the occurence index
Returns:
an attribute field

getAttributes

public Attribute[] getAttributes(String name)
Returns the attributes with the specified name.

If there is only an occurence of that attribute the length of returned array is 1, instead if there aren't attributes with the given name the length of returned array is 0

Parameters:
name - the name of the attribute
Returns:
an array of attributes

getAttributesCount

public int getAttributesCount(String name)
Returns the number of attributes with a specified name

Parameters:
name - the name of the attribute
Returns:
an integer

getBandwith

public Bandwith getBandwith(String modifier)
Returns the bandwith field with a specified modifier.

Parameters:
modifier - the bandwith modifier
Returns:
the bandwith field specified by modifier if present, null otherwise

getBandwiths

public Bandwith[] getBandwiths()
Returns the bandwith fields.

Returns:
an array that contains the bandwith fields contained in the session description

getConnection

public Connection getConnection()
Returns the connection field.

Returns:
the connection field if present, null otherwise

getEmails

public Email[] getEmails()
Returns the email fields.

Returns:
an array that contains the email fields contained in the session description

getInformation

public Information getInformation()
Returns the information field.

Returns:
the information field if present, null otherwise

getKey

public Key getKey()
Returns the key field.

Returns:
the key field if present, null otherwise

getMediaDescriptions

public MediaDescription[] getMediaDescriptions()
Returns the media descriptions.

Returns:
an array that contains the media descriptions contained in the session description

getMediaDescriptionsCount

public int getMediaDescriptionsCount()
Returns the number of media descriptions.

Returns:
an integer

getOrigin

public Origin getOrigin()
Returns the origin field.

Returns:
the origin field

getPhones

public Phone[] getPhones()
Returns the phone fields.

Returns:
an array that contains the phone fields contained in the session description

getSessionName

public SessionName getSessionName()
Returns the session name field.

Returns:
the session name field

getTimeDescriptions

public TimeDescription[] getTimeDescriptions()
Returns the time descriptions.

Returns:
an array that contains the time descriptions contained in the session description

getTimeZone

public TimeZone getTimeZone()
Returns the time zone field.

Returns:
the time zone field if present, null otherwise

getUri

public Uri getUri()
Returns the uri field.

Returns:
the uri field if present, null otherwise

getVersion

public Version getVersion()
Returns the version field.

Returns:
the version field

hasAttribute

public boolean hasAttribute(String name)
Indicates if an attribute with a specified name is present.

Parameters:
name - the name of the attribute
Returns:
true if the attribute is present, false otherwise

hasConnection

public boolean hasConnection()
Indicates if the connection field is present.

Returns:
true if the connection field is present, false otherwise

hasEmails

public boolean hasEmails()
Indicates if one or more email fields are present.

Returns:
true if one or more email fields are present, false otherwise

hasInformation

public boolean hasInformation()
Indicates if the information field is present.

Returns:
true if the information field is present, false otherwise

hasKey

public boolean hasKey()
Indicates if the encryption key field is present.

Returns:
true if the encryption key field is present, false otherwise

hasPhones

public boolean hasPhones()
Indicates if one or more phone fields are present.

Returns:
true if one or more phone fields are present, false otherwise

hasTimeZone

public boolean hasTimeZone()
Indicates if the timezone field is present.

Returns:
true if the timezone field is present, false otherwise

hasUri

public boolean hasUri()
Indicates if the uri field is present

Returns:
true if the uri field is present, false otherwise

removeAttribute

public Attribute removeAttribute(String name)
Removes the attribute field with an associated name. If there are multiple occurencies of attributes with that name, the first one is removed

Parameters:
name - the name of the attribute field to remove
Returns:
the removed attribute if present, null otherwise

removeAttribute

public Attribute removeAttribute(String name,
                                 int index)
Removes a specified occurence of an attribute with the specified name.

Parameters:
name - the name of the attribute
index - the occurence index
Returns:
the removed attribute

removeAttributes

public Attribute[] removeAttributes(String name)
Remove all occurencies of attributes with the specified name.

Parameters:
name - the name of the attribute

removeBandwith

public Bandwith removeBandwith(String modifier)
Remove the bandwith field with an associated modifier

Parameters:
modifier - the modifier associated to the bandwith field to remove
Returns:
the removed bandwith if present, null otherwise

setAttributes

public void setAttributes(Attribute[] fields)
Set attribute fields. Please note that previous attributes will be replaced

Parameters:
fields - the fields to set
Throws:
IllegalArgumentException - if one or more field are null

setBandwiths

public void setBandwiths(Bandwith[] fields)
Set bandwith fields. Please note that previous bandwiths will be replaced

Parameters:
fields - the fields to set
Throws:
IllegalArgumentException - if one or more field are null

setConnection

public void setConnection(Connection c)
Sets the connection field.

Parameters:
c - the connection field to set

setEmails

public void setEmails(Email[] fields)
               throws IllegalArgumentException
Sets email fields.

Parameters:
fields - the email fields to set
Throws:
IllegalArgumentException - if one or more field are null

setInformation

public void setInformation(Information i)
Sets the information field.

Parameters:
i - the information field to set

setKey

public void setKey(Key k)
Sets the encryption key field.

Parameters:
k - the encryption key field to set

setMediaDescriptions

public void setMediaDescriptions(MediaDescription[] descriptions)
                          throws IllegalArgumentException,
                                 SDPException
Sets media descriptions.

Parameters:
descriptions - the media descriptions to set
Throws:
IllegalArgumentException - if one or more descriptions are null
SDPException

setOrigin

public void setOrigin(Origin o)
               throws IllegalArgumentException
Sets the origin field.

Parameters:
o - the origin field to set
Throws:
IllegalArgumentException - if the field is null

setPhones

public void setPhones(Phone[] fields)
               throws IllegalArgumentException
Sets phone fields.

Parameters:
fields - the phone fields to set
Throws:
IllegalArgumentException - if one or more phone fields are null

setSessionName

public void setSessionName(SessionName s)
                    throws IllegalArgumentException
Sets session name field.

Parameters:
s - the session name field to set
Throws:
IllegalArgumentException - if the field is null

setTimeDescriptions

public void setTimeDescriptions(TimeDescription[] descriptions)
                         throws IllegalArgumentException
Sets time descriptions.

Parameters:
descriptions - the time descriptions to set
Throws:
IllegalArgumentException - if one or more description are null

setTimeZone

public void setTimeZone(TimeZone z)
Sets the timezone field.

Parameters:
z - the timezone field to set

setUri

public void setUri(Uri u)
Sets the uri field.

Parameters:
u - the uri field to set

setVersion

public void setVersion(Version v)
                throws IllegalArgumentException
Sets the version field.

Parameters:
v - the version field to set
Throws:
IllegalArgumentException - if the field is null

toString

public String toString()
Returns a string representation of this description.

Specified by:
toString in interface Description
Overrides:
toString in class Object
Returns:
A string representation of the description


Copyright © 2004-2008. All Rights Reserved.