org.jplate.foundation.node.impl.defaults
Class DefaultLeafNode<BC,LC>

java.lang.Object
  extended by org.jplate.foundation.node.impl.AbstractNode<BC,LC>
      extended by org.jplate.foundation.node.impl.defaults.DefaultLeafNode<BC,LC>
Type Parameters:
BC - The branch context representing data type stored in branches.
LC - The leaf context representing data type stored in leaves.
All Implemented Interfaces:
java.io.Serializable, FormattableIfc, VisitableIfc<NodeVisitorIfc<BC,LC>>, LeafNodeIfc<BC,LC>, NodeIfc<BC,LC>

public class DefaultLeafNode<BC,LC>
extends AbstractNode<BC,LC>
implements LeafNodeIfc<BC,LC>

Default implementation of LeafNodeIfc. Is not thread-safe with regards to setting and retrieving the context.

Specifying the branch and leaf context defines what object types can be expected for all branches and leaves for self, siblings, parents, etc.

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/DefaultLeafNode.java $
    

See Also:
Serialized Form

Field Summary
private  LC _context
          Self's context.
private  org.apache.commons.logging.Log _log
          Used for logging.
private static java.lang.String PARENT_IS_NULL_MSG
          Denotes the parent presented on construction is null.
private static long serialVersionUID
          For serialization purposes.
 
Constructor Summary
private DefaultLeafNode()
          Default constructor not allowed.
  DefaultLeafNode(BranchNodeIfc<BC,LC> parent)
          Constructor to set the parent.
  DefaultLeafNode(BranchNodeIfc<BC,LC> parent, LC context)
          Constructor to set the parent and context.
 
Method Summary
 void accept(NodeVisitorIfc<BC,LC> nodeVisitor)
          Allows visitor to perform operations on self.
 LC getContext()
          Returns self's context.
 void setContext(LC context)
          Sets the context of self.
 java.lang.String toString()
          Returns a stringified version 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

serialVersionUID

private static final long serialVersionUID
For serialization purposes.

See Also:
Constant Field Values

PARENT_IS_NULL_MSG

private static final java.lang.String PARENT_IS_NULL_MSG
Denotes the parent presented on construction is null.

See Also:
Constant Field Values

_log

private final transient org.apache.commons.logging.Log _log
Used for logging.


_context

private LC _context
Self's context.

Constructor Detail

DefaultLeafNode

public DefaultLeafNode(BranchNodeIfc<BC,LC> parent,
                       LC context)
Constructor to set the parent and context.

Parameters:
parent - The parent of self.
context - The data associated with self.
Throws:
java.lang.IllegalArgumentException - if parent is null.

DefaultLeafNode

public DefaultLeafNode(BranchNodeIfc<BC,LC> parent)
Constructor to set the parent.

Parameters:
parent - The parent of self.
Throws:
java.lang.IllegalArgumentException - if parent is null.

DefaultLeafNode

private DefaultLeafNode()
Default constructor not allowed.

Method Detail

toString

public java.lang.String toString()
Returns a stringified version of self.

Overrides:
toString in class java.lang.Object
Returns:
The String representation of self.

toString

public java.lang.String toString(java.lang.String prepend)
Returns a string representation of self prepending prepend to each line.

Specified by:
toString in interface FormattableIfc
Parameters:
prepend - The text to prepend to each line as defined in the return value.
Returns:
A string representation of self who has prepend prepended to each line.

accept

public void accept(NodeVisitorIfc<BC,LC> nodeVisitor)
            throws VisitException
Allows visitor to perform operations on self.

Specified by:
accept in interface VisitableIfc<NodeVisitorIfc<BC,LC>>
Parameters:
nodeVisitor - The object who will perform an operation on self.
Throws:
VisitException - If any problems arise performing an operation on self.

setContext

public void setContext(LC context)
Sets the context of self.

Specified by:
setContext in interface LeafNodeIfc<BC,LC>
Parameters:
context - The new context.

getContext

public LC getContext()
Returns self's context.

Specified by:
getContext in interface LeafNodeIfc<BC,LC>
Returns:
Self's context.