Eidola home

org.eidola.kernel
Class Element

java.lang.Object
  |
  +--org.eidola.kernel.event.EventBroadcaster
        |
        +--org.eidola.kernel.Container
              |
              +--org.eidola.kernel.Element
Direct Known Subclasses:
NamedElement

public abstract class Element
extends Container

A piece of an Eidola program which is owned by another container. Elements can be as large as a Package, or as small as a numeric constant in an expression.

Elements sit in a strict hierarchy -- every Element has exactly one owner. The chain of owners always reaches up to a Namespace. All the elements within the namespace have unique full names; see NamedElement.

Structure:

See note on synchronization and concurrent read safety in Container.

Version:
[Development version]
Author:
Paul Cantrell

Inner Class Summary
 class Element.Compilation
           
 
Inner classes inherited from class org.eidola.kernel.Container
Container.Compilation
 
Field Summary
static ContainerPart OWNER
          Part of an element.
 
Fields inherited from class org.eidola.kernel.Container
CONTENTS, debugCompile
 
Fields inherited from class org.eidola.kernel.event.EventBroadcaster
debugEvents
 
Constructor Summary
Element()
          Creates a new empty element.
 
Method Summary
 List getFullName()
          Returns a list of the names of the chain of containers.
 List getIndirectOwners()
          Returns the list including this container, its owner, its owner's owner, etc, up to and including the container's namespace.
 Namespace getNamespace()
          Returns the namespace in which this element lives.
 Container getOwner()
          Returns this element's owner.
protected  void handleOwnerEvent(ContainerEvent event)
          Propagates events from the owner.
 void setOwner(Container newOwner)
          Sets this element's owner.
 String toString()
          Returns the full name of the element as a nicely formatted string.
 
Methods inherited from class org.eidola.kernel.Container
broadcastEvent, compile, dump, finalize, getCompilation, getCompileVersion, getStructureVersion, handleContentEvent, handleSelfEvent, makeNewCompilation
 
Methods inherited from class org.eidola.kernel.event.EventBroadcaster
addListener, removeListener, updateBroadcasters
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OWNER

public static final ContainerPart OWNER
Part of an element.
See Also:
StructureChanged
Constructor Detail

Element

public Element()
Creates a new empty element. The new element won't be valid until it has an owner.
Method Detail

getNamespace

public Namespace getNamespace()
Returns the namespace in which this element lives.
Overrides:
getNamespace in class Container

getOwner

public Container getOwner()
Returns this element's owner.

setOwner

public void setOwner(Container newOwner)
              throws CyclicOwner
Sets this element's owner. This will broadcast a StructureChanged notifying that the OWNER has changed.
Throws:
CyclicOwner - If setting this owner would create a cycle in the chain of owners.

getIndirectOwners

public List getIndirectOwners()
Returns the list including this container, its owner, its owner's owner, etc, up to and including the container's namespace. The list goes from the topmost container down. Although this is really a derived structure, it is not a member of Compilation and is not calculated lazily, because this would often lead to the propogation of unreasonable numbers of events.

getFullName

public List getFullName()
Returns a list of the names of the chain of containers. For unnamed elements in the chain, the element itself appears. Although this is really a derived structure, it is not a member of Compilation and is not calculated lazily, because this would often lead to the propogation of unreasonable numbers of events.
See Also:
NamedElement.getName(), toString()

handleOwnerEvent

protected void handleOwnerEvent(ContainerEvent event)
Propagates events from the owner. By default, this handler broadcasts a CompileRequired event when it receives a StructureChanged event from the owner.

toString

public String toString()
Returns the full name of the element as a nicely formatted string.
Overrides:
toString in class Object

Eidola home