KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > InstructionPointerContext


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.debug.internal.ui;
12
13 import org.eclipse.debug.core.model.IDebugTarget;
14 import org.eclipse.debug.core.model.IThread;
15 import org.eclipse.jface.text.source.Annotation;
16 import org.eclipse.ui.texteditor.ITextEditor;
17
18 /**
19  * Represents the context for a single instruction pointer. This is a convenience class
20  * used to store the four objects that comprise an instruction pointer 'context' so it
21  * can be stored in collections.
22  */

23 public class InstructionPointerContext {
24
25     /**
26      * The thread this context belongs to.
27      */

28     private IThread fThread;
29     
30     /**
31      * The debug target this context belongs to.
32      */

33     private IDebugTarget fDebugTarget;
34     
35     /**
36      * The editor that the annotation is being displayed in
37      */

38     private ITextEditor fEditor;
39     
40     /**
41      * The vertical ruler annotation for this context.
42      */

43     private Annotation fAnnotation;
44
45     public InstructionPointerContext(IDebugTarget target, IThread thread, ITextEditor editor, Annotation annotation) {
46         fDebugTarget = target;
47         fThread = thread;
48         fEditor = editor;
49         fAnnotation = annotation;
50     }
51     
52     /* (non-Javadoc)
53      * @see java.lang.Object#equals(java.lang.Object)
54      */

55     public boolean equals(Object JavaDoc other) {
56         if (other instanceof InstructionPointerContext) {
57             InstructionPointerContext otherContext = (InstructionPointerContext) other;
58             if (getAnnotation().equals(otherContext.getAnnotation())){
59                 return getEditor().equals(otherContext.getEditor());
60             }
61         }
62         return false;
63     }
64     
65     /* (non-Javadoc)
66      * @see java.lang.Object#hashCode()
67      */

68     public int hashCode() {
69         return getAnnotation().hashCode() + getEditor().hashCode();
70     }
71
72     /**
73      * @return the thread
74      */

75     public IThread getThread() {
76         return fThread;
77     }
78
79     /**
80      * @return the debug target
81      */

82     public IDebugTarget getDebugTarget() {
83         return fDebugTarget;
84     }
85
86     /**
87      * @return the editor
88      */

89     public ITextEditor getEditor() {
90         return fEditor;
91     }
92     
93     /**
94      * @return the annotation
95      */

96     public Annotation getAnnotation() {
97         return fAnnotation;
98     }
99
100 }
101
Popular Tags