org.iperg.part.core
Class IpUrl

java.lang.Object
  extended by org.iperg.part.core.IpUrl

public class IpUrl
extends java.lang.Object

The IpUrl class is used to represent URLs that express network addresses using a protocol specific syntax. All URLs should have the structure protocol://device:protocol-specific.

Version:
1.0.0 Initial version
Author:
Olov Stahl - olovs@sics.se

Constructor Summary
IpUrl(java.lang.String spec)
          Create a new url object using a given string specification.
IpUrl(java.lang.String protocol, java.lang.String device, java.lang.String protocolSpecific)
          Create a new url instance by giving the protocol, device and protocol specific components separately
 
Method Summary
 boolean equals(java.lang.Object obj)
          Check if the url equals another object.
 java.lang.String getDevice()
          Get the device part of the url.
 java.lang.String getProtocol()
          Get the protocol part of the url.
 java.lang.String getProtocolSpecific()
          Get the protocol specific part of the url.
 java.lang.String toString()
          Create a string representation of this url
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IpUrl

public IpUrl(java.lang.String spec)
Create a new url object using a given string specification. The string syntax should be protocol://device:protocol-specific. The protocol part is the name of a protocol, e.g., udp. The device part is the address or name of a device (e.g., an IP address or a host name). The protocol specific part is optional and there are no syntax restrictions.

Parameters:
spec - A string specification from which the url will be constructed

IpUrl

public IpUrl(java.lang.String protocol,
             java.lang.String device,
             java.lang.String protocolSpecific)
Create a new url instance by giving the protocol, device and protocol specific components separately

Method Detail

toString

public java.lang.String toString()
Create a string representation of this url

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the url

getProtocol

public java.lang.String getProtocol()
Get the protocol part of the url. Will be null if no protocol was part of the url.

Returns:
The protocol part of the url

getDevice

public java.lang.String getDevice()
Get the device part of the url. Will be null if not device was given as part of url.

Returns:
The device part of the url

getProtocolSpecific

public java.lang.String getProtocolSpecific()
Get the protocol specific part of the url. Since this part is optional, value returned may be null.

Returns:
The protocol specific part of the url

equals

public boolean equals(java.lang.Object obj)
Check if the url equals another object. For a url to equal another object, the object must be an instance of the IpUrl class, and its string url must equal the string url of this url object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to compare to this url
Returns:
true if the object equals the url, false otherwise