org.jicengine.element
Class ElementCompiler

java.lang.Object
  extended byorg.jicengine.element.ElementCompiler
Direct Known Subclasses:
BeanElementCompiler, BlockElementCompiler, ListElementCompiler, MapCompiler, StrictElementCompiler

public abstract class ElementCompiler
extends java.lang.Object

A class that makes it possible to create Element-objects little by little, as is needed if the JIC-file is parsed with a SAX-parser.

ElementCompiler parses String-typed attributes and other data to corresponding objects. After all the data of an XML-element has been processed, the resulting runtime-Element can be obtained with method createElement().

Element Life cycle

Author:
.timo

Constructor Summary
ElementCompiler(java.lang.String name, Location location)
           
 
Method Summary
 Element createElement()
           
 void elementInitialized()
          Called by handler when the start-tag of the element has been processed - Element has been created and all attributes have been set, but no cdata nor child-elements have been processed.
 Operation getConstructor()
           
protected  ElementImpl getElement()
           
 Location getLocation()
           
 java.lang.String getName()
           
 void handleChildElement(Element child)
          Used for notifying this element about a child-element
protected abstract  ActionElement handleExtraChildElement(ValueElement child)
          for subclasses!
 void setAction(java.lang.String expression)
           for setting the action as an expression.
 void setCData(java.lang.String cData)
          if this element has a constructor, the cdata is added to the element-context with the name 'CDATA'.
 void setConstructor(java.lang.String expression)
           
 void setId(java.lang.String id)
          Sets the id of this element.
 void setInstanceClass(java.lang.String className)
           
 void setOverridableBy(java.lang.String overridingId)
           
 void setParameters(java.lang.String parameters)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ElementCompiler

public ElementCompiler(java.lang.String name,
                       Location location)
Method Detail

getElement

protected ElementImpl getElement()

getName

public java.lang.String getName()

getLocation

public Location getLocation()

setOverridableBy

public void setOverridableBy(java.lang.String overridingId)

createElement

public Element createElement()
                      throws ElementException
Throws:
ElementException

setId

public void setId(java.lang.String id)
Sets the id of this element. Makes the value of this element available in the global-context

Parameters:
id - The new id value

setParameters

public void setParameters(java.lang.String parameters)

setConstructor

public void setConstructor(java.lang.String expression)
                    throws ElementException
Throws:
ElementException

getConstructor

public Operation getConstructor()

setInstanceClass

public void setInstanceClass(java.lang.String className)
                      throws ElementException
Throws:
ElementException

setAction

public void setAction(java.lang.String expression)
               throws ElementException

for setting the action as an expression.

enhancements:

Throws:
ElementException

setCData

public void setCData(java.lang.String cData)
              throws ElementException
if this element has a constructor, the cdata is added to the element-context with the name 'CDATA'. (cdata might be ignored if the constructor doesn't use CDATA) if there is no constructor, cdata becomes the value of this element.

Parameters:
cData - Description of the Parameter
Throws:
ElementException - Description of the Exception

handleChildElement

public void handleChildElement(Element child)
                        throws ElementException
Used for notifying this element about a child-element

Parameters:
child - a child with no action, can have a value or not.
Throws:
ElementException - Description of the Exception

handleExtraChildElement

protected abstract ActionElement handleExtraChildElement(ValueElement child)
                                                  throws ElementException
for subclasses!

Throws:
ElementException

elementInitialized

public void elementInitialized()
                        throws ElementException
Called by handler when the start-tag of the element has been processed - Element has been created and all attributes have been set, but no cdata nor child-elements have been processed. This is a good spot for verifying that the state of the element is valid - the attributes have been used properly, attributes not set by user can be set to their default values, etc.

Throws:
ElementException - Description of the Exception

toString

public java.lang.String toString()