public abstract class ImageProvider extends Object
ImageTypeDescriptor
.Constructor and Description |
---|
ImageProvider(String identifier,
String pathToDefaultImage)
Create a new ImageProvider.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canLoad(String imageIdentifier)
Test whether a provider can load the image.
|
String |
getDefaultImageMimeType()
Get the mime type of the default image
|
protected long |
getDefaultImageResourceLastModificationTimestamp()
Get the timestamp of the last modification of the default image resource.
|
String |
getDefaultImageVersionString()
The version string of the default image.
|
String |
getIdentifier()
Return the identifier of the provider.
|
int |
getTimeToLive()
Get the number of seconds until a cached image should expire and thus be reloaded
|
abstract String |
getVersionString(String imageIdentifier)
Return a string which represents the version of the image.
|
boolean |
hasDefaultImage(String imageIdentifier)
Return whether the provider has a default image for the case when there is no image for a
given identifier.
|
void |
imageChanged(String imageIdentifier)
Invoked by the
ImageManager.imageChanged(String, String, String) to notify the
provider about a changed image. |
abstract boolean |
isAuthorized(String imageIdentifier)
Return whether the current user is allowed to access the given image.
|
abstract boolean |
isExternalProvider()
Return whether this provider loads image from an external resource (like another server) and
not from the local database or file system.
|
Image |
loadDefaultImage()
Load the default image.
|
abstract Image |
loadImage(String imageIdentifier)
Load the unscaled image
|
public ImageProvider(String identifier, String pathToDefaultImage)
identifier
- The identifier of the provider. The identifier has to be unique among all
providers that are registered for an image type.pathToDefaultImage
- If the path starts with file: it is interpreted as a file URI otherwise it is
interpreted as the name of a resource containing the default image. This resource
will be loaded with the class loader of this class. If null, there will be no
default image.public abstract boolean canLoad(String imageIdentifier)
loadImage(String)
will handle it.imageIdentifier
- the identifier of the imagepublic String getDefaultImageMimeType() throws ImageNotFoundException
ImageNotFoundException
- if there is no (valid) default imageprotected long getDefaultImageResourceLastModificationTimestamp()
getDefaultImageVersionString()
when the default image exists and is resource that
should be loaded with the class loader. This implementation returns the build-timestamp of
the application.public String getDefaultImageVersionString() throws ImageNotFoundException
ImageNotFoundException
- in case there is no default imagegetVersionString(String)
public String getIdentifier()
public int getTimeToLive()
public abstract String getVersionString(String imageIdentifier) throws AuthorizationException, ImageNotFoundException
imageIdentifier
- the identifier of the imageImageNotFoundException
- in case there is no image for the imageIdentifierAuthorizationException
- in case the current user is not allowed to access the imagepublic boolean hasDefaultImage(String imageIdentifier)
imageIdentifier
- the identifier for which no image was foundpublic void imageChanged(String imageIdentifier)
ImageManager.imageChanged(String, String, String)
to notify the
provider about a changed image. The provider can use this method to reset internal caches.
The default implementation does nothing.imageIdentifier
- the identifier of the changed image. Can be null in the case that all images have
changed.public abstract boolean isAuthorized(String imageIdentifier)
imageIdentifier
- identifier of the imagepublic abstract boolean isExternalProvider()
public Image loadDefaultImage() throws ImageNotFoundException
ImageNotFoundException
- in case there is no default image.public abstract Image loadImage(String imageIdentifier) throws ImageNotFoundException, AuthorizationException
imageIdentifier
- The identifier of the imageImageNotFoundException
- in case there is no image for the imageIdentifier or loading failedAuthorizationException
- in case the current user is not allowed to access the imageCopyright © 2019 Communote team. All rights reserved.