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
Locatorimplementation that operates on URLs.This is a straight forward implementation of the
Locatorinterface 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 theLocatorinterface 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 booleanequals(Object obj)Compares this object with another one.static URLLocatorgetInstance(String sUrl)Returns aURLLocatorinstance for the URL specified as string.static URLLocatorgetInstance(URL url)Returns aURLLocatorinstance for the specified URL.URLgetURL()Returns the URL represented by this locator.inthashCode()Returns a hash code for this object.StringtoString()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 aURLLocatorinstance for the specified URL.- Parameters:
url- the URL (must not be null)- Returns:
- the
URLLocatorinstance for this URL - Throws:
IllegalArgumentException- if the URL is null
-
getInstance
public static URLLocator getInstance(String sUrl)
Returns aURLLocatorinstance 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
URLLocatorfor 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.
-
-