Eidola home

org.eidola.kernel
Class Capsule

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

public abstract class Capsule
extends NamedElement

An element which encapsulates a unit of a program by holding member elements in public and private sections.

Structure:

Signature:

See note on synchronization and concurrent read safety in Container.

Version:
[Development version]
Author:
Paul Cantrell

Inner Class Summary
 class Capsule.Compilation
           
 
Inner classes inherited from class org.eidola.kernel.NamedElement
NamedElement.Compilation
 
Inner classes inherited from class org.eidola.kernel.Element
Element.Compilation
 
Inner classes inherited from class org.eidola.kernel.Container
Container.Compilation
 
Field Summary
static ContainerPart PRIVATE_MEMBERS
          Part of a capsule.
static ContainerPart PUBLIC_MEMBERS
          Part of a capsule.
 
Fields inherited from class org.eidola.kernel.NamedElement
NAME
 
Fields inherited from class org.eidola.kernel.Element
OWNER
 
Fields inherited from class org.eidola.kernel.Container
CONTENTS, debugCompile
 
Fields inherited from class org.eidola.kernel.event.EventBroadcaster
debugEvents
 
Constructor Summary
Capsule()
          Creates a new empty capsule.
 
Method Summary
 void addMember(NamedElement mem, boolean inPublic)
          Adds a member to this capsule.
 void addPrivate(NamedElement mem)
          Adds a private member to this capsule.
 void addPublic(NamedElement mem)
          Adds a public member to this capsule.
 NamedElement findMember(String memName, boolean inPublic)
          Finds a member by name.
 NamedElement findPrivate(String memName)
          Finds a private member by name.
 NamedElement findPublic(String memName)
          Finds a public member by name.
 Set getPrivate()
          Returns the private members of this capsule.
 Set getPublic()
          Returns the public members of this capsule.
 void removeMember(NamedElement mem, boolean inPublic)
          Removes a member from this capsule.
 void removePrivate(NamedElement mem)
          Removes a private member from this capsule.
 void removePublic(NamedElement mem)
          Removes a public member from this capsule.
 void setMembers(Collection newMems, boolean setPub)
          Sets either the public or private members of this capsule.
 void setPrivate(Collection newPriv)
          Sets the private members of this capsule.
 void setPublic(Collection newPub)
          Sets the public members of this capsule.
 
Methods inherited from class org.eidola.kernel.NamedElement
broadcastEvent, getName, getSignatureVersion, setName
 
Methods inherited from class org.eidola.kernel.Element
getFullName, getIndirectOwners, getNamespace, getOwner, handleOwnerEvent, setOwner, toString
 
Methods inherited from class org.eidola.kernel.Container
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

PUBLIC_MEMBERS

public static final ContainerPart PUBLIC_MEMBERS
Part of a capsule.
See Also:
StructureChanged

PRIVATE_MEMBERS

public static final ContainerPart PRIVATE_MEMBERS
Part of a capsule.
See Also:
StructureChanged
Constructor Detail

Capsule

public Capsule()
Creates a new empty capsule.
Method Detail

getPublic

public Set getPublic()
Returns the public members of this capsule.

getPrivate

public Set getPrivate()
Returns the private members of this capsule.

findPublic

public NamedElement findPublic(String memName)
Finds a public member by name. If there are illegal duplicate names, this method returns one of them in an undefined fashion.
Parameters:
memName - The member name to look for.

findPrivate

public NamedElement findPrivate(String memName)
Finds a private member by name. If there are illegal duplicate names, this method returns one of them in an undefined fashion.
Parameters:
memName - The member name to look for.

findMember

public NamedElement findMember(String memName,
                               boolean inPublic)
Finds a member by name. If there are illegal duplicate names, this method returns one of them in an undefined fashion.
Parameters:
memName - The member name to look for.
inPublic - Search in public (true) or private (false) members.

addPublic

public void addPublic(NamedElement mem)
               throws IllegalElementType
Adds a public member to this capsule. If the element is already a public member, this method has no effect.

Events: StructureChanged, SignatureChanged

Parameters:
mem - The member to add.
Throws:
IllegalElementType - If mem is null.

addPrivate

public void addPrivate(NamedElement mem)
                throws IllegalElementType
Adds a private member to this capsule. If the element is already a private member, this has no effect.

Events: StructureChanged, SignatureChanged

Parameters:
mem - The member to add.
Throws:
IllegalElementType - If mem is null.

addMember

public void addMember(NamedElement mem,
                      boolean inPublic)
               throws IllegalElementType
Adds a member to this capsule. If it is already a member where you are adding it, this method has no effect.

Events: StructureChanged, SignatureChanged

Parameters:
mem - The member to add.
inPublic - Makes the element a public (true) or private (false) member.
Throws:
IllegalElementType - If mem is null.

removePublic

public void removePublic(NamedElement mem)
Removes a public member from this capsule. If the element is not a public member, this method has no effect.

Events: StructureChanged, SignatureChanged

Parameters:
mem - The member to remove.

removePrivate

public void removePrivate(NamedElement mem)
Removes a private member from this capsule. If the element is not a private member, this method has no effect.

Events: StructureChanged, SignatureChanged

Parameters:
mem - The member to remove.

removeMember

public void removeMember(NamedElement mem,
                         boolean inPublic)
Removes a member from this capsule. If the element is not a member, this method has no effect.

Events: StructureChanged, SignatureChanged

Parameters:
mem - The member to remove.
inPublic - Removes the element from the public (true) or private (false) members.

setPublic

public void setPublic(Collection newPub)
               throws IllegalElementType
Sets the public members of this capsule.

Events: StructureChanged, SignatureChanged

Parameters:
newPub - A collection of NamedElements which will be the new public members. This method makes an internal copy of this collection, so it is safe to pass a collection and subsequently modify it.
Throws:
IllegalElementType - If one of the new members is null or not a named element.

setPrivate

public void setPrivate(Collection newPriv)
                throws IllegalElementType
Sets the private members of this capsule.

Events: StructureChanged, SignatureChanged

Parameters:
newPriv - A collection of NamedElements which will be the new private members. This method makes an internal copy of this collection, so it is safe to pass a collection and subsequently modify it.
Throws:
IllegalElementType - If one of the new members is null or not a named element.

setMembers

public void setMembers(Collection newMems,
                       boolean setPub)
                throws IllegalElementType
Sets either the public or private members of this capsule.

Events: StructureChanged, SignatureChanged

Parameters:
newMems - A collection of NamedElements which will be the new members. This method makes an internal copy of this collection, so it is safe to pass a collection and subsequently modify it.
setPub - Set the public (true) or private (false) members.
Throws:
IllegalElementType - If one of the new members is null or not a named element.

Eidola home