1 11 package org.eclipse.core.internal.propertytester; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.core.resources.mapping.ResourceMapping; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.QualifiedName; 17 18 23 public class ResourceMappingPropertyTester extends ResourcePropertyTester { 24 public boolean test(Object receiver, String method, Object [] args, Object expectedValue) { 25 if (!(receiver instanceof ResourceMapping)) 26 return false; 27 if (!method.equals(PROJECT_PERSISTENT_PROPERTY)) 28 return false; 29 IProject[] projects = ((ResourceMapping) receiver).getProjects(); 32 if (projects.length == 0) 33 return false; 34 String propertyName; 35 String expectedVal; 36 if (args.length == 0) { 37 propertyName = toString(expectedValue); 38 expectedVal = null; } else if (args.length == 1) { 40 propertyName = toString(args[0]); 41 expectedVal = null; } else { 43 propertyName = toString(args[0]); 44 expectedVal = toString(args[1]); 45 } 46 QualifiedName key = toQualifedName(propertyName); 47 boolean found = false; 48 for (int i = 0; i < projects.length; i++) { 49 try { 50 Object actualVal = projects[i].getPersistentProperty(key); 51 if (actualVal == null) 53 continue; 54 found = true; 56 if (expectedVal == null) 58 continue; 59 if (!expectedVal.equals(actualVal.toString())) 61 return false; 62 } catch (CoreException e) { 63 } 65 } 66 return found; 68 } 69 } 70 | Popular Tags |