Access keysTop, Summary, Constructors,
Instance properties,
Instance methodsBaseTreeNode
| Kind of class: |
class |
| Inherits from: |
none |
| Version: |
20 July 2005 |
| Author: |
Arthur Clemens |
| Classpath: |
playground.classes.data.tree.BaseTreeNode |
| File last modified: |
Thursday, 13 July 2006, 09:34:01 |
/*
Copyright 2005-2006 by the authors of asapframework, http://asapframework.org
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import playground.classes.data.KeyValueList;
import playground.classes.data.tree.*;
/**
Bare bones tree node class of a position tree: nodes with children, no left/right nodes.
Every {@code BaseTreeNode} subclass should implement a custom constructor and the (private) method {@link #createNewNode}. That method is a Factory method; it returns for each subclass implementation the node with the desired type. When adding nodes to the Tree, all child nodes automatically 'inherit' the type from their parent.
@author Arthur Clemens
@version 20 July 2005
*/
class playground.classes.data.tree.BaseTreeNode {
private var mName:String; /**< Unique identifier. */
private var mNamePath:String; /**< Identifier path. */
private var mProperties:KeyValueList; /**< Stores properties for this node. */
private var mDepth:Number; /**< Depth of the node. 0 is reserved for the root node. */
private var mOwner:Tree; /**< Reference to the Tree that owns the node. */
private var mParent:TreeNode; /**< Parent node. */
private var mChildren:Array; /*< Child nodes (typical of a position tree). */
private var mPosition:Number; /**< Position in children array */
function BaseTreeNode (inName:String, inProperties:KeyValueList)
{
// subclasses might want to have parameter checks here
mName = inName;
mProperties = inProperties;
}
/**
Creates a new node. Should be implemented by subclasses.
@param inName : name for the new node; the name should be unique and without spaces
@param inProperties : KeyValueList that stores key/value pairs
@return The newly created node.
*/
private function createNewNode (inName:String, inProperties:KeyValueList) : BaseTreeNode
{
return new BaseTreeNode(inName, inProperties);
}
}
Bare bones tree node class of a position tree: nodes with children, no left/right nodes.
Every
BaseTreeNode subclass should implement a custom constructor and the (private) method
createNewNode. That method is a Factory method; it returns for each subclass implementation the node with the desired type. When adding nodes to the Tree, all child nodes automatically 'inherit' the type from their parent.
Instance properties
mChildren
private mChildren:Array
(read,write)
mDepth
private mDepth:Number
(read,write)
Depth of the node. 0 is reserved for the root node.
mName
private mName:String
(read,write)
Unique identifier.
mNamePath
private mNamePath:String
(read,write)
Identifier path.
mOwner
Reference to the Tree that owns the node.
mPosition
private mPosition:Number
(read,write)
Position in children array
mProperties
Stores properties for this node.
Instance methods
createNewNode
private function createNewNode (
Creates a new node. Should be implemented by subclasses.
Parameters:
inName :
name for the new node; the name should be unique and without spaces
inProperties:
KeyValueList that stores key/value pairs
Returns:The newly created node.