// XAAL toolkit // Copyright (C) 2009 Ville Karavirta // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package xaal.objects.structures; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import xaal.objects.AddStructure; import xaal.objects.Xaal; /** * @author vkaravir * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class Node extends Structure implements AddStructure { private Structure content; private String label; private DataStructure parent; /** * */ public Node(Xaal xaalDoc, DataStructure parent) { super(xaalDoc); this.parent = parent; } /** * @return Returns the content. */ public Structure getContent() { return content; } /** * @param content The content to set. */ public void setContent(Structure content) { if (content instanceof Edge) { // TODO Common error logging - reference as node content return; } if (content instanceof Node) this.content = (Structure) ((Node)content).getContent(); this.content = content; } /** * @return Returns the label. */ public String getLabel() { return label; } /** * @param label The label to set. */ public void setLabel(String label) { this.label = label; } public void addStructure(DataStructure ds) { setContent(ds); } public void addStructure(Structure s) { setContent(s); } /** * @return */ public boolean isLabeled() { return (label != null); } public DataStructure getParent() { return parent; } public Iterator getStructures() { List l = new LinkedList(); l.add(content); return l.iterator(); } }