net.sourceforge.jsdp
Class Connection

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

public class Connection
extends Object
implements Field

A Connection represents an c=<field value> field contained in a SDP message.

A connection field is used to identify a network address on which media can be received. For this purpose it also identifies the network type, the address type, the start of an address range, the time to live of the session and the number of addresses in the range, but the time to live and number of addresses are optional.

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

Field Summary
static String IP4
          The IP4 address type
static String IP6
          The IP6 address type
protected  Resource resource
          The network resource specified by the field
 
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
protected Connection()
          Creates a new Connection.
  Connection(String resource)
          Creates a new Connection.
 
Method Summary
 Object clone()
          Returns a clone of this field.
 String getAddress()
          Returns the network address.
 String getAddressType()
          Returns the type of the address.
 String getNetType()
          Returns the network type.
 char getType()
          Returns the type character for the field.
static Connection parse(String field)
          Parse an input string and constructs the equivalent connection field.
 void setAddress(String address)
          Sets the network address.
 void setAddress(String address, int ttl)
          Sets the network address.
 void setAddress(String address, int ttl, int addresses)
          Sets the network address.
 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
 

Field Detail

IP4

public static final String IP4
The IP4 address type

See Also:
Constant Field Values

IP6

public static final String IP6
The IP6 address type

See Also:
Constant Field Values

resource

protected Resource resource
The network resource specified by the field

Constructor Detail

Connection

protected Connection()
Creates a new Connection.


Connection

public Connection(String resource)
           throws SDPException
Creates a new Connection.

Parameters:
resource - the network address on which media can be received. The address type associated with this connection depends by address value
Throws:
SDPException - if the network address is not valid
Method Detail

parse

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

Parameters:
field - the string to parse
Returns:
a new Connection 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 network address.

Returns:
the network address

getAddressType

public String getAddressType()
Returns the type of the address.

Returns:
the type of the address: IP4 or IP6

getNetType

public String getNetType()
Returns the network type.

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

getType

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

Specified by:
getType in interface Field
Returns:
the field type character: c

setAddress

public void setAddress(String address)
                throws SDPException
Sets the network address.

Parameters:
address - the network address
Throws:
SDPException - if the address isn't a valid IP4, IP6 or FQDN address

setAddress

public void setAddress(String address,
                       int ttl)
                throws SDPException
Sets the network address.

Parameters:
address - the network address
ttl - the time to live
Throws:
SDPException - if the address isn't a valid IP4, IP6 or FQDN address, or TTL is minor than 1 or greater than 255

setAddress

public void setAddress(String address,
                       int ttl,
                       int addresses)
                throws SDPException
Sets the network address.

Parameters:
address - the network address
ttl - the time to live
addresses - the number of the addresses
Throws:
SDPException - if the address isn't a valid IP4, IP6 or FQDN address, or TTL is minor than 1 or greater than 255, or the number of addresses is negative

toString

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

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


Copyright © 2004-2008. All Rights Reserved.