KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > PluginModelDelta


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.pde.internal.core;
12
13 import java.util.ArrayList JavaDoc;
14
15 import org.eclipse.pde.core.plugin.ModelEntry;
16
17 public class PluginModelDelta {
18     public static final int ADDED = 1;
19     public static final int REMOVED = 2;
20     public static final int CHANGED = 4;
21
22     private ArrayList JavaDoc added;
23     private ArrayList JavaDoc removed;
24     private ArrayList JavaDoc changed;
25
26     private int kind = 0;
27
28     public PluginModelDelta() {
29     }
30
31     public int getKind() {
32         return kind;
33     }
34     public ModelEntry[] getAddedEntries() {
35         return getEntries(added);
36     }
37     public ModelEntry[] getRemovedEntries() {
38         return getEntries(removed);
39     }
40     public ModelEntry[] getChangedEntries() {
41         return getEntries(changed);
42     }
43     private ModelEntry[] getEntries(ArrayList JavaDoc list) {
44         if (list == null)
45             return new ModelEntry[0];
46         return (ModelEntry[]) list.toArray(new ModelEntry[list.size()]);
47     }
48
49     void addEntry(ModelEntry entry, int type) {
50         switch (type) {
51             case ADDED :
52                 added = addEntry(added, entry);
53                 break;
54             case REMOVED :
55                 removed = addEntry(removed, entry);
56                 break;
57             case CHANGED :
58                 changed = addEntry(changed, entry);
59                 break;
60         }
61         kind |= type;
62     }
63     private ArrayList JavaDoc addEntry(ArrayList JavaDoc list, ModelEntry entry) {
64         if (list == null)
65             list = new ArrayList JavaDoc();
66         list.add(entry);
67         return list;
68     }
69 }
70
Popular Tags