01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdi.internal.event;
11:
12: import java.io.DataInputStream;
13: import java.io.IOException;
14:
15: import org.eclipse.jdi.internal.FieldImpl;
16: import org.eclipse.jdi.internal.MirrorImpl;
17: import org.eclipse.jdi.internal.ObjectReferenceImpl;
18: import org.eclipse.jdi.internal.VirtualMachineImpl;
19: import org.eclipse.jdi.internal.request.RequestID;
20:
21: import com.sun.jdi.Field;
22: import com.sun.jdi.ObjectReference;
23: import com.sun.jdi.Value;
24: import com.sun.jdi.event.WatchpointEvent;
25:
26: /**
27: * This class implements the corresponding interfaces
28: * declared by the JDI specification. See the com.sun.jdi package
29: * for more information.
30: *
31: */
32: public abstract class WatchpointEventImpl extends LocatableEventImpl
33: implements WatchpointEvent {
34: /** The field that is about to be accessed/modified. */
35: protected FieldImpl fField;
36: /** The object whose field is about to be accessed/modified. */
37: protected ObjectReferenceImpl fObjectReference;
38:
39: /**
40: * Creates new WatchpointEventImpl.
41: */
42: protected WatchpointEventImpl(String description,
43: 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,
51: DataInputStream dataInStream) throws IOException {
52: readThreadAndLocation(target, dataInStream);
53: fField = FieldImpl.readWithReferenceTypeWithTag(target,
54: dataInStream);
55: fObjectReference = ObjectReferenceImpl.readObjectRefWithTag(
56: target, dataInStream);
57: }
58:
59: /**
60: * Returns the field that is about to be accessed/modified.
61: */
62: public Field field() {
63: return fField;
64: }
65:
66: /**
67: * Returns the object whose field is about to be accessed/modified.
68: */
69: public ObjectReference object() {
70: return fObjectReference;
71: }
72:
73: /**
74: * Current value of the field.
75: */
76: public Value valueCurrent() {
77: // Note: if field is static, fObjectReference will be null.
78: if (fObjectReference == null)
79: return fField.declaringType().getValue(fField);
80: return fObjectReference.getValue(fField);
81: }
82: }
|