org.apache.tapestry
Interface IResourceLocation

All Known Implementing Classes:
AbstractResourceLocation, ClasspathResourceLocation, ContextResourceLocation

public interface IResourceLocation

Describes the location of a resource, such as a specification or template. Resources may be located within the classpath, or within the Web context root or somewhere else entirely.

Resources may be either base or localized. A localized version of a base resource may be obtained via getLocalization(Locale).

Resource locations are used as Map keys, they must implement Object.hashCode() and Object.equals(java.lang.Object) properly.

Resource locations are valid even if the corresponding resource doesn't exist. To verify if a localization actually exists, use getResourceURL(), which returns null if the resource doesn't exist. getLocalization(Locale) returns only real resource locations, where the resource exists.

Folders must be represented with a trailing slash.

Since:
3.0
Version:
$Id: IResourceLocation.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship

Method Summary
 Locale getLocale()
          Returns the locale for which this resource has been localized or null if the resource has not been localized.
 IResourceLocation getLocalization(Locale locale)
          Returns a localized version of this resource (or this resource, if no appropriate localization is found).
 String getName()
          Returns the file name portion of the resource location.
 String getPath()
          Returns the path that represents the resource.
 IResourceLocation getRelativeLocation(String name)
          Returns at a relative location to this resource.
 URL getResourceURL()
          Returns a URL for the resource.
 

Method Detail

getResourceURL

URL getResourceURL()
Returns a URL for the resource.

Returns:
the URL for the resource if it exists, or null if it does not

getName

String getName()
Returns the file name portion of the resource location.


getLocalization

IResourceLocation getLocalization(Locale locale)
Returns a localized version of this resource (or this resource, if no appropriate localization is found). Should only be invoked on a base resource.

Parameters:
locale - to localize for, or null for no localization.
Returns:
a localized version of this resource, of null if the resource itself does not exist.

getRelativeLocation

IResourceLocation getRelativeLocation(String name)
Returns at a relative location to this resource. The new resource may or may not exist; this can be determined via getResourceURL().

Parameters:
name - name of new resource, possibly as a relative path, or as an absolute path (starting with a slash).

getPath

String getPath()
Returns the path that represents the resource. This should only be used when the type of resource is known.


getLocale

Locale getLocale()
Returns the locale for which this resource has been localized or null if the resource has not been localized. This should only be used when the type of resource is known. This locale is the same or more general than the locale for which localization was requested. For example, if the requested locale was en_US, but only the file Home_en was found, this locale returned would be en.