Source Code Cross Referenced for FieldBreakpoint.java in  » IDE-Netbeans » ant » org » netbeans » api » debugger » jpda » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » ant » org.netbeans.api.debugger.jpda 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.api.debugger.jpda;
043:
044:        import java.util.Map;
045:        import java.util.WeakHashMap;
046:        import javax.swing.event.ChangeEvent;
047:        import javax.swing.event.ChangeListener;
048:        import org.netbeans.api.debugger.Breakpoint;
049:
050:        /**
051:         * Notifies about variable change or access events.
052:         *
053:         * <br><br>
054:         * <b>How to use it:</b>
055:         * <pre style="background-color: rgb(255, 255, 153);">
056:         *    DebuggerManager.addBreakpoint (FieldBreakpoint.create (
057:         *        "org.netbeans.modules.editor.EditorPanel",
058:         *        "state",
059:         *        FieldBreakpoint.TYPE_MODIFICATION
060:         *    ));</pre>
061:         * This breakpoint stops when state field of EditorPanel class is modified.
062:         *
063:         * @author Jan Jancura
064:         */
065:        public class FieldBreakpoint extends JPDABreakpoint {
066:
067:            /** Property name constant. */
068:            public static final String PROP_FIELD_NAME = "fieldName"; // NOI18N
069:            /** Property name constant. */
070:            public static final String PROP_CLASS_NAME = "className"; // NOI18N
071:            /** Property name constant. */
072:            public static final String PROP_CONDITION = "condition"; // NOI18N
073:            /** Property name constant. */
074:            public static final String PROP_BREAKPOINT_TYPE = "breakpointType"; // NOI18N
075:            /** Property name constant */
076:            public static final String PROP_INSTANCE_FILTERS = "instanceFilters"; // NOI18N
077:            /** Property name constant */
078:            public static final String PROP_THREAD_FILTERS = "threadFilters"; // NOI18N
079:
080:            /** Property type value constant. */
081:            public static final int TYPE_ACCESS = 1;
082:            /** Property type value constant. */
083:            public static final int TYPE_MODIFICATION = 2;
084:
085:            private String className = "";
086:            private String fieldName = "";
087:            private int type = TYPE_MODIFICATION;
088:            private String condition = ""; // NOI18N
089:            private Map<JPDADebugger, ObjectVariable[]> instanceFilters;
090:            private Map<JPDADebugger, JPDAThread[]> threadFilters;
091:
092:            private FieldBreakpoint() {
093:            }
094:
095:            /**
096:             * Creates a new breakpoint for given parameters.
097:             *
098:             * @param className class name
099:             * @param fieldName name of field
100:             * @param breakpointType one of constants: TYPE_ACCESS, 
101:             *   TYPE_MODIFICATION
102:             * @return a new breakpoint for given parameters
103:             */
104:            public static FieldBreakpoint create(String className,
105:                    String fieldName, int breakpointType) {
106:                FieldBreakpoint b = new FieldBreakpointImpl();
107:                b.setClassName(className);
108:                b.setFieldName(fieldName);
109:                b.setBreakpointType(breakpointType);
110:                return b;
111:            }
112:
113:            /**
114:             * Get name of class the field is defined in.
115:             *
116:             * @return the name of class the field is defined in
117:             */
118:            public String getClassName() {
119:                return className;
120:            }
121:
122:            /**
123:             * Set name of class the field is defined in.
124:             *
125:             * @param className a new name of class the field is defined in
126:             */
127:            public void setClassName(String className) {
128:                if ((className == this .className)
129:                        || ((className != null) && (this .className != null) && this .className
130:                                .equals(className)))
131:                    return;
132:                Object old = this .className;
133:                this .className = className;
134:                firePropertyChange(PROP_CLASS_NAME, old, className);
135:            }
136:
137:            /**
138:             * Returns name of field.
139:             *
140:             * @return a name of field
141:             */
142:            public String getFieldName() {
143:                return fieldName;
144:            }
145:
146:            /**
147:             * Sets name of field.
148:             *
149:             * @param name a name of field
150:             */
151:            public void setFieldName(String name) {
152:                if (name != null) {
153:                    name = name.trim();
154:                }
155:                if ((name == fieldName)
156:                        || ((name != null) && (fieldName != null) && fieldName
157:                                .equals(name)))
158:                    return;
159:                String old = fieldName;
160:                fieldName = name;
161:                firePropertyChange(PROP_FIELD_NAME, old, fieldName);
162:            }
163:
164:            /**
165:             * Get the instance filter for a specific debugger session.
166:             * @return The instances or <code>null</code> when there is no instance restriction.
167:             */
168:            public ObjectVariable[] getInstanceFilters(JPDADebugger session) {
169:                if (instanceFilters != null) {
170:                    return instanceFilters.get(session);
171:                } else {
172:                    return null;
173:                }
174:            }
175:
176:            /**
177:             * Set the instance filter for a specific debugger session. This restricts
178:             * the breakpoint to specific instances in that session.
179:             * @param session the debugger session
180:             * @param instances the object instances or <code>null</code> to unset the filter.
181:             */
182:            public void setInstanceFilters(JPDADebugger session,
183:                    ObjectVariable[] instances) {
184:                if (instanceFilters == null) {
185:                    instanceFilters = new WeakHashMap<JPDADebugger, ObjectVariable[]>();
186:                }
187:                if (instances != null) {
188:                    instanceFilters.put(session, instances);
189:                } else {
190:                    instanceFilters.remove(session);
191:                }
192:                firePropertyChange(PROP_INSTANCE_FILTERS, null,
193:                        instances != null ? new Object[] { session, instances }
194:                                : null);
195:            }
196:
197:            /**
198:             * Get the thread filter for a specific debugger session.
199:             * @return The thread or <code>null</code> when there is no thread restriction.
200:             */
201:            public JPDAThread[] getThreadFilters(JPDADebugger session) {
202:                if (threadFilters != null) {
203:                    return threadFilters.get(session);
204:                } else {
205:                    return null;
206:                }
207:            }
208:
209:            /**
210:             * Set the thread filter for a specific debugger session. This restricts
211:             * the breakpoint to specific threads in that session.
212:             * @param session the debugger session
213:             * @param threads the threads or <code>null</code> to unset the filter.
214:             */
215:            public void setThreadFilters(JPDADebugger session,
216:                    JPDAThread[] threads) {
217:                if (threadFilters == null) {
218:                    threadFilters = new WeakHashMap<JPDADebugger, JPDAThread[]>();
219:                }
220:                if (threads != null) {
221:                    threadFilters.put(session, threads);
222:                } else {
223:                    threadFilters.remove(session);
224:                }
225:                firePropertyChange(PROP_THREAD_FILTERS, null,
226:                        threads != null ? new Object[] { session, threads }
227:                                : null);
228:            }
229:
230:            /**
231:             * Returns type of breakpoint (one of TYPE_ACCESS and TYPE_MODIFICATION).
232:             *
233:             * @return type of breakpoint
234:             */
235:            public int getBreakpointType() {
236:                return type;
237:            }
238:
239:            /**
240:             * Sets type of breakpoint.
241:             *
242:             * @param type a new type of breakpoint
243:             */
244:            public void setBreakpointType(int type) {
245:                if (this .type == type)
246:                    return;
247:                if ((type != TYPE_MODIFICATION) && (type != TYPE_ACCESS)
248:                        && (type != (TYPE_MODIFICATION | TYPE_ACCESS)))
249:                    throw new IllegalArgumentException();
250:                int old = this .type;
251:                this .type = type;
252:                firePropertyChange(PROP_BREAKPOINT_TYPE, new Integer(old),
253:                        new Integer(type));
254:            }
255:
256:            /**
257:             * Returns condition.
258:             *
259:             * @return cond a condition
260:             */
261:            public String getCondition() {
262:                return condition;
263:            }
264:
265:            /**
266:             * Sets condition.
267:             *
268:             * @param cond a c new condition
269:             */
270:            public void setCondition(String cond) {
271:                if (cond != null) {
272:                    cond = cond.trim();
273:                }
274:                String old = condition;
275:                condition = cond;
276:                firePropertyChange(PROP_CONDITION, old, cond);
277:            }
278:
279:            /**
280:             * Returns a string representation of this object.
281:             *
282:             * @return  a string representation of the object
283:             */
284:            public String toString() {
285:                return "FieldBreakpoint " + className + "." + fieldName;
286:            }
287:
288:            private static final class FieldBreakpointImpl extends
289:                    FieldBreakpoint implements  ChangeListener {
290:
291:                public void stateChanged(ChangeEvent chev) {
292:                    Object source = chev.getSource();
293:                    if (source instanceof  Breakpoint.VALIDITY) {
294:                        setValidity((Breakpoint.VALIDITY) source, chev
295:                                .toString());
296:                    } else {
297:                        throw new UnsupportedOperationException(chev.toString());
298:                    }
299:                }
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.