Package net.sf.freecol.common.resources
Class ResourceMapping
- java.lang.Object
-
- net.sf.freecol.common.resources.ResourceMapping
-
public final class ResourceMapping extends java.lang.ObjectRepresents a mapping between identifiers and resources.- See Also:
Resource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceResourceMapping.PreloadControllerprivate static classResourceMapping.ResourceType<T>
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,AudioResource>audioResourcesprivate java.util.Map<java.lang.String,ColorResource>colorResourcesprivate java.util.Map<java.lang.String,FAFileResource>fafResourcesprivate java.util.Map<java.lang.String,FontResource>fontResourcesprivate java.util.Map<java.lang.String,ImageResource>imageResourcesprivate static java.util.logging.Loggerloggerprivate java.util.Map<java.lang.Class<?>,ResourceMapping.ResourceType<?>>resourceTypesprivate java.util.Map<java.lang.String,StringResource>stringResourcesprivate java.util.Map<java.lang.String,SZAResource>szaResourcesprivate 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 booleanadd(java.lang.String key, Resource resource)voidaddAll(ResourceMapping rc)Adds all mappings from the givenResourceMappingto this object.voidclearCaches()booleanduplicateResource(java.lang.String key, java.lang.String keyNew)Create another mapping for a Resource under a different key.AudioResourcegetAudioResource(java.lang.String key)Get anAudioResourceby identifier.ColorResourcegetColorResource(java.lang.String key)Get anColorResourceby identifier.FAFileResourcegetFAFileResource(java.lang.String key)Get anFAFileResourceby identifier.FontResourcegetFontResource(java.lang.String key)Get anFontResourceby identifier.java.util.Set<java.lang.String>getImageKeySet()Get the image keys in this mapping.ImageResourcegetImageResource(java.lang.String key)Get anImageResourceby identifier.StringResourcegetStringResource(java.lang.String key)Get anStringResourceby identifier.SZAResourcegetSZAResource(java.lang.String key)Get anSZAResourceby identifier.VideoResourcegetVideoResource(java.lang.String key)Get anVideoResourceby identifier.private static java.util.Map<java.lang.Class<?>,ResourceMapping.ResourceType<?>>mapFrom(ResourceMapping.ResourceType<?>... resourceTypes)intpreload(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 givenResourceMappingto this object.- Parameters:
rc- TheResourceMapping.
-
getAudioResource
public AudioResource getAudioResource(java.lang.String key)
Get anAudioResourceby identifier.- Parameters:
key- The resource identifier.- Returns:
- The
AudioResourcefound.
-
getColorResource
public ColorResource getColorResource(java.lang.String key)
Get anColorResourceby identifier.- Parameters:
key- The resource identifier.- Returns:
- The
ColorResourcefound.
-
getFAFileResource
public FAFileResource getFAFileResource(java.lang.String key)
Get anFAFileResourceby identifier.- Parameters:
key- The resource identifier.- Returns:
- The
FAFileResourcefound.
-
getFontResource
public FontResource getFontResource(java.lang.String key)
Get anFontResourceby identifier.- Parameters:
key- The resource identifier.- Returns:
- The
FontResourcefound.
-
getImageResource
public ImageResource getImageResource(java.lang.String key)
Get anImageResourceby identifier.- Parameters:
key- The resource identifier.- Returns:
- The
ImageResourcefound.
-
getStringResource
public StringResource getStringResource(java.lang.String key)
Get anStringResourceby identifier.- Parameters:
key- The resource identifier.- Returns:
- The
StringResourcefound.
-
getSZAResource
public SZAResource getSZAResource(java.lang.String key)
Get anSZAResourceby identifier.- Parameters:
key- The resource identifier.- Returns:
- The
SZAResourcefound.
-
getVideoResource
public VideoResource getVideoResource(java.lang.String key)
Get anVideoResourceby identifier.- Parameters:
key- The resource identifier.- Returns:
- The
VideoResourcefound.
-
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- ThePreloadControllerhandling 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)
-
-