org.mmbase.core.event
Class NodeEvent

java.lang.Object
  extended byorg.mmbase.core.event.Event
      extended byorg.mmbase.core.event.NodeEvent
All Implemented Interfaces:
Cloneable, PublicCloneable, Serializable

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,v 1.27 2006/06/20 21:23:57 michiel Exp $
Author:
Ernst Bunders
See Also:
Serialized Form

Field Summary
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 oldValues, Map newValues, int eventType)
           
 
Method Summary
 boolean equals(Object o)
           
 String getBuilderName()
           
 Set getChangedFields()
           
protected static String getEventTypeGuiName(int eventType)
           
 Object getNewValue(String fieldName)
           
 Map getNewValues()
          new values can be different things.
 int getNodeNumber()
           
 Object getOldValue(String fieldName)
           
 Map getOldValues()
          old values can be different things.
 boolean hasChanged(String fieldName)
          utility method: check if a certain field has changed
 int hashCode()
           
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(String eventType)
          For conveneance: conversion of the old event type indication to the new style
 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
Constructor Detail

NodeEvent

public NodeEvent(String machineName,
                 String builderName,
                 int nodeNumber,
                 Map oldValues,
                 Map 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
newValues - map with new values of changed fields
eventType - the type of event
Method Detail

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 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.

toString

public String toString()

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)
For conveneance: conversion of the old event type indication to the new style

Parameters:
eventType -

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()

equals

public boolean equals(Object o)

getOldValues

public final Map 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 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 build 1.8.1.20060716