1 19 20 package org.netbeans.api.debugger.jpda; 21 22 import javax.swing.event.ChangeEvent ; 23 import javax.swing.event.ChangeListener ; 24 import org.netbeans.api.debugger.Breakpoint; 25 26 41 public class FieldBreakpoint extends JPDABreakpoint { 42 43 44 public static final String PROP_FIELD_NAME = "fieldName"; 46 public static final String PROP_CLASS_NAME = "className"; 48 public static final String PROP_CONDITION = "condition"; 50 public static final String PROP_BREAKPOINT_TYPE = "breakpointType"; 52 53 public static final int TYPE_ACCESS = 1; 54 55 public static final int TYPE_MODIFICATION = 2; 56 57 private String className = ""; 58 private String fieldName = ""; 59 private int type = TYPE_MODIFICATION; 60 private String condition = ""; 62 63 private FieldBreakpoint () { 64 } 65 66 75 public static FieldBreakpoint create ( 76 String className, 77 String fieldName, 78 int breakpointType 79 ) { 80 FieldBreakpoint b = new FieldBreakpointImpl (); 81 b.setClassName (className); 82 b.setFieldName (fieldName); 83 b.setBreakpointType (breakpointType); 84 return b; 85 } 86 87 92 public String getClassName () { 93 return className; 94 } 95 96 101 public void setClassName (String className) { 102 if ( (className == this.className) || 103 ( (className != null) && 104 (this.className != null) && 105 this.className.equals (className) 106 ) 107 ) return; 108 Object old = this.className; 109 this.className = className; 110 firePropertyChange (PROP_CLASS_NAME, old, className); 111 } 112 113 118 public String getFieldName () { 119 return fieldName; 120 } 121 122 127 public void setFieldName (String name) { 128 if (name != null) { 129 name = name.trim(); 130 } 131 if ( (name == fieldName) || 132 ((name != null) && (fieldName != null) && fieldName.equals (name)) 133 ) return; 134 String old = fieldName; 135 fieldName = name; 136 firePropertyChange (PROP_FIELD_NAME, old, fieldName); 137 } 138 139 144 public int getBreakpointType () { 145 return type; 146 } 147 148 153 public void setBreakpointType (int type) { 154 if (this.type == type) return; 155 if ( (type != TYPE_MODIFICATION) && 156 (type != TYPE_ACCESS) 157 ) throw new IllegalArgumentException (); 158 int old = this.type; 159 this.type = type; 160 firePropertyChange (PROP_BREAKPOINT_TYPE, new Integer (old), new Integer (type)); 161 } 162 163 168 public String getCondition () { 169 return condition; 170 } 171 172 177 public void setCondition (String cond) { 178 if (cond != null) { 179 cond = cond.trim(); 180 } 181 String old = condition; 182 condition = cond; 183 firePropertyChange (PROP_CONDITION, old, cond); 184 } 185 186 191 public String toString () { 192 return "FieldBreakpoint " + className + "." + fieldName; 193 } 194 195 private static final class FieldBreakpointImpl extends FieldBreakpoint implements ChangeListener { 196 197 public void stateChanged(ChangeEvent chev) { 198 Object source = chev.getSource(); 199 if (source instanceof Breakpoint.VALIDITY) { 200 setValidity((Breakpoint.VALIDITY) source, chev.toString()); 201 } else { 202 throw new UnsupportedOperationException (chev.toString()); 203 } 204 } 205 } 206 } 207 | Popular Tags |