org.carrot2.util.resource
Class ResourceLookup

java.lang.Object
  extended by org.carrot2.util.resource.ResourceLookup

public final class ResourceLookup
extends Object

Resource loading utility scanning one or more IResourceLocator locations. If all locators provided to this class are thread-safe, this class is also thread-safe.


Nested Class Summary
static class ResourceLookup.Location
          A set of predefined locations.
 
Constructor Summary
ResourceLookup(IResourceLocator... locators)
          Create a lookup object based on the provided array of resource locators (in order).
ResourceLookup(List<IResourceLocator> locators)
          Create a lookup object based on the provided list of resource locators (in order).
ResourceLookup(ResourceLookup.Location... locations)
          Create a lookup object based on the provided array of predefined locations.
 
Method Summary
 boolean equals(Object target)
           
 IResource[] getAll(String resource)
          Scans all resource locators and returns matching resources.
 IResource getFirst(String resource)
          Scans through resource locators and returns the first matching resource.
 IResourceLocator[] getLocators()
          Returns a copy of the internal locators array.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLookup

public ResourceLookup(ResourceLookup.Location... locations)
Create a lookup object based on the provided array of predefined locations.


ResourceLookup

public ResourceLookup(IResourceLocator... locators)
Create a lookup object based on the provided array of resource locators (in order).


ResourceLookup

public ResourceLookup(List<IResourceLocator> locators)
Create a lookup object based on the provided list of resource locators (in order).

Method Detail

getAll

public IResource[] getAll(String resource)
Scans all resource locators and returns matching resources.

Parameters:
resource - Resource name.
Returns:
Returns an empty array if no resource matched the given name.

getFirst

public IResource getFirst(String resource)
Scans through resource locators and returns the first matching resource.

Parameters:
resource - Resource name.
Returns:
Returns null if no resource was found for the given name.

getLocators

public IResourceLocator[] getLocators()
Returns a copy of the internal locators array.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object target)
Overrides:
equals in class Object


Copyright (c) Dawid Weiss, Stanislaw Osinski