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