org.mmbase.module.builders
Class DayMarkers

java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.module.core.MMTable
          extended by org.mmbase.module.core.MMObjectBuilder
              extended by org.mmbase.module.builders.DayMarkers
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener

public class DayMarkers
extends MMObjectBuilder

Daymarkers are used to calculate the age of MMBase objects. Every day a daymarker is added to the daymarks table. Such an entry consists of a daycount (number of days from 1970), and a count (current object number of that day).

Version:
$Id: DayMarkers.java 41843 2010-04-12 15:04:13Z michiel $
Author:
Daniel Ockeloen,Rico Jansen, Michiel Meeuwissen

Field Summary
static String FIELD_DAYCOUNT
           
static String FIELD_MARK
           
static long MILLISECONDS_IN_A_DAY
           
static long SECONDS_IN_A_DAY
           
 
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, GUI_INDICATOR, GUI_PARAMETERS, guiFunction, infoFunction, internalVersion, nodeCache, oType, pluralNames, searchAge, singularNames, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, TMP_FIELD_EXISTS, 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
DayMarkers()
           
 
Method Summary
 int getAge(int nodeNumber)
          Returns the age, in days, of a node.
 Date getDate(MMObjectNode node)
          Returns the date of a daymarker
 int getDayCount()
          The current day count.
 int getDayCountAge(int daysold)
          Given an age, this function returns a mark, _not a day count_, and also _not an age_!
 int getDayCountByObject(int number)
           
 String getLocaleGUIIndicator(Locale locale, MMObjectNode node)
          Returns gui information for a specific node.
 int getMonthsByDayCount(int daycount)
           
 boolean init()
          Calculate smallestMark, and smallestDay.
 String replace(PageInfo sp, StringTokenizer command)
          Scan.
 void shutdown()
          clean all acquired resources, because system is shutting down
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, commit, create, createAlias, createAlias, delete, equals, equals, executeFunction, executeFunction, fieldLocalChanged, getAncestors, getBlobCache, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBState, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEmptyNode, getField, getFieldNames, getFields, getFields, getFunction, getFunctionParameters, getFunctions, getGUIIndicator, getGUIIndicator, getGUIIndicator, getHTML, getInitParameter, getInitParameters, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedInputStream, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, insert, isExtensionOf, isNodeCached, isNull, isVirtual, loadInitParameters, newFunctionInstance, nodeLocalChanged, nodeRemoteChanged, notify, notify, preCommit, process, removeEventListener, removeField, removeLocalObserver, removeNode, removeRelations, removeRemoteObserver, removeSyncNodes, safeCache, sendFieldChangeSignal, setDefaults, setDescription, setDescriptions, setFields, setInitParameter, setMaintainer, 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_DAYCOUNT

public static final String FIELD_DAYCOUNT
See Also:
Constant Field Values

FIELD_MARK

public static final String FIELD_MARK
See Also:
Constant Field Values

SECONDS_IN_A_DAY

public static final long SECONDS_IN_A_DAY
See Also:
Constant Field Values

MILLISECONDS_IN_A_DAY

public static final long MILLISECONDS_IN_A_DAY
See Also:
Constant Field Values
Constructor Detail

DayMarkers

public DayMarkers()
Method Detail

init

public boolean init()
Calculate smallestMark, and smallestDay. smallestMark is the smallest object number for which a daymark exists. smallestDay is the first daymarker that was set.

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

shutdown

public void shutdown()
Description copied from class: MMObjectBuilder
clean all acquired resources, because system is shutting down

Overrides:
shutdown in class MMObjectBuilder

getAge

public int getAge(int nodeNumber)
Returns the age, in days, of a node. So, this does the inverse of most methods in this class. It converts a node number (which is like a mark) to a day.


getDayCount

public int getDayCount()
The current day count.

Returns:
the number of days from 1970 of today.

getDayCountAge

public int getDayCountAge(int daysold)
Given an age, this function returns a mark, _not a day count_, and also _not an age_!

Parameters:
daysold - a time in days ago.
Returns:
the smallest object number of all objects that are younger than given parameter daysold.

replace

public String replace(PageInfo sp,
                      StringTokenizer command)
Scan. Known tokens are: COUNT-X gets an object number of X days after 1970 COUNTAGE-X gets an object number of X days old COUNTMONTH-X gets an object number of X months after 1970 COUNTNEXTMONTH-X gets an object number of X+1 months after 1970 COUNTPREVMONTH-X gets an object number of X-1 months after 1970 COUNTPREVDELTAMONTH-X-Y gets an object number of X-Y months after 1970 COUNTNEXTDELTAMONTH-X-Y gets an object number of X+Y months after 1970 TIMETOOBJECTNUMBER gets an object number of X seconds after 1970

Overrides:
replace in class MMObjectBuilder
Parameters:
sp - The PageInfo (containing http and user info) that calls the function
command - a list of strings that describe the (sub)command to execute
Returns:
the result value as a String

getDayCountByObject

public int getDayCountByObject(int number)
Javadoc:

getMonthsByDayCount

public int getMonthsByDayCount(int daycount)
Javadoc:

getDate

public Date getDate(MMObjectNode node)
Returns the date of a daymarker

Parameters:
node - The node of which the date is wanted
Returns:
a Date which is the date

getLocaleGUIIndicator

public String getLocaleGUIIndicator(Locale locale,
                                    MMObjectNode node)
Returns gui information for a specific node. This value is retrieved by retrieving the field 'gui()' of the node (node.getStringValue("gui()") )

Overrides:
getLocaleGUIIndicator in class MMObjectBuilder
Parameters:
node - The node of which the gui information is wanted
Returns:
a String in which the current date is shown


MMBase 2.0-SNAPSHOT - null