KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdi > internal > event > WatchpointEventImpl


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdi.internal.event;
12
13
14 import java.io.DataInputStream JavaDoc;
15 import java.io.IOException JavaDoc;
16
17 import org.eclipse.jdi.internal.FieldImpl;
18 import org.eclipse.jdi.internal.MirrorImpl;
19 import org.eclipse.jdi.internal.ObjectReferenceImpl;
20 import org.eclipse.jdi.internal.VirtualMachineImpl;
21 import org.eclipse.jdi.internal.request.RequestID;
22
23 import com.sun.jdi.Field;
24 import com.sun.jdi.ObjectReference;
25 import com.sun.jdi.Value;
26 import com.sun.jdi.event.WatchpointEvent;
27
28 /**
29  * This class implements the corresponding interfaces
30  * declared by the JDI specification. See the com.sun.jdi package
31  * for more information.
32  *
33  */

34 public abstract class WatchpointEventImpl extends LocatableEventImpl implements WatchpointEvent {
35     /** The field that is about to be accessed/modified. */
36     protected FieldImpl fField;
37     /** The object whose field is about to be accessed/modified. */
38     protected ObjectReferenceImpl fObjectReference;
39     
40     /**
41      * Creates new WatchpointEventImpl.
42      */

43     protected WatchpointEventImpl(String JavaDoc description, VirtualMachineImpl vmImpl, RequestID requestID) {
44         super(description, vmImpl, requestID);
45     }
46
47     /**
48      * @return Creates, reads and returns new EventImpl, of which requestID has already been read.
49      */

50     public void readWatchpointEventFields(MirrorImpl target, DataInputStream JavaDoc dataInStream) throws IOException JavaDoc {
51         readThreadAndLocation(target, dataInStream);
52         fField = FieldImpl.readWithReferenceTypeWithTag(target, dataInStream);
53         fObjectReference = ObjectReferenceImpl.readObjectRefWithTag(target, dataInStream);
54     }
55
56     /**
57      * Returns the field that is about to be accessed/modified.
58      */

59     public Field field() {
60         return fField;
61     }
62     
63     /**
64      * Returns the object whose field is about to be accessed/modified.
65      */

66     public ObjectReference object() {
67         return fObjectReference;
68     }
69     
70     /**
71      * Current value of the field.
72      */

73     public Value valueCurrent() {
74         // Note: if field is static, fObjectReference will be null.
75
if (fObjectReference == null)
76             return fField.declaringType().getValue(fField);
77         return fObjectReference.getValue(fField);
78     }
79 }
80
Popular Tags