1 19 20 package org.netbeans.modules.schema2beansdev; 21 22 import java.beans.*; 23 import java.io.*; 24 25 public class TestListener implements PropertyChangeListener { 26 public PrintStream out; 27 public boolean printStackTrace; 28 29 public TestListener(PrintStream out) { 30 this.out = out; 31 } 32 33 public void propertyChange(PropertyChangeEvent e) { 34 out.print("oldValue="); 35 printValue(e.getOldValue()); 36 out.println(); 37 out.print("newValue="); 38 printValue(e.getNewValue()); 39 out.println(); 40 out.println("propertyName="+e.getPropertyName()); 41 out.println("source="+e.getSource()); 42 if (printStackTrace) { 43 new Exception ().printStackTrace(); 44 } 45 } 46 47 public void printValue(Object v) { 48 if (v == null) { 49 out.print("null"); 50 return; 51 } 52 Class cls = v.getClass(); 53 if (cls.isArray()) { 54 out.print("{"); 55 Object [] arr = (Object []) v; 56 for (int i = 0; i < arr.length; ++i) { 57 if (i > 0) 58 out.print(", "); 59 printValue(arr[i]); 60 } 61 out.print("}"); 62 } else { 63 out.print(""+v); 64 } 65 } 66 } 67 | Popular Tags |