Class Node
- java.lang.Object
-
- org.exoplatform.social.common.xmlprocessor.model.Node
-
public class Node extends Object
Model of XML node tree- Author:
- Ly Minh Phuong - http://phuonglm.net
-
-
Constructor Summary
Constructors Constructor Description Node()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(String key, String value)Adds Attribute to current Node.voidaddChildNode(Node childNode)Adds child Node to this Node.voidconvertToContent()Converts this Tag Node to Content Node, add Close Tag at the end of child nodes and move all child Nodes of this Node to parent Node.AttributesgetAttributes()Returns Attributes of NodeLinkedList<Node>getChildNodes()Gets the list child nodes of current Node.StringgetContent()Gets the Content of Node, if Node have Content it mean that is text Node.NodegetParentNode()Gets parent Node of current Node.StringgetTitle()Gets title of Node, node's title ak the tag name.voidinsertAfter(int position, Node node)Insert Node to DOM tree after the node at positionvoidinsertAfter(Node refNode, Node nodeToInsert)insert Node to DOM tree after refNodebooleanisRootNode()Check if node is RootNodebooleanisSelfClosedNode()Check if node is SelfCloseNodebooleanisTextNode()Check if node is TextNodevoidsetAttributes(Attributes attributes)Sets attributes of Node.voidsetChildNodes(LinkedList<Node> childNodes)Sets the list child nodes of current Node.voidsetContent(String content)Sets the Content of Node, if Node have Content it mean that is text Node.voidsetParentNode(Node parentNode)Sets the parent Node of currentNodevoidsetTitle(String nodeTitle)Sets title of Node, node's title ak the tag name.StringtoString()Convert Node to XML String including all sub-Node
-
-
-
Method Detail
-
getParentNode
public Node getParentNode()
Gets parent Node of current Node. If current Node is root, parent Node == null;- Returns:
- parent node
-
setParentNode
public void setParentNode(Node parentNode)
Sets the parent Node of currentNode- Parameters:
parentNode-
-
getTitle
public String getTitle()
Gets title of Node, node's title ak the tag name.- Returns:
- the node title
-
setTitle
public void setTitle(String nodeTitle)
Sets title of Node, node's title ak the tag name.- Parameters:
nodeTitle-
-
getAttributes
public Attributes getAttributes()
Returns Attributes of Node- Returns:
- the attributes
-
setAttributes
public void setAttributes(Attributes attributes)
Sets attributes of Node.- Parameters:
attributes-
-
getContent
public String getContent()
Gets the Content of Node, if Node have Content it mean that is text Node.- Returns:
- the content node
-
setContent
public void setContent(String content)
Sets the Content of Node, if Node have Content it mean that is text Node.- Parameters:
content-
-
getChildNodes
public LinkedList<Node> getChildNodes()
Gets the list child nodes of current Node.- Returns:
- child nodes
-
setChildNodes
public void setChildNodes(LinkedList<Node> childNodes)
Sets the list child nodes of current Node.- Parameters:
childNodes- the child nodes
-
addChildNode
public void addChildNode(Node childNode)
Adds child Node to this Node.- Parameters:
childNode- the child node
-
addAttribute
public void addAttribute(String key, String value)
Adds Attribute to current Node.- Parameters:
key- attribute keyvalue- attribute value
-
isTextNode
public boolean isTextNode()
Check if node is TextNode- Returns:
- Since:
- 1.2.2
-
isRootNode
public boolean isRootNode()
Check if node is RootNode- Returns:
- Since:
- 1.2.2
-
isSelfClosedNode
public boolean isSelfClosedNode()
Check if node is SelfCloseNode- Returns:
- Since:
- 1.2.2
-
insertAfter
public void insertAfter(Node refNode, Node nodeToInsert)
insert Node to DOM tree after refNode- Parameters:
refNode-nodeToInsert-- Since:
- 1.2.2
-
insertAfter
public void insertAfter(int position, Node node)Insert Node to DOM tree after the node at position- Parameters:
position-node-- Since:
- 1.2.2
-
toString
public String toString()
Convert Node to XML String including all sub-Node
-
convertToContent
public void convertToContent()
Converts this Tag Node to Content Node, add Close Tag at the end of child nodes and move all child Nodes of this Node to parent Node.
-
-