KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > registry > RegistryDelta


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.core.internal.registry;
12
13 import java.util.*;
14 import org.eclipse.core.runtime.IExtension;
15 import org.eclipse.core.runtime.IExtensionDelta;
16
17 /**
18  * The extension deltas are grouped by namespace. There is one registry delta by namespace.
19  */

20 public class RegistryDelta {
21     private Set extensionDeltas = new HashSet(); //the extension deltas (each element indicate the type of the delta)
22
private IObjectManager objectManager; //The object manager from which all the objects contained in the deltas will be found.
23

24     RegistryDelta() {
25         //Nothing to do
26
}
27
28     public int getExtensionDeltasCount() {
29         return extensionDeltas.size();
30     }
31
32     public IExtensionDelta[] getExtensionDeltas() {
33         return (IExtensionDelta[]) extensionDeltas.toArray(new ExtensionDelta[extensionDeltas.size()]);
34     }
35
36     public IExtensionDelta[] getExtensionDeltas(String JavaDoc extensionPoint) {
37         Collection selectedExtDeltas = new LinkedList();
38         for (Iterator extDeltasIter = extensionDeltas.iterator(); extDeltasIter.hasNext();) {
39             IExtensionDelta extensionDelta = (IExtensionDelta) extDeltasIter.next();
40             if (extensionDelta.getExtension().getExtensionPointUniqueIdentifier().equals(extensionPoint))
41                 selectedExtDeltas.add(extensionDelta);
42         }
43         return (IExtensionDelta[]) selectedExtDeltas.toArray(new IExtensionDelta[selectedExtDeltas.size()]);
44     }
45
46     /**
47      * @param extensionPointId
48      * @param extensionId must not be null
49      */

50     public IExtensionDelta getExtensionDelta(String JavaDoc extensionPointId, String JavaDoc extensionId) {
51         for (Iterator extDeltasIter = extensionDeltas.iterator(); extDeltasIter.hasNext();) {
52             IExtensionDelta extensionDelta = (IExtensionDelta) extDeltasIter.next();
53             IExtension extension = extensionDelta.getExtension();
54             if (extension.getExtensionPointUniqueIdentifier().equals(extensionPointId) && extension.getUniqueIdentifier() != null && extension.getUniqueIdentifier().equals(extensionId))
55                 return extensionDelta;
56         }
57         return null;
58     }
59
60     void addExtensionDelta(IExtensionDelta extensionDelta) {
61         this.extensionDeltas.add(extensionDelta);
62         ((ExtensionDelta) extensionDelta).setContainingDelta(this);
63     }
64
65     public String JavaDoc toString() {
66         return "\n\tHost " + ": " + extensionDeltas; //$NON-NLS-1$//$NON-NLS-2$
67
}
68
69     void setObjectManager(IObjectManager objectManager) {
70         this.objectManager = objectManager;
71         //TODO May want to add into the existing one here... if it is possible to have batching
72
}
73
74     public IObjectManager getObjectManager() {
75         return objectManager;
76     }
77 }
78
Popular Tags