1 16 package org.apache.myfaces.custom.tree.model; 17 18 19 33 public class TreeModelEvent 34 { 35 36 private Object source; 37 private TreePath path; 38 private int[] childIndices; 39 private Object [] children; 40 41 42 57 public TreeModelEvent(Object source, Object [] path, int[] childIndices, Object [] children) 58 { 59 this(source, new TreePath(path), childIndices, children); 60 } 61 62 63 74 public TreeModelEvent(Object source, TreePath path, int[] childIndices, Object [] children) 75 { 76 this.source = source; 77 this.path = path; 78 this.childIndices = childIndices; 79 this.children = children; 80 } 81 82 83 91 public TreeModelEvent(Object source, Object [] path) 92 { 93 this(source, new TreePath(path)); 94 } 95 96 97 105 public TreeModelEvent(Object source, TreePath path) 106 { 107 this.source = source; 108 this.path = path; 109 this.childIndices = new int[0]; 110 } 111 112 113 118 public Object getSource() 119 { 120 return source; 121 } 122 123 124 138 public TreePath getTreePath() 139 { 140 return path; 141 } 142 143 144 153 public Object [] getChildren() 154 { 155 if (children != null) 156 { 157 Object [] answer = new Object [children.length]; 158 159 System.arraycopy(children, 0, answer, 0, children.length); 160 return answer; 161 } 162 return null; 163 } 164 165 166 175 public int[] getChildIndices() 176 { 177 if (childIndices != null) 178 { 179 int[] answer = new int[childIndices.length]; 180 181 System.arraycopy(childIndices, 0, answer, 0, childIndices.length); 182 return answer; 183 } 184 return null; 185 } 186 187 188 194 public String toString() 195 { 196 StringBuffer buffer = new StringBuffer (); 197 198 buffer.append(super.toString()); 199 if (path != null) 200 { 201 buffer.append(" path " + path); 202 } 203 if (childIndices != null) 204 { 205 buffer.append(" indices [ "); 206 for (int i = 0; i < childIndices.length; i++) 207 { 208 buffer.append(Integer.toString(childIndices[i]) + " "); 209 } 210 buffer.append("]"); 211 } 212 if (children != null) 213 { 214 buffer.append(" children [ "); 215 for (int i = 0; i < children.length; i++) 216 { 217 buffer.append(children[i] + " "); 218 } 219 buffer.append("]"); 220 } 221 return buffer.toString(); 222 } 223 224 } 225 | Popular Tags |