Package net.sf.freecol.common.resources
Class ResourceMapping
- java.lang.Object
-
- net.sf.freecol.common.resources.ResourceMapping
-
public final class ResourceMapping extends java.lang.Object
Represents a mapping between identifiers and resources.- See Also:
Resource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ResourceMapping.PreloadController
private static class
ResourceMapping.ResourceType<T>
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,AudioResource>
audioResources
private java.util.Map<java.lang.String,ColorResource>
colorResources
private java.util.Map<java.lang.String,FAFileResource>
fafResources
private java.util.Map<java.lang.String,FontResource>
fontResources
private java.util.Map<java.lang.String,ImageResource>
imageResources
private static java.util.logging.Logger
logger
private java.util.Map<java.lang.Class<?>,ResourceMapping.ResourceType<?>>
resourceTypes
private java.util.Map<java.lang.String,StringResource>
stringResources
private java.util.Map<java.lang.String,SZAResource>
szaResources
private java.util.Map<java.lang.String,VideoResource>
videoResources
-
Constructor Summary
Constructors Constructor Description ResourceMapping()
Creates a new emptyResourceMapping
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(java.lang.String key, Resource resource)
void
addAll(ResourceMapping rc)
Adds all mappings from the givenResourceMapping
to this object.void
clearCaches()
boolean
duplicateResource(java.lang.String key, java.lang.String keyNew)
Create another mapping for a Resource under a different key.AudioResource
getAudioResource(java.lang.String key)
Get anAudioResource
by identifier.ColorResource
getColorResource(java.lang.String key)
Get anColorResource
by identifier.FAFileResource
getFAFileResource(java.lang.String key)
Get anFAFileResource
by identifier.FontResource
getFontResource(java.lang.String key)
Get anFontResource
by identifier.java.util.Set<java.lang.String>
getImageKeySet()
Get the image keys in this mapping.ImageResource
getImageResource(java.lang.String key)
Get anImageResource
by identifier.StringResource
getStringResource(java.lang.String key)
Get anStringResource
by identifier.SZAResource
getSZAResource(java.lang.String key)
Get anSZAResource
by identifier.VideoResource
getVideoResource(java.lang.String key)
Get anVideoResource
by identifier.private static java.util.Map<java.lang.Class<?>,ResourceMapping.ResourceType<?>>
mapFrom(ResourceMapping.ResourceType<?>... resourceTypes)
int
preload(ResourceMapping.PreloadController preloadController)
Preload all resources in this mapping.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
colorResources
private final java.util.Map<java.lang.String,ColorResource> colorResources
-
fontResources
private final java.util.Map<java.lang.String,FontResource> fontResources
-
stringResources
private final java.util.Map<java.lang.String,StringResource> stringResources
-
fafResources
private final java.util.Map<java.lang.String,FAFileResource> fafResources
-
szaResources
private final java.util.Map<java.lang.String,SZAResource> szaResources
-
audioResources
private final java.util.Map<java.lang.String,AudioResource> audioResources
-
videoResources
private final java.util.Map<java.lang.String,VideoResource> videoResources
-
imageResources
private final java.util.Map<java.lang.String,ImageResource> imageResources
-
resourceTypes
private final java.util.Map<java.lang.Class<?>,ResourceMapping.ResourceType<?>> resourceTypes
-
-
Method Detail
-
add
public boolean add(java.lang.String key, Resource resource)
-
duplicateResource
public boolean duplicateResource(java.lang.String key, java.lang.String keyNew)
Create another mapping for a Resource under a different key.- Parameters:
key
- The key to find the existing Resource.keyNew
- The new key for the duplicate.- Returns:
- true on success
-
addAll
public void addAll(ResourceMapping rc)
Adds all mappings from the givenResourceMapping
to this object.- Parameters:
rc
- TheResourceMapping
.
-
getAudioResource
public AudioResource getAudioResource(java.lang.String key)
Get anAudioResource
by identifier.- Parameters:
key
- The resource identifier.- Returns:
- The
AudioResource
found.
-
getColorResource
public ColorResource getColorResource(java.lang.String key)
Get anColorResource
by identifier.- Parameters:
key
- The resource identifier.- Returns:
- The
ColorResource
found.
-
getFAFileResource
public FAFileResource getFAFileResource(java.lang.String key)
Get anFAFileResource
by identifier.- Parameters:
key
- The resource identifier.- Returns:
- The
FAFileResource
found.
-
getFontResource
public FontResource getFontResource(java.lang.String key)
Get anFontResource
by identifier.- Parameters:
key
- The resource identifier.- Returns:
- The
FontResource
found.
-
getImageResource
public ImageResource getImageResource(java.lang.String key)
Get anImageResource
by identifier.- Parameters:
key
- The resource identifier.- Returns:
- The
ImageResource
found.
-
getStringResource
public StringResource getStringResource(java.lang.String key)
Get anStringResource
by identifier.- Parameters:
key
- The resource identifier.- Returns:
- The
StringResource
found.
-
getSZAResource
public SZAResource getSZAResource(java.lang.String key)
Get anSZAResource
by identifier.- Parameters:
key
- The resource identifier.- Returns:
- The
SZAResource
found.
-
getVideoResource
public VideoResource getVideoResource(java.lang.String key)
Get anVideoResource
by identifier.- Parameters:
key
- The resource identifier.- Returns:
- The
VideoResource
found.
-
getImageKeySet
public java.util.Set<java.lang.String> getImageKeySet()
Get the image keys in this mapping.- Returns:
- A set of keys.
-
preload
public int preload(ResourceMapping.PreloadController preloadController)
Preload all resources in this mapping.- Parameters:
preloadController
- ThePreloadController
handling this preload.- Returns:
- The number of resources loaded.
-
clearCaches
public void clearCaches()
-
mapFrom
private static final java.util.Map<java.lang.Class<?>,ResourceMapping.ResourceType<?>> mapFrom(ResourceMapping.ResourceType<?>... resourceTypes)
-
-