net.aethersanctum.curlyml
Class Node

java.lang.Object
  extended by net.aethersanctum.curlyml.Node
Direct Known Subclasses:
Document

public class Node
extends java.lang.Object

The basic building block of a loaded CurlyML tree.

All nodes are named, and may have a list of child nodes attached. There is a semantic difference between a parent node with no children, and a leaf node.

Author:
ben

Constructor Summary
Node(java.lang.String nodeText)
          Create a new Node.
 
Method Summary
 void addChild(Node child)
          add a child to this node's child list.
 java.util.List<Node> getChildren()
          Get me all the children this node has.
 java.lang.String getText()
          get this node's name/text value
 boolean hasChildren()
          check to see if a node has chilren.
 boolean isParent()
          a Node is a parent if it has a child list attached (may be empty)
 void markAsParent()
          Mark this node as a parent.
 void setChildren(java.util.List<Node> children)
          Replace/set this node's child list.
 void setText(java.lang.String text)
          set this node's name/text value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node(java.lang.String nodeText)
Create a new Node. Initially it is a leaf node, unless we add children or explicity declare it to be a parent node via markAsParent().

Parameters:
nodeText -
See Also:
markAsParent()
Method Detail

getChildren

public java.util.List<Node> getChildren()
Get me all the children this node has. May return null if this node isn't a parent, or an empty List if it's a childless parent.

Returns:

setChildren

public void setChildren(java.util.List<Node> children)
Replace/set this node's child list. Probably not useful.

Parameters:
children -

markAsParent

public void markAsParent()
Mark this node as a parent. Will get rendered as an empty node if no children are subsequently added.


getText

public java.lang.String getText()
get this node's name/text value

Returns:

setText

public void setText(java.lang.String text)
set this node's name/text value

Parameters:
text -

isParent

public boolean isParent()
a Node is a parent if it has a child list attached (may be empty)


hasChildren

public boolean hasChildren()
check to see if a node has chilren. It can't unless it's a parent, of course.


addChild

public void addChild(Node child)
add a child to this node's child list. but if it's not a parent, we have to make it one first by giving it a child list.