KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > SynchronizeInfo


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.debug.internal.ui.views.memory;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Enumeration JavaDoc;
15 import java.util.Hashtable JavaDoc;
16
17 import org.eclipse.debug.core.model.IMemoryBlock;
18
19
20 /**
21  * Stores synchronization information for a memory block
22  * Each object of synchronization information contains a memory block,
23  * a list of views to be synchronized and a list of properties to be syncrhonized.
24  * The views are responsible for defining properties to be synchronized and notifying
25  * the synchronizer of properties changes. This is only for keeping track of
26  * values of synchronized properties and firing events when properties are changed.
27  *
28  * Memory block serves as a key for synchronization. Views displaying the same
29  * memory block can be synchronized. Views displaying different memory block
30  * cannot be synchronized.
31  *
32  * @since 3.0
33  */

34 public class SynchronizeInfo
35 {
36     private IMemoryBlock fBlock; // memory block blocked by the views
37
private Hashtable JavaDoc fProperties; // list of properties to be synchronized
38

39     /**
40      * Create a new synchronization info object for the memory block
41      * @param block
42      */

43     public SynchronizeInfo(IMemoryBlock block)
44     {
45         fBlock = block;
46         fProperties = new Hashtable JavaDoc();
47     }
48     
49     
50     /**
51      * Set a property and its value to the info object
52      * @param propertyId
53      * @param value
54      */

55     public void setProperty(String JavaDoc propertyId, Object JavaDoc value)
56     {
57         if (propertyId == null)
58             return;
59             
60         if (value == null)
61             return;
62             
63         fProperties.put(propertyId, value);
64     }
65     
66     /**
67      * Returns the value of the property from the info object
68      * @param propertyId
69      * @return value of the property
70      */

71     public Object JavaDoc getProperty(String JavaDoc propertyId)
72     {
73         if (propertyId == null)
74             return null;
75             
76         Object JavaDoc value = fProperties.get(propertyId);
77         
78         return value;
79     }
80     
81     /**
82      * @return all the property ids stored in this sync info object
83      */

84     public String JavaDoc[] getPropertyIds()
85     {
86         if (fProperties == null)
87             return new String JavaDoc[0];
88         
89         Enumeration JavaDoc enumeration = fProperties.keys();
90         ArrayList JavaDoc ids = new ArrayList JavaDoc();
91         
92         while (enumeration.hasMoreElements())
93         {
94             ids.add(enumeration.nextElement());
95         }
96         
97         return (String JavaDoc[])ids.toArray(new String JavaDoc[ids.size()]);
98     }
99     
100     /**
101      * Clean up the synchronization info object
102      */

103     public void delete()
104     {
105         
106         if (fProperties != null){
107             fProperties.clear();
108             fProperties = null;
109         }
110         
111         if (fBlock != null){
112             fBlock = null;
113         }
114     }
115 }
116
Popular Tags