org.apache.stratos.lb.common.conf.structure
Class Node

java.lang.Object
  extended by org.apache.stratos.lb.common.conf.structure.Node
All Implemented Interfaces:
Serializable

public class Node
extends Object
implements Serializable

This is the basic data structure which holds a Nginx formatted configuration file.

See Also:
Serialized Form

Constructor Summary
Node()
           
 
Method Summary
 void addProperty(String key, String value)
          Adds a new property to properties Map of this Node if and only if key is not null.
 void appendChild(Node aNode)
          Appends a child node at the end of the List of child nodes of this Node, if a similar node is not already present as a child node.
 String childNodesToString(int indentation)
          This will convert each child Node of this Node to a String.
 boolean equals(Object node)
           
 Node findChildNodeByName(String name)
          This will try to find a child Node of this Node, which has the given name.
 List<Node> getChildNodes()
          Returns child nodes List of this Node.
 String getName()
          Returns the name of this Node.
 Map<String,String> getProperties()
          Returns properties Map of this Node.
 String getProperty(String key)
          Returns the value of a given property.
 int hashCode()
           
 String propertiesToString(int indentation)
          Returns all the properties of this Node as a String.
 boolean removeChildNode(Node node)
          Removes the first occurrence of a node equals to the given node.
 Node removeChildNode(String name)
          Removes the first occurrence of a node having the given name and returns the removed Node.
 void setChildNodes(List<Node> childNodes)
           
 void setName(String name)
          Sets the name of this Node.
 void setProperties(Map<String,String> properties)
           
 String toString()
          Convert this Node to a String which is in Nginx format.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node()
Method Detail

setChildNodes

public void setChildNodes(List<Node> childNodes)

setProperties

public void setProperties(Map<String,String> properties)

childNodesToString

public String childNodesToString(int indentation)
This will convert each child Node of this Node to a String.

Returns:
a string which represents child nodes of this node.

findChildNodeByName

public Node findChildNodeByName(String name)
This will try to find a child Node of this Node, which has the given name.

Parameters:
name - name of the child node to find.
Returns:
child Node object if found or else null.

getName

public String getName()
Returns the name of this Node.

Returns:
name of the node.

getChildNodes

public List<Node> getChildNodes()
Returns child nodes List of this Node.

Returns:
List of Node

getProperties

public Map<String,String> getProperties()
Returns properties Map of this Node.

Returns:
Map whose keys and values are String.

getProperty

public String getProperty(String key)
Returns the value of a given property.

Parameters:
key - name of a property.
Returns:
trimmed value if the property is found in this Node, or else null.

propertiesToString

public String propertiesToString(int indentation)
Returns all the properties of this Node as a String. Key and value of the property is separated by a tab (\t) character and each property is separated by a new line character.

Parameters:
indentation - relative number of tabs
Returns:
properties of this node as a String.

removeChildNode

public Node removeChildNode(String name)
Removes the first occurrence of a node having the given name and returns the removed Node.

Parameters:
name - name of the child node to be removed.
Returns:
removed Node or else null.

removeChildNode

public boolean removeChildNode(Node node)
Removes the first occurrence of a node equals to the given node.

Parameters:
node - Node to be removed.
Returns:
whether the removal is successful or not.

setName

public void setName(String name)
Sets the name of this Node.

Parameters:
name - String to be set as the name.

appendChild

public void appendChild(Node aNode)
Appends a child node at the end of the List of child nodes of this Node, if a similar node is not already present as a child node.

Parameters:
aNode - child Node to be appended.

addProperty

public void addProperty(String key,
                        String value)
Adds a new property to properties Map of this Node if and only if key is not null.

Parameters:
key - name of the property to be added.
value - value of the property to be added.

toString

public String toString()
Convert this Node to a String which is in Nginx format.
Sample:

ij {
klm n;
pq {
rst u;
}
}

Overrides:
toString in class Object

equals

public boolean equals(Object node)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.