KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > debugger > Breakpoint


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.debugger;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeSupport JavaDoc;
24
25 /**
26  * Abstract definition of breakpoint.
27  *
28  * @author Jan Jancura
29  */

30 public abstract class Breakpoint {
31
32
33     /** Property name for enabled status of the breakpoint. */
34     public static final String JavaDoc PROP_ENABLED = "enabled"; // NOI18N
35
/** Property name for disposed state of the breakpoint. */
36     public static final String JavaDoc PROP_DISPOSED = "disposed"; // NOI18N
37
/** Property name for name of group of the breakpoint. */
38     public static final String JavaDoc PROP_GROUP_NAME = "groupName"; // NOI18N
39
/** Property name for breakpoint validity */
40     public static final String JavaDoc PROP_VALIDITY = "validity"; // NOI18N
41

42     /** Validity values */
43     public static enum VALIDITY { UNKNOWN, VALID, INVALID }
44     
45     /** Support for property listeners. */
46     private PropertyChangeSupport JavaDoc pcs;
47     private String JavaDoc groupName = "";
48     private VALIDITY validity = VALIDITY.UNKNOWN;
49     private String JavaDoc validityMessage;
50     
51     { pcs = new PropertyChangeSupport JavaDoc (this); }
52
53     /**
54      * Called when breakpoint is removed.
55      */

56     protected void dispose () {}
57
58     /**
59      * Test whether the breakpoint is enabled.
60      *
61      * @return <code>true</code> if so
62      */

63     public abstract boolean isEnabled ();
64     
65     /**
66      * Disables the breakpoint.
67      */

68     public abstract void disable ();
69     
70     /**
71      * Enables the breakpoint.
72      */

73     public abstract void enable ();
74     
75     /**
76      * Get the validity of this breakpoint.
77      * @return The breakpoint validity.
78      */

79     public final synchronized VALIDITY getValidity() {
80         return validity;
81     }
82     
83     /**
84      * Get the message describing the current validity. For invalid breakpoints
85      * this should describe the reason why it is invalid.<p>
86      * Intended for use by ui implementation code, NodeModel.getShortDescription(), for example.
87      * @return The validity message.
88      */

89     public final synchronized String JavaDoc getValidityMessage() {
90         return validityMessage;
91     }
92     
93     /**
94      * Set the validity of this breakpoint.
95      * @param validity The new breakpoint validity.
96      * @param reason The message describing why is this validity being set, or <code>null</code>.
97      */

98     protected final void setValidity(VALIDITY validity, String JavaDoc reason) {
99         VALIDITY old;
100         synchronized (this) {
101             this.validityMessage = reason;
102             if (this.validity == validity) return ;
103             old = this.validity;
104             this.validity = validity;
105         }
106         firePropertyChange(PROP_VALIDITY, old, validity);
107     }
108     
109     public String JavaDoc getGroupName () {
110         return groupName;
111     }
112     
113     public void setGroupName (String JavaDoc newGroupName) {
114         if (groupName.equals (newGroupName)) return;
115         String JavaDoc old = groupName;
116         groupName = newGroupName.intern();
117         firePropertyChange (PROP_GROUP_NAME, old, newGroupName);
118     }
119     
120     /**
121      * Add a listener to property changes.
122      *
123      * @param listener the listener to add
124      */

125     public synchronized void addPropertyChangeListener (
126         PropertyChangeListener JavaDoc listener
127     ) {
128         pcs.addPropertyChangeListener (listener);
129     }
130
131     /**
132      * Remove a listener to property changes.
133      *
134      * @param listener the listener to remove
135      */

136     public synchronized void removePropertyChangeListener (
137         PropertyChangeListener JavaDoc listener
138     ) {
139         pcs.removePropertyChangeListener (listener);
140     }
141
142     /**
143      * Adds a property change listener.
144      *
145      * @param propertyName a name of property to listen on
146      * @param l the listener to add
147      */

148     public void addPropertyChangeListener (
149         String JavaDoc propertyName, PropertyChangeListener JavaDoc l
150     ) {
151         pcs.addPropertyChangeListener (propertyName, l);
152     }
153
154     /**
155      * Removes a property change listener.
156      *
157      * @param propertyName a name of property to stop listening on
158      * @param l the listener to remove
159      */

160     public void removePropertyChangeListener (
161         String JavaDoc propertyName, PropertyChangeListener JavaDoc l
162     ) {
163         pcs.removePropertyChangeListener (propertyName, l);
164     }
165
166     /**
167      * Fire property change.
168      *
169      * @param name name of property
170      * @param o old value of property
171      * @param n new value of property
172      */

173     protected void firePropertyChange (String JavaDoc name, Object JavaDoc o, Object JavaDoc n) {
174         pcs.firePropertyChange (name, o, n);
175     }
176     
177     /**
178      * Called when breakpoint is removed.
179      */

180     void disposeOut () {
181         dispose ();
182         firePropertyChange (PROP_DISPOSED, Boolean.FALSE, Boolean.TRUE);
183     }
184 }
185
Popular Tags