Package net.sf.freecol.common.resources
Class Resource
- java.lang.Object
-
- net.sf.freecol.common.resources.Resource
-
- Direct Known Subclasses:
AudioResource
,ColorResource
,FAFileResource
,FontResource
,ImageResource
,StringResource
,SZAResource
,VideoResource
public abstract class Resource extends java.lang.Object
Represents a resource that either has been or can be loaded using aURI
. There can only be one instance ofResource
having the same (as in URI's equals, not the identity)URI
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Resource.Cleanable
Implement the Cleanable interface if a Resource has a use for calls to a clean method.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
primaryKey
The primary key for the resource to be used for caching purposes.private java.net.URI
resourceLocator
TheURI
used when loading this resource.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
getPrimaryKey()
The primary key of the resource.java.net.URI
getResourceLocator()
Returns theURI
used for loading the resource.abstract void
preload()
Preload the resource if possible/meaningful.
-
-
-
Constructor Detail
-
Resource
protected Resource(java.lang.String primaryKey)
Trivial constructor.- Parameters:
primaryKey
- The primary key.
-
Resource
protected Resource(java.lang.String primaryKey, java.net.URI resourceLocator)
Do not use directly.- Parameters:
primaryKey
- The key for the primary version of the resource, that is the key when theResource
was created.resourceLocator
- TheURI
used when loading this resource.
-
-
Method Detail
-
getPrimaryKey
public java.lang.String getPrimaryKey()
The primary key of the resource. This key can be used for caching purposes since it will be the same for a resource no matter how many keys point to the same resource. Beware: All variations and sizes share the same primary key.- Returns:
- The key.
-
getResourceLocator
public java.net.URI getResourceLocator()
Returns theURI
used for loading the resource.- Returns:
- The
URI
.
-
preload
public abstract void preload()
Preload the resource if possible/meaningful.
-
-