+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// TreeNodeImpl.java\r
-// Since: 2009/03/30 23:09:43\r
-//\r
-// $URL$\r
-// $Author$\r
-//--------------------------------------\r
-package org.xerial.util.tree.impl;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.xerial.util.tree.TreeNode;\r
-\r
-public class TreeNodeImpl implements TreeNode\r
-{\r
- String nodeName = null;\r
- String nodeValue = null;\r
- List<TreeNode> childNodes = new ArrayList<TreeNode>();\r
-\r
- public TreeNodeImpl(String nodeName, String nodeValue)\r
- {\r
- this.nodeName = nodeName;\r
- this.nodeValue = nodeValue;\r
- }\r
-\r
- public TreeNodeImpl addNode(TreeNodeImpl node)\r
- {\r
- childNodes.add(node);\r
- return node;\r
- }\r
-\r
- public List<TreeNode> getChildren()\r
- {\r
- return childNodes;\r
- }\r
-\r
- public String getNodeName()\r
- {\r
- return nodeName;\r
- }\r
-\r
- public String getNodeValue()\r
- {\r
- return nodeValue;\r
- }\r
-\r
- public void setNodeValue(String nodeValue)\r
- {\r
- this.nodeValue = nodeValue;\r
- }\r
-\r
- @Override\r
- public String toString()\r
- {\r
- StringBuilder buf = new StringBuilder();\r
- buf.append(nodeName);\r
- if (nodeValue != null)\r
- {\r
- buf.append(":");\r
- buf.append(nodeValue);\r
- }\r
- if (!childNodes.isEmpty())\r
- {\r
- buf.append("(");\r
- int index = 0;\r
- for (TreeNode each : childNodes)\r
- {\r
- if (index != 0)\r
- buf.append(", ");\r
- buf.append(each);\r
- index++;\r
- }\r
- buf.append(")");\r
- }\r
-\r
- return buf.toString();\r
- }\r
-\r
-}\r