org.netbeans.modules.bpel.model.impl
Class NamespaceOptimizer

java.lang.Object
  extended by org.netbeans.modules.bpel.model.impl.services.InnerEventDispatcherAdapter
      extended by org.netbeans.modules.bpel.model.impl.NamespaceOptimizer
All Implemented Interfaces:
InnerEventDispatcher

public class NamespaceOptimizer
extends InnerEventDispatcherAdapter

Author:
ads This class removes namespaces added to element as result of setting QName attribute in unattached element. Any such namespace ( is any ) should be removed from current element and moved to root element. Moving namespace to root element already implemented in XAM but it works ONLY for copied element. This service need care about existing namespace and change new prefix with existing namespace to existing prefix. This is done in preDispatch. Moving to root namespaces declaration that is not found in root is performed in postDispatch. Also one need to care about updating prefix appropriately because it can be changed after moving namespace to root. This service need two more services: one will identified element as created via builder ( cookie flag ), second should remove this flag from cookie after element is inserted into tree. Only elements with this flag needs to be handled by this service. Because otherwise there will be double work for "copied" element.

Field Summary
(package private) static java.lang.String XMLNS
           
 
Constructor Summary
NamespaceOptimizer()
           
 
Method Summary
 boolean isApplicable(ChangeEvent event)
          This method called for checking either we need to call this visitor for event.
 void postDispatch(ChangeEvent event)
          This method will be called after action on model was performed.
 void preDispatch(ChangeEvent event)
          This method will be called before action on model will be performed.
 void reset(ChangeEvent event)
          This method is called when some exception is detected in one of dispatchers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XMLNS

static final java.lang.String XMLNS
See Also:
Constant Field Values
Constructor Detail

NamespaceOptimizer

public NamespaceOptimizer()
Method Detail

isApplicable

public boolean isApplicable(ChangeEvent event)
Description copied from interface: InnerEventDispatcher
This method called for checking either we need to call this visitor for event.

Specified by:
isApplicable in interface InnerEventDispatcher
Overrides:
isApplicable in class InnerEventDispatcherAdapter
Parameters:
event - Fired event.
Returns:
Is applicable this visitor for event.

preDispatch

public void preDispatch(ChangeEvent event)
Description copied from interface: InnerEventDispatcher
This method will be called before action on model will be performed. This method could throw VetoException. It should not throw any exception on events about accessing to children ( setting/adding/removing child in parent ). This is because OM doesn't have methods that could be incorrectly used. Only setting incorrect attribute value could throw such exception.

Specified by:
preDispatch in interface InnerEventDispatcher
Overrides:
preDispatch in class InnerEventDispatcherAdapter
Parameters:
event - Event that will be fired after OM will be changed. It is not yet happened.

postDispatch

public void postDispatch(ChangeEvent event)
Description copied from interface: InnerEventDispatcher
This method will be called after action on model was performed. It could perform additional changes in OM based on event information. F.e. it could change name of attribute that reference to some entity by name and this name was changed.

Specified by:
postDispatch in interface InnerEventDispatcher
Overrides:
postDispatch in class InnerEventDispatcherAdapter
Parameters:
event - Event that fired by OM after change was performed.

reset

public void reset(ChangeEvent event)
Description copied from interface: InnerEventDispatcher
This method is called when some exception is detected in one of dispatchers. Then all dispatchers that collect some information on preDispatch stage can clear this information. Suggested use - when one of inner dispatchers throws VetoException then all diaspatchers need to clean internal state, because postDispatch will never be called.

Specified by:
reset in interface InnerEventDispatcher
Overrides:
reset in class InnerEventDispatcherAdapter
Parameters:
event - Event that fired by OM after change was performed.