org.jicengine.element.impl
Class ArrayElementCompiler

java.lang.Object
  extended byorg.jicengine.element.ElementCompiler
      extended byorg.jicengine.element.impl.StrictElementCompiler
          extended byorg.jicengine.element.impl.ArrayElementCompiler

public class ArrayElementCompiler
extends StrictElementCompiler

NOTE: currently, every value-element is handled as an array-element. what if the element has an action that would need some of the child-value-elements? .

Author:
.timo

Nested Class Summary
 class ArrayElementCompiler.ArrayConstructor
          Description of the Class
static class ArrayElementCompiler.RenamedValueElement
          Description of the Class
 
Constructor Summary
ArrayElementCompiler(java.lang.String name, Location location)
           
 
Method Summary
 void handleChildElement(Element child)
           Overrides the default handleChildElement()-procedure so that it becomes possible to handle the child-elements as elements of the array.
 
Methods inherited from class org.jicengine.element.impl.StrictElementCompiler
handleExtraChildElement
 
Methods inherited from class org.jicengine.element.ElementCompiler
createElement, elementInitialized, getConstructor, getElement, getLocation, getName, setAction, setCData, setConstructor, setId, setInstanceClass, setOverridableBy, setParameters, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayElementCompiler

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

handleChildElement

public void handleChildElement(Element child)
                        throws ElementException

Overrides the default handleChildElement()-procedure so that it becomes possible to handle the child-elements as elements of the array.

every ValueElement becomes an element in the array. we have to do some tricks, though.

We rename every value-element using syntax 'this[0]', 'this[1]', 'this[2]',... with this scheme, we accomplish 3 things:

  1. the constructor can recognize the array elements. - all array elements are handled as constructor parameters. the constructor must fetch each parameter from the context by their name. using this syntax, the array-constructor can query the context for array-elements.
  2. the constructor can resolve the size of the array - the array-elements are numbered, so by querying the context the constructor can resolve the index of the last element.
  3. duplicate-id collisions are avoided - every array-element is added to the constructor-context that doesn't allow duplicate names. every name must be different.
<7p>

the renaming is done with wrapper-element RenamedValueElement.

Overrides:
handleChildElement in class ElementCompiler
Parameters:
child - Description of the Parameter
Throws:
ElementException - Description of the Exception