1 11 package org.eclipse.core.resources.mapping; 12 13 import java.util.ArrayList ; 14 import org.eclipse.core.internal.resources.mapping.ModelProviderManager; 15 import org.eclipse.core.resources.*; 16 import org.eclipse.core.runtime.*; 17 18 40 public abstract class ResourceMapping extends PlatformObject { 41 42 57 public void accept(ResourceMappingContext context, IResourceVisitor visitor, IProgressMonitor monitor) throws CoreException { 58 ResourceTraversal[] traversals = getTraversals(context, monitor); 59 for (int i = 0; i < traversals.length; i++) 60 traversals[i].accept(visitor); 61 } 62 63 75 public boolean contains(ResourceMapping mapping) { 76 return false; 77 } 78 79 86 public boolean equals(Object obj) { 87 if (obj == this) 88 return true; 89 if (obj instanceof ResourceMapping) { 90 ResourceMapping other = (ResourceMapping) obj; 91 return other.getModelObject().equals(getModelObject()); 92 } 93 return false; 94 } 95 96 109 public IMarker[] findMarkers(String type, boolean includeSubtypes, IProgressMonitor monitor) throws CoreException { 110 final ResourceTraversal[] traversals = getTraversals(ResourceMappingContext.LOCAL_CONTEXT, monitor); 111 ArrayList result = new ArrayList (); 112 for (int i = 0; i < traversals.length; i++) 113 traversals[i].doFindMarkers(result, type, includeSubtypes); 114 return (IMarker[]) result.toArray(new IMarker[result.size()]); 115 } 116 117 124 public abstract Object getModelObject(); 125 126 132 public final ModelProvider getModelProvider() { 133 try { 134 return ModelProviderManager.getDefault().getModelProvider(getModelProviderId()); 135 } catch (CoreException e) { 136 throw new IllegalStateException (e.getMessage()); 137 } 138 } 139 140 146 public abstract String getModelProviderId(); 147 148 154 public abstract IProject[] getProjects(); 155 156 193 public abstract ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException; 194 195 198 public int hashCode() { 199 return getModelObject().hashCode(); 200 } 201 } 202 | Popular Tags |