org.mmbase.core.event
Class NodeEvent

java.lang.Object
  extended by org.mmbase.core.event.Event
      extended by org.mmbase.core.event.NodeEvent
All Implemented Interfaces:
Serializable, Cloneable, PublicCloneable<Event>

public class NodeEvent
extends Event

This class communicates a node event. in case of a change event, it contains a map of changed values, mapped to their field's name, as well as the previous values of the changed fields.

Since:
MMBase-1.8
Version:
$Id: NodeEvent.java 42350 2010-05-31 16:03:05Z michiel $
Author:
Ernst Bunders
See Also:
Serialized Form

Field Summary
(package private) static UtilReader properties
           
static int TYPE_RELATION_CHANGE
          Event type speicfic for MMBase nodes.
 
Fields inherited from class org.mmbase.core.event.Event
eventType, machine, TYPE_CHANGE, TYPE_DELETE, TYPE_NEW, TYPE_UNSPECIFIED
 
Constructor Summary
NodeEvent(String machineName, String builderName, int nodeNumber, Map<String,Object> oldValues, Map<String,Object> newValues, int eventType)
           
 
Method Summary
(package private) static void configure()
          Reads nodeevents.xml
 boolean equals(Object o)
           
 String getBuilderName()
           
 Set<String> getChangedFields()
           
protected static String getEventTypeGuiName(int eventType)
           
 Object getNewValue(String fieldName)
           
 Map<String,Object> getNewValues()
          new values can be different things.
 int getNodeNumber()
           
 Object getOldValue(String fieldName)
           
 Map<String,Object> getOldValues()
          old values can be different things.
static Class[] getRequiredValueTypes()
          Gets the types (interfaces) which values must implement in the values and oldvalues maps.
static Class[] getUnacceptableValueTypes()
          Sets the types of which values are unacceptable in the values and oldvalues maps.
 boolean hasChanged(String fieldName)
          utility method: check if a certain field has changed
 int hashCode()
           
 boolean isRelation()
          Especially events of the type NEW can also be about relations.
static void main(String[] args)
           
static String newTypeToOldType(int eventType)
          For conveneance: conversion of the new event type indication to the old style
static int oldTypeToNewType(char eventType)
          For conveneance: conversion of the old event type indication to the new style
static int oldTypeToNewType(String eventType)
           
(package private) static void setRequiredValueTypes(Class[] types)
           
(package private) static void setUnacceptableValueTypes(Class[] types)
           
 String toString()
           
 
Methods inherited from class org.mmbase.core.event.Event
clone, getMachine, getType, isLocal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_RELATION_CHANGE

public static final int TYPE_RELATION_CHANGE
Event type speicfic for MMBase nodes.

See Also:
Constant Field Values

properties

static final UtilReader properties
Since:
MMBase-1.9.4
Constructor Detail

NodeEvent

public NodeEvent(String machineName,
                 String builderName,
                 int nodeNumber,
                 Map<String,Object> oldValues,
                 Map<String,Object> newValues,
                 int eventType)
Parameters:
machineName - (MMBase) name of the server
builderName - name of builder of node event is about
oldValues - map with fields and their values that have been changed by the event. This may be null
newValues - map with new values of changed fields
eventType - the type of event
Method Detail

setUnacceptableValueTypes

static void setUnacceptableValueTypes(Class[] types)
Since:
MMBase-1.9.4
See Also:
getUnacceptableValueTypes()

setRequiredValueTypes

static void setRequiredValueTypes(Class[] types)
Since:
MMBase-1.9.4
See Also:
getRequiredValueTypes()

getUnacceptableValueTypes

public static Class[] getUnacceptableValueTypes()
Sets the types of which values are unacceptable in the values and oldvalues maps. This can be configured in config/utils/nodeevents.xml This defaults to [byte[]], but you can add other larges types too e.g. String. You could also set it to Object.class not not include any values in the event.

Since:
MMBase-1.9.4

getRequiredValueTypes

public static Class[] getRequiredValueTypes()
Gets the types (interfaces) which values must implement in the values and oldvalues maps. This can be configured in config/utils/nodeevents.xml This defaults to [java.io.Serializable]. The values must be serializable, otherwise the event itself is not properly serializable, which is needed in a clustering environment.

Since:
MMBase-1.9.4

configure

static void configure()
Reads nodeevents.xml

Since:
MMBase-1.9.4

getOldValue

public final Object getOldValue(String fieldName)
Parameters:
fieldName - the field you want to get the old value of
Returns:
an Object containing the old value (in case of change event), or null if the fieldName was not found in the old value list

getChangedFields

public final Set<String> getChangedFields()
Returns:
a set containing the names of the fields that have changed

getNewValue

public final Object getNewValue(String fieldName)
Parameters:
fieldName - the field you want the new value of (in case of change event), or null if the fieldName was not found in the new value list
Returns:
the new value of the field

getBuilderName

public final String getBuilderName()
Returns:
Returns the builderName.

getNodeNumber

public final int getNodeNumber()
Returns:
Returns the nodeNumber.

isRelation

public boolean isRelation()
Especially events of the type NEW can also be about relations. You may want to know this. This determines it efficiently without actually getting the node from the database.

Since:
MMBase-1.9.4

toString

public String toString()
Overrides:
toString in class Object

getEventTypeGuiName

protected static String getEventTypeGuiName(int eventType)

newTypeToOldType

public static String newTypeToOldType(int eventType)
For conveneance: conversion of the new event type indication to the old style

Parameters:
eventType - must be c,d,n or r
Returns:
A String describing the type of an event. (like "c" (change), "d" (delete), "n" (new), or "r" (relation change))

oldTypeToNewType

public static int oldTypeToNewType(String eventType)

oldTypeToNewType

public static int oldTypeToNewType(char eventType)
For conveneance: conversion of the old event type indication to the new style

Parameters:
eventType -
Since:
MMBase-1.9.2

hasChanged

public boolean hasChanged(String fieldName)
utility method: check if a certain field has changed

Parameters:
fieldName -
Returns:
true if the field of given name is among the changed fields

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getOldValues

public final Map<String,Object> getOldValues()
old values can be different things.

Returns:
a map where the key is a fieldname and the value the field's value

getNewValues

public final Map<String,Object> getNewValues()
new values can be different things.

Returns:
a map where the key is a fieldname and the value the field's value

main

public static void main(String[] args)


MMBase 2.0-SNAPSHOT - null