All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface org.jcon.core.part.Node

public interface Node
This interface represents a single node in a hierarchial System Tree. Each node has one part. A node can be a container or leaf. Containers hold zero or more nodes. The terms part and node are fairly interchangable.

Responsibilites are to maintain the state that applies to all parts, such as name, parent and isCore. The design philosophy is it should remain small and simple, serving only an "identification and properties role", with almost no behavior.

The boolean properties are all designed with the most common case as false, which is the default. For example we use "isHidden" instead of "isVisible".

TODO - A design problem is how do we add more properties, or hide existing properties? Perhaps we need a propMap.


Method Index

 o getName()
 o getParentNode()
 o getPart()
Returns the node's part.
 o getRootNode()
Returns the root node, which has no parent node.
 o isCompanion()
Returns true if this is a companion part or false if not.
 o isContainer()
Returns true if this is a container part or false if not.
 o isCore()
Returns true if this is a core part or false if not.
 o isHidden()
Returns true if this is a hidden part or false if not.
 o isInheritable()
Returns true if this is inheritable or false if not.
 o isVirtual()
Returns true if this is a virtual part or false if not.
 o setCompanion(boolean)
Sets whether this is a companion part or not.
 o setContainer(boolean)
Sets whether this is a container part or not.
 o setCore(boolean)
Sets whether this is a core part or not.
 o setHidden(boolean)
Sets whether this is a hidden part or not.
 o setInheritable(boolean)
Sets whether this is inheritable or not.
 o setName(String)
Sets the node or part name.
 o setParentNode(Node)
 o setPart(Object)
Sets the node's part, which may be any object whatsoever.
 o setVirtual(boolean)
Sets whether this is a virtual part or not.
 o toString()
Returns a String representation of the node.

Methods

 o setName
 public abstract void setName(String name)
Sets the node or part name. This must be unique per container. It must be alphanumeric, may contain periods, and must not contain blanks or slashes. It cannot be null or a zero length String. This is a required property.

The name "MyCell" is not allowed. This is reserved for use in Cell.findPart(String name).

Our convention is to capatalize the first letter of each word making up the self-documenting part name. Examples are "Root", "ControlRegistry" and "UserSecurity".

If part names are used for finding the part in other containers, then to avoid name space conflicts the names need careful design. This can achieve branch or system uniqueness. This will happen if service parts are used a lot. To support unique naming we allow periods in the name, such as "org.jcon.security.UserAuthorization".

Parameters:
name - the name of the node.
 o getName
 public abstract String getName()
 o setPart
 public abstract void setPart(Object part)
Sets the node's part, which may be any object whatsoever. The object should be unique per container and probably unique per System Tree. This is a required property.

If the part implements NodeUser then setNode(Node) will be called, using "this" node.

Parameters:
part - the node's part.
 o getPart
 public abstract Object getPart()
Returns the node's part.

Returns:
the node's part.
 o setParentNode
 public abstract void setParentNode(Node parentNode)
 o getParentNode
 public abstract Node getParentNode()
 o setCore
 public abstract void setCore(boolean isCore)
Sets whether this is a core part or not. The default is false.

Parameters:
isCore - true if this is a core part or false if not.
 o isCore
 public abstract boolean isCore()
Returns true if this is a core part or false if not.

Parts are divided into two groups: core and domain. Core parts are required for a System Tree to run. They are domain neutral, and are normally hidden. Domain parts are the ones supplied by the system builder, have the domain functionality, and form the bulk of a system. The use of core parts by domain parts should be minimized and fascaded to preserve core encapsulation.

Returns:
true if this is a core part or false if not.
 o setContainer
 public abstract void setContainer(boolean isContainer)
Sets whether this is a container part or not. The default is false.

Parameters:
isContainer - true if this is a container or false if not.
 o isContainer
 public abstract boolean isContainer()
Returns true if this is a container part or false if not.

A unique type of core part is a container. It holds other container or leaf parts. All other types of parts are leaf parts. A container part requires the other core parts to run. Thus the core parts form the "container" portion of a system. We do not call this "isCell" to allow other types of containers, such as organs.

Returns:
true if this is a container or false if not.
 o setCompanion
 public abstract void setCompanion(boolean isCompanion)
Sets whether this is a companion part or not. The default is false.

Parameters:
isCompanion - true if this is a companion or false if not.
 o isCompanion
 public abstract boolean isCompanion()
Returns true if this is a companion part or false if not.

A container may have one leaf part that's psychologically associated with the container. An example is a registry. In the visual System Tree companions are shown as with their containers instead of being a child. This helps conceptual design.

Returns:
true if this is a companion or false if not.
 o setInheritable
 public abstract void setInheritable(boolean isInheritable)
Sets whether this is inheritable or not. The default is false.

Parameters:
isInheritable - true if this is inheritable or false if not.
 o isInheritable
 public abstract boolean isInheritable()
Returns true if this is inheritable or false if not.

Parts may play a "local" or "inheritable" role in their collaborations with other parts. Most parts are local, and are used via Messages or occasionally directly. Some parts play a "service" role by sitting near the upper region of a System Tree and serving the needs of many parts below by being inheritable. This is the Service Architecture Pattern, though that pattern is not limited to trees.

We recommend the use of "message services" instead of "part services" for most use. This has looser coupling.

An example of the use of isInheritable is core service parts. This allows cores that don't use Messages, gives greater speed, and allows part sharing of stateless part by many containers for efficiency. One purpose of this property is so the designer can declare that a part NOT be used as a service, which can improve cell encapsulation. Another advantage is automatic management of service parts by a service registry or such.

Returns:
true if this is inheritable or false if not.
 o setVirtual
 public abstract void setVirtual(boolean isVirtual)
Sets whether this is a virtual part or not. The default is false.

Parameters:
isVirtual - true if this is virtual or false if not.
 o isVirtual
 public abstract boolean isVirtual()
Returns true if this is a virtual part or false if not.

Parts may be normal or "virtual". Normally all parts are defined in Container DK. But virtual parts are not defined by Container DK. This allows more dynamic system behavior, less DK, and lighter system weight. An example of virtual parts is core parts in subcells below the root.

TODO - Perhaps we need a better word, but "virtual" means a part definition is hidden, and so the part appears out of nowhere. Is this property really needed?

Returns:
true if this is virtual or false if not.
 o setHidden
 public abstract void setHidden(boolean isHidden)
Sets whether this is a hidden part or not. The default is false.

Parameters:
isHidden - true if this is hidden or false if not.
 o isHidden
 public abstract boolean isHidden()
Returns true if this is a hidden part or false if not.

Most parts are visible in the visual System Tree tool and to "get all parts in a container" calls, etc. But the core parts (except for container) are hidden, because that would clutter up things visually, and expose them to possible misuse by non-core parts. This also helps preserve core encapsulation.

This property can be used to control the behavior of classes like "PartReader" to hide sensitive parts. (It's a little muddy because of the show container exception)

Returns:
true if this is hidden or false if not.
 o getRootNode
 public abstract Node getRootNode()
Returns the root node, which has no parent node.

Returns:
the root node.
 o toString
 public abstract String toString()
Returns a String representation of the node. The standard is the name of the node.

Returns:
a String representation of the node.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index