1 11 12 package org.eclipse.osgi.internal.baseadaptor; 13 14 import java.io.IOException ; 15 import java.util.HashMap ; 16 import java.util.Iterator ; 17 import org.eclipse.osgi.framework.adaptor.PermissionStorage; 18 19 public class BasePermissionStorage implements PermissionStorage { 20 21 private HashMap locations = new HashMap (); 22 private String [] defaultInfos; 23 private String [] condPermInfos; 24 private BaseStorage storage; 25 private boolean dirty; 26 27 BasePermissionStorage(BaseStorage storage) { 28 this.storage = storage; 29 } 30 31 public String [] getLocations() throws IOException { 32 synchronized (locations) { 33 String [] result = new String [locations.size()]; 34 int i = 0; 35 for (Iterator iLocs = locations.keySet().iterator(); iLocs.hasNext(); i++) 36 result[i] = (String ) iLocs.next(); 37 return result; 38 } 39 } 40 41 public String [] getPermissionData(String location) throws IOException { 42 if (location == null) 43 return defaultInfos; 44 synchronized (locations) { 45 if (locations.size() == 0) 46 return null; 47 return (String []) locations.get(location); 48 } 49 } 50 51 public void setPermissionData(String location, String [] data) throws IOException { 52 if (location == null) { 53 defaultInfos = data; 54 return; 55 } 56 synchronized (locations) { 57 if (data == null) 58 locations.remove(location); 59 else 60 locations.put(location, data); 61 } 62 setDirty(true); 63 storage.requestSave(); 64 } 65 66 public void saveConditionalPermissionInfos(String [] infos) throws IOException { 67 condPermInfos = infos; 68 setDirty(true); 69 storage.requestSave(); 70 } 71 72 public String [] getConditionalPermissionInfos() throws IOException { 73 return condPermInfos; 74 } 75 76 public boolean isDirty() { 77 return dirty; 78 } 79 80 public void setDirty(boolean dirty) { 81 this.dirty = dirty; 82 } 83 } 84 | Popular Tags |