net.sourceforge.jsdp
Class MediaDescription

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

public class MediaDescription
extends Object
implements Description

A MediaDescription identifies the set of medias that may be received. It includes:

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

Field Summary
protected  HashMap attributes
          The attribute fields
protected  HashMap bandwiths
          The bandwith fields
protected  Connection c
          The connection field
protected  Information i
          The information field
protected  Key k
          The key field
protected  Media m
          The media field
 
Constructor Summary
MediaDescription(Media media)
          Creates a new MediaDescription.
 
Method Summary
 void addAttribute(Attribute field)
          Adds an attribute field.
 void addBandwith(Bandwith field)
          Adds a bandwith field.
 void clearAttributes()
          Remove all attribute fields contained in the description.
 void clearBandwiths()
          Remove all bandwith fields contained in the 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 attribute fields with the specified name.
 int getAttributesCount(String name)
          Returns the number of attribute fields with the 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.
 Information getInformation()
          Returns the information field.
 Key getKey()
          Returns the encryption key field.
 Media getMedia()
          Returns the media 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 hasInformation()
          Indicates if the information field is present.
 boolean hasKey()
          Indicates if the encryption key 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 field 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 setInformation(Information i)
          Sets the information field.
 void setKey(Key k)
          Sets the encryption key field.
 void setMedia(Media m)
          Sets the media field.
 String toString()
          Returns a string representation of the description.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m

protected Media m
The media field


i

protected Information i
The information field


c

protected Connection c
The connection field


bandwiths

protected HashMap bandwiths
The bandwith fields


k

protected Key k
The key field


attributes

protected HashMap attributes
The attribute fields

Constructor Detail

MediaDescription

public MediaDescription(Media media)
                 throws IllegalArgumentException
Creates a new MediaDescription.

Parameters:
media - the media field
Throws:
IllegalArgumentException - if the media field is 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 field)
                 throws IllegalArgumentException
Adds a bandwith field. If a Bandwith with the same modifier is already present it will be replaced.

Parameters:
field - the bandwith field to set
Throws:
IllegalArgumentException - if the bandwith field 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 description.


clone

public Object clone()
Description copied from interface: Description
Returns a clone of this description.

Specified by:
clone in interface Description
Overrides:
clone in class Object
Returns:
a clone of this 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()
Returns all attribute fields.

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

getAttributes

public Attribute[] getAttributes(String name)
Returns the attribute fields 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 attribute fields

getAttributesCount

public int getAttributesCount(String name)
Returns the number of attribute fields with the 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 description

getConnection

public Connection getConnection()
Returns the connection field.

Returns:
the connection field is present, null otherwise

getInformation

public Information getInformation()
Returns the information field.

Returns:
the information field if is present, null otherwise

getKey

public Key getKey()
Returns the encryption key field.

Returns:
the encryption key field if present, null otherwise

getMedia

public Media getMedia()
Returns the media field.

Returns:
the media 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

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

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 field with the specified name.

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

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 field to set. It can be null

setInformation

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

Parameters:
i - the field to set. It can be null

setKey

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

Parameters:
k - the field to set. It can be null

setMedia

public void setMedia(Media m)
              throws IllegalArgumentException
Sets the media field.

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

toString

public String toString()
Returns a string representation of the 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.