com.inet.html.image
Class ImageCache

java.lang.Object
  extended by com.inet.html.image.ImageCache

public class ImageCache
extends java.lang.Object

JWebEngine Image Cache. Caches the images by soft references, generates id's for images without URL.


Constructor Summary
ImageCache()
           
 
Method Summary
 void addImage(java.lang.String identifier, java.net.URL base, java.awt.Image content)
          Adds a certain image to the cache
 RemoteImage getImage(java.lang.String identifier, java.net.URL base, java.awt.image.ImageObserver observer)
          Loads a certain image or returns it's cached instance
static ImageCache getStaticInstance()
          Returns the static cache.
 boolean isCacheReference(java.lang.String identifier)
          Returns true, if the identifier is a cache ID.
 java.lang.String registerImage(java.awt.Image content)
          Stores an image content to the cache an generates an ID for this content
 boolean removeKey(java.lang.String identifier, java.net.URL base)
          Removes a cache entry, if known
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageCache

public ImageCache()
Method Detail

getStaticInstance

public static ImageCache getStaticInstance()
Returns the static cache.

Returns:
the static cache, never null

getImage

public RemoteImage getImage(java.lang.String identifier,
                            java.net.URL base,
                            java.awt.image.ImageObserver observer)
Loads a certain image or returns it's cached instance

Parameters:
identifier - the identifier (may be a cache ID, a relative or absolute URL)
base - the base URL of the current document, required to resolve relative URLs
observer - the observer to notify of the load progress
Returns:
the image wrapper or null in case of an error

addImage

public void addImage(java.lang.String identifier,
                     java.net.URL base,
                     java.awt.Image content)
Adds a certain image to the cache

Parameters:
identifier - the identifier (may be a cache ID, a relative or absolute URL)
base - the base URL of the current document, required to resolve relative URLs
content - the image content to add to the cache

removeKey

public boolean removeKey(java.lang.String identifier,
                         java.net.URL base)
Removes a cache entry, if known

Parameters:
identifier - the identifier or an absolute or relative URL
base - the base URL for relative URL identifiers
Returns:
true, if the cache map was modified

registerImage

public java.lang.String registerImage(java.awt.Image content)
Stores an image content to the cache an generates an ID for this content

Parameters:
content - the content to store
Returns:
the generaded ID for this content

isCacheReference

public boolean isCacheReference(java.lang.String identifier)
Returns true, if the identifier is a cache ID. This does NOT mean that there is an cache entry for this ID.

Parameters:
identifier - the identifier to be checked, may be null
Returns:
true, if it's a cache ID pattern, false otherwise