| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BooleanNode |
|
| 1.2307692307692308;1.231 |
| 1 | /** | |
| 2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
| 3 | * Educational Community License, Version 2.0 (the "License"); you may | |
| 4 | * not use this file except in compliance with the License. You may | |
| 5 | * obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.osedu.org/licenses/ECL-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, | |
| 10 | * software distributed under the License is distributed on an "AS IS" | |
| 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 12 | * or implied. See the License for the specific language governing | |
| 13 | * permissions and limitations under the License. | |
| 14 | */ | |
| 15 | ||
| 16 | package org.kuali.student.common.messagebuilder.booleanmessage.ast; | |
| 17 | ||
| 18 | import org.antlr.runtime.Token; | |
| 19 | import org.antlr.runtime.tree.CommonTree; | |
| 20 | ||
| 21 | /** | |
| 22 | * This class is a boolean node in a binary tree. | |
| 23 | */ | |
| 24 | 0 | public class BooleanNode extends CommonTree { |
| 25 | ||
| 26 | private BooleanNode parent; | |
| 27 | private Boolean value; | |
| 28 | private String nodeMessage; | |
| 29 | private String language; | |
| 30 | ||
| 31 | /** | |
| 32 | * Construct a boolean node for a particular token in a binary tree. | |
| 33 | * Tokens are +, *, (, ) and propositions e.g. tokens: (M1*M2)+M3 | |
| 34 | * See BooleanFunctionParser.java | |
| 35 | * | |
| 36 | * @param payload Node token | |
| 37 | */ | |
| 38 | public BooleanNode(Token payload) { | |
| 39 | 817 | super(payload); |
| 40 | 817 | } |
| 41 | ||
| 42 | /** | |
| 43 | * Gets the parent boolean node. | |
| 44 | * | |
| 45 | * @return Parent boolean node | |
| 46 | */ | |
| 47 | public BooleanNode getParent(){ | |
| 48 | 315 | return parent; |
| 49 | } | |
| 50 | ||
| 51 | /** | |
| 52 | * Gets the b-tree left node. | |
| 53 | * | |
| 54 | * @return B-tree left boolean node | |
| 55 | */ | |
| 56 | public BooleanNode getLeftNode(){ | |
| 57 | 638 | return (BooleanNode) this.getChild(0); |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 | * Gets the b-tree right node. | |
| 62 | * | |
| 63 | * @return B-tree right boolean node | |
| 64 | */ | |
| 65 | public BooleanNode getRightNode(){ | |
| 66 | 501 | return (BooleanNode) this.getChild(1); |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * Gets the label of the node. | |
| 71 | * | |
| 72 | * @return Node label | |
| 73 | */ | |
| 74 | public String getLabel(){ | |
| 75 | 1137 | return this.getText(); |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * Gets the boolean value (true or false). | |
| 80 | * | |
| 81 | * @return Boolean value | |
| 82 | */ | |
| 83 | public Boolean getValue(){ | |
| 84 | 499 | return value; |
| 85 | } | |
| 86 | ||
| 87 | /** | |
| 88 | * Gets the node message. | |
| 89 | * | |
| 90 | * @return Node message | |
| 91 | */ | |
| 92 | public String getNodeMessage(){ | |
| 93 | 664 | return nodeMessage; |
| 94 | } | |
| 95 | ||
| 96 | /** | |
| 97 | * Gets the message language. | |
| 98 | * | |
| 99 | * @return Message language | |
| 100 | */ | |
| 101 | public String getLanguage() { | |
| 102 | 1 | return language; |
| 103 | } | |
| 104 | ||
| 105 | /** | |
| 106 | * org.antlr.runtime.tree.CommonTree.getParent() is not implemented | |
| 107 | * you have to set the parent yourself, BinaryMessageTree.java | |
| 108 | * | |
| 109 | * @param parent Parent node | |
| 110 | */ | |
| 111 | public void setParent(BooleanNode parent){ | |
| 112 | 270 | this.parent = parent; |
| 113 | 270 | } |
| 114 | ||
| 115 | /** | |
| 116 | * Sets the boolean value (true or false). | |
| 117 | * | |
| 118 | * @param value Boolean value | |
| 119 | */ | |
| 120 | public void setValue(Boolean value){ | |
| 121 | 164 | this.value = value; |
| 122 | 164 | } |
| 123 | ||
| 124 | /** | |
| 125 | * Sets the node message. | |
| 126 | * | |
| 127 | * @param nodeMessage Node message | |
| 128 | */ | |
| 129 | public void setNodeMessage(String nodeMessage){ | |
| 130 | 250 | this.nodeMessage = nodeMessage; |
| 131 | 250 | } |
| 132 | ||
| 133 | /** | |
| 134 | * Sets the message language. | |
| 135 | * | |
| 136 | * @param language Message language | |
| 137 | */ | |
| 138 | public void setLanguage(String language) { | |
| 139 | 117 | this.language = language; |
| 140 | 117 | } |
| 141 | ||
| 142 | @Override | |
| 143 | public String toString() { | |
| 144 | 8 | return "BooleanNode[" |
| 145 | + "label=" + getLabel() | |
| 146 | + ", value=" + value | |
| 147 | + ", leftNodeLabel=" + (getLeftNode() == null ? null : getLeftNode().getLabel()) | |
| 148 | + ", rightNodeLabel=" + (getRightNode() == null ? null : getRightNode().getLabel()) | |
| 149 | + ", parentLabel=" + (parent == null ? null : parent.getLabel()) | |
| 150 | + "]"; | |
| 151 | } | |
| 152 | ||
| 153 | } |