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 MethodBreakpoint extends JPDABreakpoint { 42 43 44 public static final String PROP_METHOD_NAME = "methodName"; 46 public static final String PROP_BREAKPOINT_TYPE = "breakpointtType"; 48 public static final String PROP_CONDITION = "condition"; 50 public static final String PROP_CLASS_FILTERS = "classFilters"; 52 public static final String PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; 54 55 public static final int TYPE_METHOD_ENTRY = 1; 56 57 public static final int TYPE_METHOD_EXIT = 2; 58 59 60 private String [] classFilters = new String [0]; 61 private String [] classExclusionFilters = new String [0]; 62 private String methodName = ""; 63 private int breakpointType = TYPE_METHOD_ENTRY; 64 private String condition = ""; 65 66 67 private MethodBreakpoint () { 68 } 69 70 77 public static MethodBreakpoint create ( 78 String className, 79 String methodName 80 ) { 81 MethodBreakpoint b = new MethodBreakpointImpl (); 82 b.setClassFilters (new String [] {className}); 83 b.setMethodName (methodName); 84 return b; 85 } 86 87 92 public static MethodBreakpoint create ( 93 ) { 94 MethodBreakpoint b = new MethodBreakpointImpl (); 95 return b; 96 } 97 98 103 public String getMethodName () { 104 return methodName; 105 } 106 107 112 public void setMethodName (String mn) { 113 if (mn != null) { 114 mn = mn.trim(); 115 } 116 if ( (mn == methodName) || 117 ((mn != null) && (methodName != null) && methodName.equals (mn)) 118 ) return; 119 String old = methodName; 120 methodName = mn; 121 firePropertyChange (PROP_METHOD_NAME, old, mn); 122 } 123 124 129 public String getCondition () { 130 return condition; 131 } 132 133 138 public void setCondition (String cond) { 139 if (cond != null) { 140 cond = cond.trim(); 141 } 142 String old = condition; 143 condition = cond; 144 firePropertyChange (PROP_CONDITION, old, cond); 145 } 146 147 152 public int getBreakpointType () { 153 return breakpointType; 154 } 155 156 161 public void setBreakpointType (int breakpointType) { 162 if (breakpointType == this.breakpointType) return; 163 if ((breakpointType & (TYPE_METHOD_ENTRY | TYPE_METHOD_EXIT)) == 0) 164 throw new IllegalArgumentException (); 165 int old = this.breakpointType; 166 this.breakpointType = breakpointType; 167 firePropertyChange (PROP_BREAKPOINT_TYPE, new Integer (old), new Integer (breakpointType)); 168 } 169 170 175 public String [] getClassFilters () { 176 return classFilters; 177 } 178 179 184 public void setClassFilters (String [] classFilters) { 185 if (classFilters == this.classFilters) return; 186 Object old = this.classFilters; 187 this.classFilters = classFilters; 188 firePropertyChange (PROP_CLASS_FILTERS, old, classFilters); 189 } 190 191 196 public String [] getClassExclusionFilters () { 197 return classExclusionFilters; 198 } 199 200 205 public void setClassExclusionFilters (String [] classExclusionFilters) { 206 if (classExclusionFilters == this.classExclusionFilters) return; 207 Object old = this.classExclusionFilters; 208 this.classExclusionFilters = classExclusionFilters; 209 firePropertyChange (PROP_CLASS_EXCLUSION_FILTERS, old, classExclusionFilters); 210 } 211 212 217 public String toString () { 218 return "MethodBreakpoint " + java.util.Arrays.asList(classFilters).toString() + "." + methodName; 219 } 220 221 private static final class MethodBreakpointImpl extends MethodBreakpoint implements ChangeListener { 222 223 public void stateChanged(ChangeEvent chev) { 224 Object source = chev.getSource(); 225 if (source instanceof Breakpoint.VALIDITY) { 226 setValidity((Breakpoint.VALIDITY) source, chev.toString()); 227 } else { 228 throw new UnsupportedOperationException (chev.toString()); 229 } 230 } 231 } 232 } 233 | Popular Tags |