|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jplate.foundation.node.impl.AbstractNode<BC,LC>
org.jplate.foundation.node.impl.defaults.DefaultBranchNode<BC,LC>
BC - The branch context representing data type stored in branches.LC - The leaf context representing data type stored in leaves.public final class DefaultBranchNode<BC,LC>
Default implementation of BranchNodeIfc. Child node manipulation can be
threadsafe by using an implementation of
ListFactoryIfc that returns synchronized
List's. However, mutating the context is not thread safe.
Modifications:
$Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
$Revision: 479 $
$Author: sfloess $
$HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/node/impl/defaults/DefaultBranchNode.java $
ListFactoryIfc,
Serialized Form| Field Summary | |
|---|---|
private java.util.List<NodeIfc<BC,LC>> |
_childList
Child nodes. |
private BC |
_context
Self's context. |
private org.apache.commons.logging.Log |
_log
Used for logging. |
private NodeFactoryIfc<BC,LC> |
_nodeFactory
Used to create child branch nodes. |
static java.lang.String |
LIST_FACTORY_IS_NULL_MSG
Denotes the list factory is null. |
static java.lang.String |
NODE_FACTORY_IS_NULL_MSG
Denotes the node factory is null. |
private static long |
serialVersionUID
For serialization purposes. |
| Constructor Summary | |
|---|---|
DefaultBranchNode()
Default constructor. |
|
DefaultBranchNode(BranchNodeIfc<BC,LC> parent)
This constructor sets the parent. |
|
DefaultBranchNode(BranchNodeIfc<BC,LC> parent,
ListFactoryIfc<NodeIfc<BC,LC>> listFactory,
NodeFactoryIfc<BC,LC> nodeFactory)
This constructor sets the parent, context and factories for self. |
|
DefaultBranchNode(ListFactoryIfc<NodeIfc<BC,LC>> listFactory)
This constructor sets the factories for self. |
|
DefaultBranchNode(ListFactoryIfc<NodeIfc<BC,LC>> listFactory,
NodeFactoryIfc<BC,LC> nodeFactory)
This constructor sets the factories for self. |
|
DefaultBranchNode(NodeFactoryIfc<BC,LC> nodeFactory)
This constructor sets the factories for self. |
|
| Method Summary | |
|---|---|
void |
accept(NodeVisitorIfc<BC,LC> nodeVisitor)
Allows visitor to perform operations on self. |
BranchNodeIfc<BC,LC> |
appendNewBranch(BC branchContext)
Append a new child branch node. |
LeafNodeIfc<BC,LC> |
appendNewLeaf(LC leafContext)
Append a new child leaf node. |
java.util.Collection<NodeIfc<BC,LC>> |
getChildren()
Return the children of self. |
BC |
getContext()
Returns the context. |
BranchNodeIfc<BC,LC> |
insertNewBranch(BC branchContext,
int index)
Insert a new child branch node at index. |
LeafNodeIfc<BC,LC> |
insertNewLeaf(LC leafContext,
int index)
Insert a new child leaf node at index. |
BranchNodeIfc<BC,LC> |
prependNewBranch(BC branchContext)
Prepend a new child branch node. |
LeafNodeIfc<BC,LC> |
prependNewLeaf(LC leafContext)
Prepend a new child leaf node. |
NodeIfc<BC,LC> |
removeNode(int index)
Remove the child node at index. |
boolean |
removeNode(NodeIfc<BC,LC> node)
Remove a child node. |
void |
setContext(BC context)
Sets the context. |
java.lang.String |
toString()
Returns the string representation of self. |
java.lang.String |
toString(java.lang.String prepend)
Returns a string representation of self prepending prepend to
each line. |
| Methods inherited from class org.jplate.foundation.node.impl.AbstractNode |
|---|
getParent, getSource, setSource |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.jplate.foundation.node.NodeIfc |
|---|
getParent, getSource, setSource |
| Field Detail |
|---|
private static final long serialVersionUID
public static final java.lang.String NODE_FACTORY_IS_NULL_MSG
public static final java.lang.String LIST_FACTORY_IS_NULL_MSG
private final transient org.apache.commons.logging.Log _log
private final java.util.List<NodeIfc<BC,LC>> _childList
private final transient NodeFactoryIfc<BC,LC> _nodeFactory
private BC _context
| Constructor Detail |
|---|
public DefaultBranchNode(BranchNodeIfc<BC,LC> parent,
ListFactoryIfc<NodeIfc<BC,LC>> listFactory,
NodeFactoryIfc<BC,LC> nodeFactory)
parent - The parent of self. It can be null (meaning no
parent).listFactory - The factory that can create a List for use to hold
child nodes.nodeFactory - The factory that can create child leaf nodes.
java.lang.IllegalArgumentException - If listFactory, or
nodeFactory, are null.List,
ContextFactoryIfc,
FactoryIfc
public DefaultBranchNode(ListFactoryIfc<NodeIfc<BC,LC>> listFactory,
NodeFactoryIfc<BC,LC> nodeFactory)
listFactory - The factory that can create a List for use to hold
child nodes.nodeFactory - The factory that can create child leaf nodes.
java.lang.IllegalArgumentException - If listFactory, or
nodeFactory, are null.Listpublic DefaultBranchNode(ListFactoryIfc<NodeIfc<BC,LC>> listFactory)
listFactory - The factory that can create a List for use to hold
child nodes.
java.lang.IllegalArgumentException - If listFactory, is null.public DefaultBranchNode(NodeFactoryIfc<BC,LC> nodeFactory)
nodeFactory - The factory that can create child leaf nodes.
java.lang.IllegalArgumentException - If nodeFactory, is null.public DefaultBranchNode(BranchNodeIfc<BC,LC> parent)
parent - is the parent branch node of self.public DefaultBranchNode()
| Method Detail |
|---|
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String prepend)
prepend to
each line.
toString in interface FormattableIfcprepend - The text to prepend to each line as defined in the return
value.
prepend
prepended to each line.
public void accept(NodeVisitorIfc<BC,LC> nodeVisitor)
throws VisitException
visitor to perform operations on self.
accept in interface VisitableIfc<NodeVisitorIfc<BC,LC>>nodeVisitor - The object who will perform an operation on self.
VisitException - If any problems arise performing an operation on self.public void setContext(BC context)
setContext in interface BranchNodeIfc<BC,LC>context - The new context.public BC getContext()
getContext in interface BranchNodeIfc<BC,LC>public LeafNodeIfc<BC,LC> appendNewLeaf(LC leafContext)
appendNewLeaf in interface BranchNodeIfc<BC,LC>leafContext - The data stored in the return value.
public BranchNodeIfc<BC,LC> appendNewBranch(BC branchContext)
appendNewBranch in interface BranchNodeIfc<BC,LC>branchContext - The data stored in the return value.
public LeafNodeIfc<BC,LC> prependNewLeaf(LC leafContext)
prependNewLeaf in interface BranchNodeIfc<BC,LC>leafContext - The data stored in the return value.
public BranchNodeIfc<BC,LC> prependNewBranch(BC branchContext)
prependNewBranch in interface BranchNodeIfc<BC,LC>branchContext - The data stored in the return value.
public LeafNodeIfc<BC,LC> insertNewLeaf(LC leafContext,
int index)
index.
insertNewLeaf in interface BranchNodeIfc<BC,LC>leafContext - The data stored in the return value.index - The index for which the return value will be inserted.
public BranchNodeIfc<BC,LC> insertNewBranch(BC branchContext,
int index)
index.
insertNewBranch in interface BranchNodeIfc<BC,LC>branchContext - The data stored in the return value.index - The index for which the return value will be inserted.
public NodeIfc<BC,LC> removeNode(int index)
index.
removeNode in interface BranchNodeIfc<BC,LC>index - The index of the child node to remove.
public boolean removeNode(NodeIfc<BC,LC> node)
removeNode in interface BranchNodeIfc<BC,LC>node - The child node to remove.
node was found and removed false if not.public java.util.Collection<NodeIfc<BC,LC>> getChildren()
Collections.unmodifiableCollection(java.util.Collection extends T>).
getChildren in interface BranchNodeIfc<BC,LC>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||