1 /* 2 * UnBBayes 3 * Copyright (C) 2002, 2008 Universidade de Brasilia - http://www.unb.br 4 * 5 * This file is part of UnBBayes. 6 * 7 * UnBBayes is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * UnBBayes is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with UnBBayes. If not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 package unbbayes.prs; 22 23 import java.util.List; 24 25 import unbbayes.prs.exception.InvalidParentException; 26 27 /** 28 * Interface representing a generic node, containing only references and state 29 * information (it does not contain visual/graphical data) 30 * @version 04/18/2009 31 * @author Shou Matsumoto 32 * Refactor: interface extraction Node -> INode 33 * 34 */ 35 public interface INode { 36 37 /** 38 * Changes node's description. 39 * 40 * @param text 41 * node's description. 42 */ 43 public abstract void setDescription(String text); 44 45 /** 46 * Set the node's name, which in most cases it is the node's ID. 47 * 48 * @param name 49 * Node's name. 50 */ 51 public abstract void setName(String name); 52 53 /** 54 * Sets a new list of children. 55 * @param children 56 * List of nodes representing the children. 57 */ 58 public abstract void setChildNodes(List<INode> children); 59 60 /** 61 * Sets a new list of parents. 62 * @param parents 63 * List of nodes representing the parents. 64 */ 65 public abstract void setParentNodes(List<INode> parents); 66 67 /** 68 * Adds a child to this node 69 * @param child 70 * @throws InvalidParentException 71 */ 72 public abstract void addChildNode(INode child) throws InvalidParentException; 73 74 /** 75 * Removes a child from this node 76 * @param child 77 */ 78 public abstract void removeChildNode(INode child); 79 80 /** 81 * Add a parent to this node 82 * @param parent 83 * @throws InvalidParentException 84 */ 85 public abstract void addParentNode(INode parent) throws InvalidParentException; 86 87 /** 88 * Removes a parent from this node 89 * @param parent 90 */ 91 public abstract void removeParentNode(INode parent); 92 93 94 95 /** 96 * Obtains the name of this node. 97 * @return node's description. 98 */ 99 public abstract String getDescription(); 100 101 /** 102 * Obtains a list of adjacent nodes. 103 * @return reference for this node's adjacents. 104 */ 105 public abstract List<INode> getAdjacentNodes(); 106 107 /** 108 * Returns the node's literal symbol. 109 * 110 * @return node's literal abbreviation. 111 */ 112 public abstract String getName(); 113 114 /** 115 * Obtains a list of children. 116 * @return list of children. 117 */ 118 public abstract List<INode> getChildNodes(); 119 120 /** 121 * Obtains a list of parents. 122 * @return list of parents. 123 */ 124 public abstract List<INode> getParentNodes(); 125 126 /** 127 * Inserts a state with the specified name at the end of the list. 128 * @param state 129 * Name of the state to be added. 130 */ 131 public abstract void appendState(String state); 132 133 /** 134 * Deletes the node's last inserted state (i.e the last element inside the list of states). 135 */ 136 public abstract void removeLastState(); 137 138 /** 139 * Used within dalgo2. It should not be used with nodes having potential table's informations. 140 */ 141 public abstract void removeStateAt(int index); 142 143 /** 144 * Replaces a state at given position to the specified position. 145 * @param state 146 * Name of the new state. 147 * @param index 148 * Position of the state being substituted. Starts with 0. 149 */ 150 public abstract void setStateAt(String state, int index); 151 152 /** 153 * It returns the node's quantity of states. 154 * @return How many states the node has. 155 */ 156 public abstract int getStatesSize(); 157 158 /** 159 * Returns the state of the position given by <code>index</code> 160 * @param index 161 * position of the state to be read. 162 * @return Name of the state at <code>index</code> 163 */ 164 public abstract String getStateAt(int index); 165 166 167 168 /** 169 * Sets the states. 170 * 171 * @param states 172 * The states to set 173 */ 174 public abstract void setStates(List<String> states); 175 176 /** 177 * Method to extract node's type. 178 * It is free to use any value as any meaning. 179 * @return 180 */ 181 public abstract int getType(); 182 183 184 }