1 9 10 package org.eclipse.ui.intro.config; 11 12 import java.util.ArrayList ; 13 import java.util.Enumeration ; 14 import java.util.Hashtable ; 15 16 24 public class IntroElement { 25 26 private String name; 27 private String value; 28 private Hashtable atts = new Hashtable (); 29 private ArrayList children; 30 31 37 public IntroElement(String name) { 38 this.name = name; 39 } 40 41 49 public void setAttribute(String name, String value) { 50 atts.put(name, value); 51 } 52 53 60 public String getAttribute(String name) { 61 return (String ) atts.get(name); 62 } 63 64 69 70 public Enumeration getAttributes() { 71 return atts.keys(); 72 } 73 74 79 public String getName() { 80 return name; 81 } 82 83 88 public String getValue() { 89 return value; 90 } 91 92 98 public void setValue(String value) { 99 this.value = value; 100 } 101 102 108 public void addChild(IntroElement child) { 109 if (children == null) 110 children = new ArrayList (); 111 children.add(child); 112 } 113 114 119 public IntroElement[] getChildren() { 120 if (children == null) 121 return new IntroElement[0]; 122 return (IntroElement[]) children.toArray(new IntroElement[children.size()]); 123 } 124 125 public boolean equals(Object obj) { 126 if (obj instanceof IntroElement) { 127 if (obj == this) { 128 return true; 129 } 130 String id1 = (String )atts.get("id"); String id2 = (String )((IntroElement)obj).atts.get("id"); if (id1 == null && id2 == null) { 133 return super.equals(obj); 134 } 135 if (id1 != null && id2 != null) { 136 return id1.equals(id2); 137 } 138 } 139 return false; 140 } 141 } | Popular Tags |