1 11 package org.eclipse.pde.internal.core; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.pde.internal.core.ifeature.IFeatureModel; 16 17 public class FeatureModelDelta implements IFeatureModelDelta { 18 private ArrayList fAdded; 19 20 private ArrayList fRemoved; 21 22 private ArrayList fChanged; 23 24 private int kind = 0; 25 26 public FeatureModelDelta() { 27 } 28 29 34 public int getKind() { 35 return kind; 36 } 37 38 43 public IFeatureModel[] getAdded() { 44 return get(fAdded); 45 } 46 47 52 public IFeatureModel[] getRemoved() { 53 return get(fRemoved); 54 } 55 56 61 public IFeatureModel[] getChanged() { 62 return get(fChanged); 63 } 64 65 private IFeatureModel[] get(ArrayList list) { 66 if (list == null) 67 return new IFeatureModel[0]; 68 return (IFeatureModel[]) list.toArray(new IFeatureModel[list.size()]); 69 } 70 71 void add(IFeatureModel model, int type) { 72 switch (type) { 73 case ADDED: 74 fAdded = add(fAdded, model); 75 break; 76 case REMOVED: 77 fRemoved = add(fRemoved, model); 78 break; 79 case CHANGED: 80 fChanged = add(fChanged, model); 81 break; 82 } 83 kind |= type; 84 } 85 86 private ArrayList add(ArrayList list, IFeatureModel model) { 87 if (list == null) 88 list = new ArrayList (); 89 list.add(model); 90 return list; 91 } 92 93 boolean contains(IFeatureModel model, int type) { 94 if ((type & ADDED) != 0 && fAdded != null && fAdded.contains(model)) { 95 return true; 96 } 97 if ((type & REMOVED) != 0 && fRemoved != null 98 && fRemoved.contains(model)) { 99 return true; 100 } 101 if ((type & CHANGED) != 0 && fChanged != null 102 && fChanged.contains(model)) { 103 return true; 104 } 105 return false; 106 } 107 } 108 | Popular Tags |