fr.inria.ketuk
Class XBMapper

java.lang.Object
  |
  +--fr.inria.ketuk.XBMapper
All Implemented Interfaces:
java.awt.event.ActionListener, BeanEditListener, javax.swing.event.CaretListener, java.awt.event.ContainerListener, java.util.EventListener, java.beans.PropertyChangeListener

public class XBMapper
extends java.lang.Object
implements BeanEditListener, java.awt.event.ActionListener, java.beans.PropertyChangeListener, java.awt.event.ContainerListener, javax.swing.event.CaretListener

A mapper between XML elements and beans

Author:
Claude Pasquier

Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          called when a event of type action is fired
 void addXEditListener(XEditListener l)
          Adds an event listener for XEdit events
 void beanEditPerformed(BeanEditEvent evt)
          called when a event of type beanEdit is fired
 void caretUpdate(javax.swing.event.CaretEvent evt)
          called when a event of type caret is fired
 void componentAdded(java.awt.event.ContainerEvent evt)
          Default processing when a component has been changed
 void componentRemoved(java.awt.event.ContainerEvent evt)
          Default processing when a component has been removed
 org.w3c.dom.Document doTransform()
          Applies the transformation represented by the current xsl document to the source document
 java.lang.Object getRootBean()
          The root of the generated beans
 org.w3c.dom.Document getXmlDocument()
          The source XML document
protected  void notifyXEditPerformed(org.w3c.dom.Node n, int eventType)
          Notifies all registered listener when an XEdit event is received
 java.lang.Object processBM()
          Applies the transformation represented by the current xslt document to the source document and generates the corresponding bean
 java.lang.Object processBM(org.w3c.dom.Document doc)
          Performs the layout of the beans described by the the parameter bean markup document
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Default processing when a property has changed
 void removeXEditListener(XEditListener l)
          Removes an event listener for XEdit events
 void updateBeans(java.beans.PropertyChangeEvent evt)
          Updates the beans when a modification has been made on the source document
 void updateBeansTot(java.beans.PropertyChangeEvent evt)
          For debug only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getXmlDocument

public org.w3c.dom.Document getXmlDocument()
The source XML document

getRootBean

public java.lang.Object getRootBean()
The root of the generated beans

processBM

public java.lang.Object processBM()
                           throws XBException,
                                  BMException
Applies the transformation represented by the current xslt document to the source document and generates the corresponding bean
Returns:
the created component

doTransform

public org.w3c.dom.Document doTransform()
                                 throws XBException
Applies the transformation represented by the current xsl document to the source document
Returns:
the target document

processBM

public java.lang.Object processBM(org.w3c.dom.Document doc)
                           throws XBException,
                                  BMException
Performs the layout of the beans described by the the parameter bean markup document
Parameters:
doc - the bean markup document
Returns:
the created Object

caretUpdate

public void caretUpdate(javax.swing.event.CaretEvent evt)
called when a event of type caret is fired
Specified by:
caretUpdate in interface javax.swing.event.CaretListener
Parameters:
evt - the fired event

beanEditPerformed

public void beanEditPerformed(BeanEditEvent evt)
called when a event of type beanEdit is fired
Specified by:
beanEditPerformed in interface BeanEditListener
Parameters:
evt - the fired event

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
called when a event of type action is fired
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - the fired event

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Default processing when a property has changed
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - the fired event

componentAdded

public void componentAdded(java.awt.event.ContainerEvent evt)
Default processing when a component has been changed
Specified by:
componentAdded in interface java.awt.event.ContainerListener
Parameters:
evt - the fired event

componentRemoved

public void componentRemoved(java.awt.event.ContainerEvent evt)
Default processing when a component has been removed
Specified by:
componentRemoved in interface java.awt.event.ContainerListener
Parameters:
evt - the fired event

updateBeansTot

public void updateBeansTot(java.beans.PropertyChangeEvent evt)
                    throws XBException
For debug only.

Generates all the beans at each modification made on the source document

Parameters:
evt - the fired event

updateBeans

public void updateBeans(java.beans.PropertyChangeEvent evt)
                 throws XBException
Updates the beans when a modification has been made on the source document

The update is composed of three successive operations

  1. the XSLT script is applied to the new source document and a new result is generated,
  2. the differences between the old result three and the new one is computed and stored in a list of changes,
  3. each change is reflected in the hierachy of target beans
Parameters:
evt - the fired event

addXEditListener

public void addXEditListener(XEditListener l)
Adds an event listener for XEdit events
Parameters:
l - the listener to add

removeXEditListener

public void removeXEditListener(XEditListener l)
Removes an event listener for XEdit events
Parameters:
l - the listener to remove

notifyXEditPerformed

protected void notifyXEditPerformed(org.w3c.dom.Node n,
                                    int eventType)
Notifies all registered listener when an XEdit event is received
Parameters:
n - the node concerned by the event
eventType - the type of the event