net.sf.freecol.common.resources
Class ResourceFactory

java.lang.Object
  extended by net.sf.freecol.common.resources.ResourceFactory

public class ResourceFactory
extends java.lang.Object

A factory class for creating Resource instances.

See Also:
Resource

Field Summary
private static java.util.logging.Logger logger
           
private static java.util.Map<java.net.URI,java.lang.ref.WeakReference<Resource>> resources
          A WeakHashMap to ensure that only one Resource is created given the same URI.
 
Constructor Summary
ResourceFactory()
           
 
Method Summary
static Resource createResource(java.net.URI uri)
          Returns an instance of Resource with the given URI as the parameter.
private static Resource getResource(java.net.URI uri)
          Gets the resource with the given URI from resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

resources

private static java.util.Map<java.net.URI,java.lang.ref.WeakReference<Resource>> resources
A WeakHashMap to ensure that only one Resource is created given the same URI.

Constructor Detail

ResourceFactory

public ResourceFactory()
Method Detail

getResource

private static Resource getResource(java.net.URI uri)
Gets the resource with the given URI from resources.

Parameters:
uri - The URI to identify a previously created Resource.
Returns:
The Resource identified by the given URI, or null if no such Resource exists.

createResource

public static Resource createResource(java.net.URI uri)
Returns an instance of Resource with the given URI as the parameter.

Parameters:
uri - The URI used when creating the instance.
Returns:
A previously created instance of Resource with the given URI if such an object has already been created, or a new instance if not.