net.sourceforge.jsdp.util
Class Resource

java.lang.Object
  extended by net.sourceforge.jsdp.util.Address
      extended by net.sourceforge.jsdp.util.Resource
All Implemented Interfaces:
Serializable, Cloneable

public class Resource
extends Address

A network resource specified in a SDP message.

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

Field Summary
protected  int addresses
          The number of addresses available for the resource
protected  int ttl
          The resource TTL
 
Fields inherited from class net.sourceforge.jsdp.util.Address
address, addressType, IN, IP4, IP6
 
Constructor Summary
protected Resource()
          Creates a new Resource.
  Resource(String address)
          Creates a new Resource.
  Resource(String address, int ttl)
          Creates a new Resource.
  Resource(String address, int ttl, int addresses)
          Creates a new Resource.
 
Method Summary
 Object clone()
          Returns a clone of this resource.
 int getTTL()
          Returns the TTL.
 boolean hasTTL()
          Indicates if the resource has a TTL.
 void removeTTL()
          Clears the resource's TTL.
 void setAddresses(int addresses)
          Sets the number of addresses of the resource.
 void setTTL(int ttl)
          Sets the resource TTL.
 String toString()
          Returns a string representation of the resource.
 
Methods inherited from class net.sourceforge.jsdp.util.Address
equals, getAddress, getAddressType, isFQDN, isFQDN, isIPAddress, setAddress
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ttl

protected int ttl
The resource TTL


addresses

protected int addresses
The number of addresses available for the resource

Constructor Detail

Resource

protected Resource()
Creates a new Resource.


Resource

public Resource(String address)
         throws SDPException
Creates a new Resource.

Parameters:
address - the resource address. The address may contains ttl and the number of addresses too
Throws:
SDPException - if the resource informations are not valid

Resource

public Resource(String address,
                int ttl)
         throws SDPException
Creates a new Resource.

Parameters:
address - the resource address. The address cannot contains ttl and the number of addresses
ttl - The resource ttl
Throws:
SDPException - if the resource informations are not valid

Resource

public Resource(String address,
                int ttl,
                int addresses)
         throws SDPException
Creates a new Resource.

Parameters:
address - the resource address. The address cannot contains ttl and the number of addresses
ttl - the resource ttl
addresses - the number of addresses available for the resource
Throws:
SDPException - if the resource informations are not valid
Method Detail

clone

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

Overrides:
clone in class Address
Returns:
a clone of this resource

getTTL

public int getTTL()
Returns the TTL.

Returns:
the TTL

hasTTL

public boolean hasTTL()
Indicates if the resource has a TTL.

Returns:
true if the resource has a TTL, false otherwise

removeTTL

public void removeTTL()
Clears the resource's TTL.


setAddresses

public void setAddresses(int addresses)
                  throws SDPException
Sets the number of addresses of the resource.

Parameters:
addresses - the number of addresses
Throws:
SDPException - if the number of addesses is negative

setTTL

public void setTTL(int ttl)
            throws SDPException
Sets the resource TTL.

Parameters:
ttl - the TTL
Throws:
SDPException - if the TTL is minor than 1 or greater than 255

toString

public String toString()
Returns a string representation of the resource.

Overrides:
toString in class Address
Returns:
The string representation of the address


Copyright © 2004-2008. All Rights Reserved.