org.peaseplate.internal.locator
Class AbstractClassLoaderLocator

java.lang.Object
  extended by org.peaseplate.locator.AbstractLocator
      extended by org.peaseplate.locator.AbstractURLBasedLocator
          extended by org.peaseplate.internal.locator.AbstractClassLoaderLocator
All Implemented Interfaces:
java.io.Serializable, Locator
Direct Known Subclasses:
ClassLoaderMessagesLocator, ClassLoaderTemplateLocator

public abstract class AbstractClassLoaderLocator
extends AbstractURLBasedLocator

An abstract implementation of a locator that is based on the class loader

See Also:
Serialized Form

Constructor Summary
AbstractClassLoaderLocator(java.net.URL url, java.lang.String resource, ResourceKey key)
          Creates the class loader locator
AbstractClassLoaderLocator(java.net.URL url, java.lang.String resource, java.lang.String name, java.util.Locale locale, java.lang.String encoding)
          Creates the class loader locator
 
Method Summary
 java.lang.String getResource()
          Returns the resource this locator is based on
protected static java.net.URL getResource(java.util.Collection<java.lang.ClassLoader> classLoaders, java.lang.String path)
          Searches for the resource in the class loaders and returns the url if found
protected static java.lang.String toCannonical(java.lang.String path)
          Converts the path to a connonical form (without ../ and ./)
 java.lang.String toString()
          A meaningful representation of the locator, mainly used for textual output e.g. in error messages
 
Methods inherited from class org.peaseplate.locator.AbstractURLBasedLocator
getUrl, isOutdated, updateMetadata
 
Methods inherited from class org.peaseplate.locator.AbstractLocator
getKey, getRawSize, getTimestamp, setRawSize, setTimestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractClassLoaderLocator

public AbstractClassLoaderLocator(java.net.URL url,
                                  java.lang.String resource,
                                  java.lang.String name,
                                  java.util.Locale locale,
                                  java.lang.String encoding)
                           throws java.lang.IllegalArgumentException
Creates the class loader locator

Parameters:
url - the url
path - the path
name - the name
locale - the locale
encoding - the encoding
Throws:
java.lang.IllegalArgumentException - if the path or the name is null

AbstractClassLoaderLocator

public AbstractClassLoaderLocator(java.net.URL url,
                                  java.lang.String resource,
                                  ResourceKey key)
                           throws java.lang.IllegalArgumentException
Creates the class loader locator

Parameters:
url - the url
path - the path
key - the key
Throws:
java.lang.IllegalArgumentException - if the path or the key is null
Method Detail

getResource

public java.lang.String getResource()
Returns the resource this locator is based on

Returns:
the resource this locator is based on

toString

public java.lang.String toString()
Description copied from interface: Locator
A meaningful representation of the locator, mainly used for textual output e.g. in error messages

Specified by:
toString in interface Locator
Overrides:
toString in class AbstractURLBasedLocator
Returns:
a meaningful representation of the locator
See Also:
Object.toString()

toCannonical

protected static java.lang.String toCannonical(java.lang.String path)
Converts the path to a connonical form (without ../ and ./)

Parameters:
path - the path
Returns:
the result

getResource

protected static java.net.URL getResource(java.util.Collection<java.lang.ClassLoader> classLoaders,
                                          java.lang.String path)
                                   throws java.lang.IllegalArgumentException
Searches for the resource in the class loaders and returns the url if found

Parameters:
classLoaders - the class loaders to search
path - the path to the resource
Returns:
the url if found
Throws:
java.lang.IllegalArgumentException - if the path is null


Copyright © 2008. All Rights Reserved.