Package net.sf.jguiraffe.locators
Class URLLocator
- java.lang.Object
-
- net.sf.jguiraffe.locators.AbstractLocator
-
- net.sf.jguiraffe.locators.URLLocator
-
- All Implemented Interfaces:
Locator
public final class URLLocator extends AbstractLocator
A specialized
Locator
implementation that operates on URLs.This is a straight forward implementation of the
Locator
interface that is based on a URL. New instances can be created using one of thegetInstance()
methods by either passing in a URL or its string representation. The implementation of thegetURL()
method then directly returns this URL. Other methods defined in theLocator
interface are implemented as empty stubs only.Instances of this class are immutable and thus can be shared between multiple threads.
- Version:
- $Id: URLLocator.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Compares this object with another one.static URLLocator
getInstance(String sUrl)
Returns aURLLocator
instance for the URL specified as string.static URLLocator
getInstance(URL url)
Returns aURLLocator
instance for the specified URL.URL
getURL()
Returns the URL represented by this locator.int
hashCode()
Returns a hash code for this object.String
toString()
Returns a string representation of this object.-
Methods inherited from class net.sf.jguiraffe.locators.AbstractLocator
getFile, getInputStream
-
-
-
-
Method Detail
-
getInstance
public static URLLocator getInstance(URL url)
Returns aURLLocator
instance for the specified URL.- Parameters:
url
- the URL (must not be null)- Returns:
- the
URLLocator
instance for this URL - Throws:
IllegalArgumentException
- if the URL is null
-
getInstance
public static URLLocator getInstance(String sUrl)
Returns aURLLocator
instance for the URL specified as string. This method converts the given string into a URL and returns a correspondingURLLocator
.- Parameters:
sUrl
- the URL as string- Returns:
- the
URLLocator
for this URL - Throws:
LocatorException
- if the string cannot be transformed into a URLIllegalArgumentException
- if the string is null
-
getURL
public URL getURL()
Returns the URL represented by this locator. This is simply the URL that was specified when this instance was created.- Returns:
- the URL represented by this locator
-
equals
public boolean equals(Object obj)
Compares this object with another one. Two instance of this class are equal if an only if they refer to the same URL.
-
hashCode
public int hashCode()
Returns a hash code for this object.
-
-