org.mmbase.module.builders
Class ImageCaches

java.lang.Object
  extended byorg.mmbase.util.functions.FunctionProvider
      extended byorg.mmbase.module.core.MMTable
          extended byorg.mmbase.module.core.MMObjectBuilder
              extended byorg.mmbase.module.builders.AbstractServletBuilder
                  extended byorg.mmbase.module.builders.AbstractImages
                      extended byorg.mmbase.module.builders.ImageCaches
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener

public class ImageCaches
extends AbstractImages

ImageCaches (aka as 'icaches') is a system-like builder used by builders with the 'Images' class. It contains the converted images.

Version:
$Id: ImageCaches.java,v 1.55 2006/06/28 11:05:25 michiel Exp $
Author:
Daniel Ockeloen, Michiel Meeuwissen

Nested Class Summary
 
Nested classes inherited from class org.mmbase.module.builders.AbstractImages
AbstractImages.CKeyCache
 
Field Summary
static String FIELD_ID
           
static Parameter[] WAIT_PARAMETERS
           
 
Fields inherited from class org.mmbase.module.builders.AbstractImages
DIMENSION_PARAMETERS, FIELD_FILESIZE, FIELD_HEIGHT, FIELD_ITYPE, FIELD_WIDTH, handleCache, HEIGHT_PARAMETERS, IMAGE_HANDLE_FIELDS, WIDTH_PARAMETERS
 
Fields inherited from class org.mmbase.module.builders.AbstractServletBuilder
addsFileName, FIELD_FILENAME, FIELD_HANDLE, FIELD_MIMETYPE, FORMAT_PARAMETERS, GUI_PARAMETERS, legalizeFileName, MIMETYPE_PARAMETERS, usesBridgeServlet
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadCastChanges, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, EVENT_TYPE_LOCAL, EVENT_TYPE_REMOTE, FIELD_NUMBER, FIELD_OBJECT_TYPE, FIELD_OWNER, fields, genericBlobCache, getFunctions, guiFunction, infoFunction, internalVersion, nodeCache, oType, searchAge, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, temporaryNodes, TMP_FIELD_NUMBER, virtual, WRAP_PARAMETERS, wrapFunction
 
Fields inherited from class org.mmbase.module.core.MMTable
maxNodesFromQuery, mmb, storageConnector, tableName
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions
 
Constructor Summary
ImageCaches()
           
 
Method Summary
protected  boolean addFileName(MMObjectNode node, String servlet)
           
protected  Object executeFunction(MMObjectNode node, String function, List args)
          Every image of course has a format and a mimetype.
 MMObjectNode getCachedNode(int imageNumber, String template)
          Finds a icache node in the icaches table
protected  Dimension getDimensionForEmptyHandle(MMObjectNode node)
          If icache does not yet have a filled handle field, neither filled width/heigh fields (can occur after a update).
protected  StringBuffer getFileName(MMObjectNode node, StringBuffer buf)
           
protected  String getGUIIndicatorWithAlt(MMObjectNode node, String alt, Parameters a)
          The GUI indicator of an image can have an alt-text.
protected  String getImageFormat(MMObjectNode node)
          Returns the image format.
protected  MMObjectNode getLegacyCachedNode(int imageNumber, String template)
          Finds a icache node in the icache table, supposing 'legacy' ckeys (where all +'s are removed).
 String getMimeType(List params)
           
protected  String getSGUIIndicatorForNode(MMObjectNode node, Parameters a)
          Returns GUI Indicator for node
 boolean init()
          Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called.
 int insert(String owner, MMObjectNode node)
          Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided).
protected  void invalidate(MMObjectNode imageNode)
          Invalidate the Image Cache for a specific Node method only accessable on package level, since only Images should call it..
 void removeNode(MMObjectNode node)
          Override the MMObjectBuilder removeNode, to invalidate the LRU ImageCache, when a node gets deleted.
 void waitForConversion(MMObjectNode node)
          If a icache node is created with empty 'handle' field, then the handle field can be filled automaticly.
 
Methods inherited from class org.mmbase.module.builders.AbstractImages
checkHandle, getAssociation, getBlobCache, getDefaultImageType, getDefaultPath, getDimension, getFileSize, getHandleFields, getMimeType, getSGUIIndicator, storesDimension, storesFileSize, storesImageType
 
Methods inherited from class org.mmbase.module.builders.AbstractServletBuilder
commit, getDefaultFileName, getGUIIndicator, getGUIIndicator, getServletPath, getServletPath, getSession, getSuperGUIIndicator
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, create, createAlias, createAlias, delete, equals, equals, executeFunction, fieldLocalChanged, getAncestors, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBKey, getDBState, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEditFields, getEmptyNode, getField, getFieldNames, getFields, getFields, getFunction, getFunctionParameters, getFunctions, getGUIIndicator, getHardNode, getHardNode, getHTML, getInitParameter, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, isExtensionOf, isNodeCached, isVirtual, newFunctionInstance, nodeLocalChanged, nodeRemoteChanged, notify, notify, preCommit, process, putTmpNode, removeEventListener, removeField, removeLocalObserver, removeRelations, removeRemoteObserver, removeSyncNodes, removeTmpNode, replace, safeCache, sendFieldChangeSignal, setDefaults, setDescription, setDescriptions, setFields, setInitParameter, setMaintainer, setParentBuilder, setPluralNames, setSearchAge, setSingularNames, setUniqueValue, setUniqueValue, setValue, setValue, setVersion, setXMLPath, testValidData, toString, toString, update, updateFields, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
count, count, created, getFullTableName, getMMBase, getNode, getNodes, getNodes, getNodes, getNodeType, getStorageConnector, getTableName, search, searchVector, setMMBase, setTableName, size
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FIELD_ID

public static final String FIELD_ID
See Also:
Constant Field Values

WAIT_PARAMETERS

public static final Parameter[] WAIT_PARAMETERS
Constructor Detail

ImageCaches

public ImageCaches()
Method Detail

init

public boolean init()
Description copied from class: MMObjectBuilder
Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called. The method retrieves data from the TypeDef builder, or adds data to that builder if the current builder is not yet registered.

Overrides:
init in class MMObjectBuilder
Returns:
true if init was completed, false if uncompleted.
See Also:
MMObjectBuilder.create()

getFileName

protected StringBuffer getFileName(MMObjectNode node,
                                   StringBuffer buf)
Overrides:
getFileName in class AbstractServletBuilder

addFileName

protected boolean addFileName(MMObjectNode node,
                              String servlet)
Overrides:
addFileName in class AbstractServletBuilder

getGUIIndicatorWithAlt

protected String getGUIIndicatorWithAlt(MMObjectNode node,
                                        String alt,
                                        Parameters a)
The GUI indicator of an image can have an alt-text.

Specified by:
getGUIIndicatorWithAlt in class AbstractImages
Since:
MMBase-1.6

getSGUIIndicatorForNode

protected String getSGUIIndicatorForNode(MMObjectNode node,
                                         Parameters a)
Description copied from class: AbstractImages
Returns GUI Indicator for node

Overrides:
getSGUIIndicatorForNode in class AbstractImages

waitForConversion

public void waitForConversion(MMObjectNode node)
If a icache node is created with empty 'handle' field, then the handle field can be filled automaticly. Sadly, getValue of MMObjectNode cannot be overriden, so it cannot be done completely automaticly, but that may be more transparent anyway. Call this method (perhaps with node.getFunctionValue("wait", null)) before requesting the handle field. This will method will block until the field is filled.

Parameters:
node - A icache node.

getCachedNode

public MMObjectNode getCachedNode(int imageNumber,
                                  String template)
Finds a icache node in the icaches table

Parameters:
imageNumber - The node number of the image for which it must be searched
template - The image conversion template
Returns:
The icache node or null if it did not exist yet.

getLegacyCachedNode

protected MMObjectNode getLegacyCachedNode(int imageNumber,
                                           String template)
Finds a icache node in the icache table, supposing 'legacy' ckeys (where all +'s are removed).

Parameters:
imageNumber - The node number of the image for which it must be searched
template - The image conversion template
Returns:
The icache node or null if it did not exist.

invalidate

protected void invalidate(MMObjectNode imageNode)
Invalidate the Image Cache for a specific Node method only accessable on package level, since only Images should call it..

Parameters:
imageNode - The image node, which is the original of the cached modifications
Since:
MMBase-1.7

removeNode

public void removeNode(MMObjectNode node)
Override the MMObjectBuilder removeNode, to invalidate the LRU ImageCache, when a node gets deleted. Remove a node from the cloud.

Overrides:
removeNode in class MMObjectBuilder
Parameters:
node - The node to remove.

getImageFormat

protected String getImageFormat(MMObjectNode node)
Returns the image format.

Overrides:
getImageFormat in class AbstractImages
Parameters:
node - The object to use.

getDimensionForEmptyHandle

protected Dimension getDimensionForEmptyHandle(MMObjectNode node)
If icache does not yet have a filled handle field, neither filled width/heigh fields (can occur after a update). The dimension can still be given.

Overrides:
getDimensionForEmptyHandle in class AbstractImages
Since:
MMBase-1.8.1

getMimeType

public String getMimeType(List params)

insert

public int insert(String owner,
                  MMObjectNode node)
Description copied from class: MMObjectBuilder
Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided). This method indirectly calls MMObjectBuilder.preCommit(org.mmbase.module.core.MMObjectNode).

Overrides:
insert in class AbstractServletBuilder

executeFunction

protected Object executeFunction(MMObjectNode node,
                                 String function,
                                 List args)
Every image of course has a format and a mimetype. Two extra functions to get them.

Overrides:
executeFunction in class AbstractImages


MMBase build 1.8.1.20060716