/bundles/plugins-trunk/XInsert/src/XTreeNode.java

# · Java · 78 lines · 42 code · 13 blank · 23 comment · 10 complexity · 7ae619385f664f18a24d8d18c3ad270a MD5 · raw file

  1. /*
  2. * 17:26:43 01/08/99
  3. *
  4. * XTreeNode.java - Part of the XTree system
  5. * Copyright (C) 1999 Romain Guy - powerteam@chez.com
  6. * Portions Copyright (C) 2000 Dominic Stolerman - dominic@sspd.org.uk
  7. * www.chez.com/powerteam
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. import java.util.Hashtable;
  24. import javax.swing.tree.*;
  25. public class XTreeNode extends DefaultMutableTreeNode {
  26. private int pos = -1;
  27. private Hashtable table;
  28. public XTreeNode(String userObject) {
  29. super(userObject);
  30. }
  31. public XTreeNode(String userObject, int pos) {
  32. super(userObject);
  33. this.pos = pos;
  34. }
  35. public void setIndex(int pos) {
  36. this.pos = pos;
  37. }
  38. public int getIndex() {
  39. return pos;
  40. }
  41. public void addVariable(String key, String value) {
  42. if(table == null)
  43. table = new Hashtable();
  44. table.put(key, value);
  45. }
  46. public String getVariable(String key) {
  47. if(table != null)
  48. return (String)table.get(key);
  49. else
  50. return null;
  51. }
  52. public boolean containsVariable(String key) {
  53. if(table != null)
  54. return table.containsKey(key);
  55. else
  56. return false;
  57. }
  58. public boolean hasVariables() {
  59. if(table != null && !table.isEmpty())
  60. return true;
  61. else
  62. return false;
  63. }
  64. }
  65. // End of XTreeNode.java