org.ejen
Class EjenChildNode

java.lang.Object
  |
  +--org.ejen.EjenChildNode
All Implemented Interfaces:
EjenConstants
Direct Known Subclasses:
EjenMergeNode, EjenParamNode, EjenRootNode, EjenSaveNode, EjenSourceNode, EjenStylesheetNode

public abstract class EjenChildNode
extends Object
implements EjenConstants

Parent abstract class of all Ejen...Node classes.

Version:
1.0
Author:
F. Wolff

Field Summary
protected static String _messageIndent
          Indentation string for message reporting.
 
Fields inherited from interface org.ejen.EjenConstants
CTX_DOM_SOURCE, CTX_STYLESHEET_HANDLER, CTX_STYLESHEET_ROOT, CTX_TRANSFORMER_FACTORY_IMPL, CTX_TRANSFORMER_IMPL, DEFAULT_XML_DATA, DEFAULT_XML_DATA_ENCODING, DEFAULT_XSL_DATA, LOG_INDENT_STR1, LOG_INDENT_STR2, MSG_DEBUG, MSG_ERR, MSG_INFO, MSG_VERBOSE, MSG_WARN, STATE_AFTER_PROCESS, STATE_BEFORE_PROCESS, STATE_CHECK, STATE_IDLE, STATE_PROCESS, STATES
 
Constructor Summary
EjenChildNode()
           
 
Method Summary
 void afterProcess()
          Does post-execution actions after this EjenChildNode execution.
 void beforeProcess()
          Prepares this EjenChildNode execution.
 void check()
          Check this EjenChildNode for mandatory attributes/child nodes.
protected  EjenContext cloneContext()
          Duplicates the current context (or creates a new one if the stack is empty).
protected  String evaluateAVT(String avt)
          Returns the evaluation of an Attribute Value Template.
protected  String evaluateAVT(TransformerImpl ti, String avt)
          Returns the evaluation of an Attribute Value Template, using the provided TransformerImpl object.
 Properties getAttributes()
          Returns the attributes of this EjenChildNode (empty here).
 Vector getChildren()
          Returns the children of this EjenChildNode (empty here).
protected  Object getFromContext(String name)
          Returns an Object (whose name is 'name') from the current context stack.
protected  Object getFromContext(String name, int offset)
          Returns an Object (whose name is 'name') from the current context stack.
protected  Object getFromGlobalContext(String name)
          Returns an Object (whose name is 'name') from the global (shared) context.
static EjenListener getListener()
          Returns the current listener for all EjenChildNode classes (the listener is static).
 int getState()
          Returns the current state of this EjenChildNode.
 void idle()
          Signals that this EjenChildNode has completly terminated its execution (including any post-execution actions).
abstract  String nodeName()
          Returns the name of this EjenChildNode.
protected  EjenContext popContext()
          Pops the current context from the contexts stack.
 void process()
          Executes this EjenChildNode.
protected  EjenContext pushContext(EjenContext ejenContext)
          Pushes a new EjenContext onto the top of the contexts stack.
protected  Object putInContext(String name, Object value)
          Puts an Object (whose name is 'name') in the current context (on the top of the stack).
protected  Object putInGlobalContext(String name, Object value)
          Puts an Object (whose name is 'name') in the global (shared) context.
 void sendMessageEvent(String msg)
          Sends a message event from this EjenChildNode (with level Does nothing if there is no listener.
 void sendMessageEvent(String msg, int level)
          Sends a message event from this EjenChildNode (with a specific level).
 void sendStateEvent()
          Sends a state change event (according to the current state of this EjenChildNode).
static void sendXSLMessageEvent(String msg)
          Sends a message event from an XSL file (via the Messenger.send(XSLProcessorContext context, ElemExtensionCall elem) extension function).
static void sendXSLMessageEvent(String msg, int level)
          Sends a message event from an XSL file (via the Messenger.send(XSLProcessorContext context, ElemExtensionCall elem) extension function), with specific level.
static void setListener(EjenListener ejenListener)
          Sets the listener for all EjenChildNode classes (the listener is static).
 String toString()
          Returns the String representation of this EjenChildNode, in the form of "<node_name> {[<attribute_name_1>=<attribute_value_1>[, <attribute_name_2>=<attribute_value_2> ...]]}".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_messageIndent

protected static String _messageIndent
Indentation string for message reporting.

Constructor Detail

EjenChildNode

public EjenChildNode()
Method Detail

nodeName

public abstract String nodeName()
Returns the name of this EjenChildNode.

Returns:
name of this EjenChildNode.

getAttributes

public Properties getAttributes()
Returns the attributes of this EjenChildNode (empty here).

Returns:
a Properties that contains all attributes of this EjenChildNode.

getChildren

public Vector getChildren()
Returns the children of this EjenChildNode (empty here).

Returns:
a Vector that contains all children of this EjenChildNode.

check

public void check()
Check this EjenChildNode for mandatory attributes/child nodes. Only sends a state change event here (EjenConstants.STATE_CHECK).


beforeProcess

public void beforeProcess()
Prepares this EjenChildNode execution. Only sends a state change event here (EjenConstants.STATE_BEFORE_PROCESS).


process

public void process()
Executes this EjenChildNode. Only sends a state change event here (EjenConstants.STATE_PROCESS).


afterProcess

public void afterProcess()
Does post-execution actions after this EjenChildNode execution. Only sends a state change event here (EjenConstants.STATE_AFTER_PROCESS).


idle

public final void idle()
Signals that this EjenChildNode has completly terminated its execution (including any post-execution actions). Only sends a state change event here (EjenConstants.STATE_IDLE).


getState

public final int getState()
Returns the current state of this EjenChildNode.

Returns:
the current state (see EjenConstants).

setListener

public static final void setListener(EjenListener ejenListener)
Sets the listener for all EjenChildNode classes (the listener is static).

Parameters:
ejenListener - the new EjenListener.

getListener

public static final EjenListener getListener()
Returns the current listener for all EjenChildNode classes (the listener is static).

Returns:
the current EjenListener.

sendStateEvent

public final void sendStateEvent()
Sends a state change event (according to the current state of this EjenChildNode). Does nothing if there is no listener.


sendMessageEvent

public final void sendMessageEvent(String msg)
Sends a message event from this EjenChildNode (with level Does nothing if there is no listener. EjenConstants.MSG_INFO).

Parameters:
msg - the message to send to the listener.

sendMessageEvent

public final void sendMessageEvent(String msg,
                                   int level)
Sends a message event from this EjenChildNode (with a specific level). Does nothing if there is no listener.

Parameters:
msg - the message to send to the listener.
level - level of the message (see EjenConstants).

sendXSLMessageEvent

public static final void sendXSLMessageEvent(String msg)
Sends a message event from an XSL file (via the Messenger.send(XSLProcessorContext context, ElemExtensionCall elem) extension function). Does nothing if there is no listener.

Parameters:
msg - the message to send to the listener.

sendXSLMessageEvent

public static final void sendXSLMessageEvent(String msg,
                                             int level)
Sends a message event from an XSL file (via the Messenger.send(XSLProcessorContext context, ElemExtensionCall elem) extension function), with specific level. Does nothing if there is no listener.

Parameters:
msg - the message to send to the listener.
level - level of the message (see EjenConstants).

toString

public final String toString()
Returns the String representation of this EjenChildNode, in the form of "<node_name> {[<attribute_name_1>=<attribute_value_1>[, <attribute_name_2>=<attribute_value_2> ...]]}".

Overrides:
toString in class Object
Returns:
the String representation of this EjenChildNode.

getFromContext

protected final Object getFromContext(String name)
Returns an Object (whose name is 'name') from the current context stack.

Parameters:
name - name of the Object to be returned.
Returns:
the Object (may be null if there is no such name).

getFromContext

protected final Object getFromContext(String name,
                                      int offset)
Returns an Object (whose name is 'name') from the current context stack.

Parameters:
name - name of the value to be returned.
offset - a negative value or zero (to access any context in the stack).
Returns:
the Object (may be null if there is no such name).
Throws:
EmptyStackException - if the stack is empty.

getFromGlobalContext

protected final Object getFromGlobalContext(String name)
Returns an Object (whose name is 'name') from the global (shared) context.

Parameters:
name - name of the value to be returned.
Returns:
the Object (may be null if there is no such name).

putInContext

protected final Object putInContext(String name,
                                    Object value)
Puts an Object (whose name is 'name') in the current context (on the top of the stack).

Parameters:
name - name of the Object to be put in the context.
value - the Object.
Returns:
the previous Object mapped to the name (may be null).

putInGlobalContext

protected final Object putInGlobalContext(String name,
                                          Object value)
Puts an Object (whose name is 'name') in the global (shared) context.

Parameters:
name - name of the Object to be put in the context.
value - the Object.
Returns:
the previous Object mapped to the name (may be null).

popContext

protected final EjenContext popContext()
Pops the current context from the contexts stack.

Returns:
the current EjenContext (may not be null).
Throws:
EmptyStackException - if the stack is empty.

pushContext

protected final EjenContext pushContext(EjenContext ejenContext)
Pushes a new EjenContext onto the top of the contexts stack.

Parameters:
ejenContext - the new EjenContext to be pushed.
Throws:
EmptyStackException - if the stack is empty.

cloneContext

protected final EjenContext cloneContext()
Duplicates the current context (or creates a new one if the stack is empty).

Returns:
the cloned context.

evaluateAVT

protected final String evaluateAVT(String avt)
Returns the evaluation of an Attribute Value Template.

Parameters:
avt - the Attribute Value Template.
Returns:
the evaluation of the Attribute Value Template.
Throws:
EjenException - if something goes wrong.

evaluateAVT

protected final String evaluateAVT(TransformerImpl ti,
                                   String avt)
Returns the evaluation of an Attribute Value Template, using the provided TransformerImpl object.

Parameters:
ti - a TransformerImpl instance.
avt - the Attribute Value Template.
Returns:
the evaluation of the Attribute Value Template.
Throws:
EjenException - if something goes wrong.