org.eclipse.core.resources/src/org/eclipse/core/resources/mapping/ResourceMapping.java
Parent Directory
|
Revision Log
Revision 1.22 -
(download)
(annotate)
Tue Jan 31 21:31:23 2006 UTC (3 years, 9 months ago) by johna
Branch: MAIN
CVS Tags: e4merge_v20090907-1000, v20080324-1725, v20060925, v20080508, v20080509, v20090505, v20090504, v20070514, R34x_v20080902, R34x_v20080709, v20060802, R35x_v20090821-0505, R3_3_1_1, v20070202, v20060808, v20061127, v20080604-1400, v20070306, v20060227, v20080430-0005, R3_2_1, R3_2_2, v20091109, v20080922, v20091102, v20080528-1613, e4merge_v20090923, v20090820, v20090629, v20080205, v20060601a, pre_e4work_merge, v20090512, v20091103-0745, v20090213, v20080128, v20070604, v20061030, v20090119, v20071001, v20090112, v20071008, v20070330, v20060306, v20060411, v20090817, v20060731, R35x_v20091105-0835, v20060717, v20060710, v20090203, v20080407, v20091013-0600, v20090209, v20061023, v20071015, v20090320, v20060328, v20060327, v20090123, R3_4, R3_5, R3_2, R3_3, v20080908, v20080714, v20070123, v20081117, v20070510, v20080310, v20071026, v20080317, v20070316, v20061016, R32x_v20060914, v20081010, v20090223, pre_R3_3, v20070430, v20090316-0910, v20070806, v20091019, v20090429-1800, R34x_v20081113, v20070924, R32x_v20061218, v20060512, v20090428, v20060626, v20081201, v20090425, v20090727a, v20071119, R34x_v20080826, v20070129, v20080303, R33x_v20080205, v20090306, v20061006, v20070115, R35x_v20090826-0451, v20060220, v20070717, R3_5_1, v20061120, v20090413, v20060603, R34x_v20090112, v20071207, v20081103, v20071204, v20070529, v20090316, v20081006, v20071126, v20060619, v20070723, v20070426, R35x_v20090925-1200, v20060511, v20060510, R32x_v20060710, R32x_v20060711, v20091022-0835, R32x_v20090122, v20090302, v20060612, R34x_v20090126, v20090911, v20071210, v20060821, v20060313, I20081022-0500, v20080520, v20070730, v20071112, v20070530, v20070226, v20061218, v20070423, v20060209, R3_3_1, R3_3_2, v20061106, I20060605-1430, v20060206, R34x_v20091113-0430, v20070916, v20080825, R3_4_2, R3_4_1, v20070709, v20090925, v20060426, v20090921, v20080224, v20060317, v20081020, R32x_v20061207, v20070219, v20091005-1055, v20080326, v20081026, v20091026-1217, v20090720, v20080201, R35x_v20091117, v20061113, v20060214, v20070820, v20060213, v20061204, HEAD
Branch point for: R3_3_maintenance, R3_4_1_maintenance_patches, v20090820_e4merge, R3_2_maintenance, R3_4_maintenance, R3_5_maintenance
Changes since 1.21: +3 -6 lines
Tue Jan 31 21:31:23 2006 UTC (3 years, 9 months ago) by johna
Branch: MAIN
CVS Tags: e4merge_v20090907-1000, v20080324-1725, v20060925, v20080508, v20080509, v20090505, v20090504, v20070514, R34x_v20080902, R34x_v20080709, v20060802, R35x_v20090821-0505, R3_3_1_1, v20070202, v20060808, v20061127, v20080604-1400, v20070306, v20060227, v20080430-0005, R3_2_1, R3_2_2, v20091109, v20080922, v20091102, v20080528-1613, e4merge_v20090923, v20090820, v20090629, v20080205, v20060601a, pre_e4work_merge, v20090512, v20091103-0745, v20090213, v20080128, v20070604, v20061030, v20090119, v20071001, v20090112, v20071008, v20070330, v20060306, v20060411, v20090817, v20060731, R35x_v20091105-0835, v20060717, v20060710, v20090203, v20080407, v20091013-0600, v20090209, v20061023, v20071015, v20090320, v20060328, v20060327, v20090123, R3_4, R3_5, R3_2, R3_3, v20080908, v20080714, v20070123, v20081117, v20070510, v20080310, v20071026, v20080317, v20070316, v20061016, R32x_v20060914, v20081010, v20090223, pre_R3_3, v20070430, v20090316-0910, v20070806, v20091019, v20090429-1800, R34x_v20081113, v20070924, R32x_v20061218, v20060512, v20090428, v20060626, v20081201, v20090425, v20090727a, v20071119, R34x_v20080826, v20070129, v20080303, R33x_v20080205, v20090306, v20061006, v20070115, R35x_v20090826-0451, v20060220, v20070717, R3_5_1, v20061120, v20090413, v20060603, R34x_v20090112, v20071207, v20081103, v20071204, v20070529, v20090316, v20081006, v20071126, v20060619, v20070723, v20070426, R35x_v20090925-1200, v20060511, v20060510, R32x_v20060710, R32x_v20060711, v20091022-0835, R32x_v20090122, v20090302, v20060612, R34x_v20090126, v20090911, v20071210, v20060821, v20060313, I20081022-0500, v20080520, v20070730, v20071112, v20070530, v20070226, v20061218, v20070423, v20060209, R3_3_1, R3_3_2, v20061106, I20060605-1430, v20060206, R34x_v20091113-0430, v20070916, v20080825, R3_4_2, R3_4_1, v20070709, v20090925, v20060426, v20090921, v20080224, v20060317, v20081020, R32x_v20061207, v20070219, v20091005-1055, v20080326, v20081026, v20091026-1217, v20090720, v20080201, R35x_v20091117, v20061113, v20060214, v20070820, v20060213, v20061204, HEAD
Branch point for: R3_3_maintenance, R3_4_1_maintenance_patches, v20090820_e4merge, R3_2_maintenance, R3_4_maintenance, R3_5_maintenance
Changes since 1.21: +3 -6 lines
Bug 115858 [Model API] ResourceMapping#getModelProviderId() should be abstract
/******************************************************************************* * Copyright (c) 2004, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.core.resources.mapping; import java.util.ArrayList; import org.eclipse.core.internal.resources.mapping.ModelProviderManager; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; /** * A resource mapping supports the transformation of an application model * object into its underlying file system resources. It provides the * bridge between a logical element and the physical resource(s) into which it * is stored but does not provide more comprehensive model access or * manipulations. * <p> * Mappings provide two means of model traversal. The {@link #accept} method * can be used to visit the resources that constitute the model object. Alternatively, * a set or traversals can be obtained by calling {@link #getTraversals}. A traversal * contains a set of resources and a depth. This allows clients (such a repository providers) * to do optimal traversals of the resources w.r.t. the operation that is being performed * on the model object. * </p> * <p> * This class may be subclassed by clients. * </p> * @see IResource * @see ResourceTraversal * @since 3.2 */ public abstract class ResourceMapping extends PlatformObject { /** * Accepts the given visitor for all existing resources in this mapping. * The visitor's {@link IResourceVisitor#visit} method is called for each * accessible resource in this mapping. * * @param context the traversal context * @param visitor the visitor * @param monitor a progress monitor, or <code>null</code> if progress * reporting is not desired * @exception CoreException if this method fails. Reasons include: * <ul> * <li> The visitor failed with this exception.</li> * <li> The traversals for this mapping could not be obtained.</li> * </ul> */ public void accept(ResourceMappingContext context, IResourceVisitor visitor, IProgressMonitor monitor) throws CoreException { ResourceTraversal[] traversals = getTraversals(context, monitor); for (int i = 0; i < traversals.length; i++) traversals[i].accept(visitor); } /** * Return whether this resource mapping contains all the resources * of the given mapping. * <p> * This method always returns <code>false</code> when the given resource * mapping's model provider id does not match that the of the receiver. * </p> * * @param mapping the given resource mapping * @return <code>true</code> if this mapping contains all the resources * of the given mapping, and <code>false</code> otherwise. */ public boolean contains(ResourceMapping mapping) { return false; } /** * Override equals to compare the model objects of the * mapping in order to determine equality. * @param obj the object to compare * @return <code>true</code> if the receiver is equal to the * given object, and <code>false</code> otherwise. */ public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof ResourceMapping) { ResourceMapping other = (ResourceMapping) obj; return other.getModelObject().equals(getModelObject()); } return false; } /** * Returns all markers of the specified type on the resources in this mapping. * If <code>includeSubtypes</code> is <code>false</code>, only markers * whose type exactly matches the given type are returned. Returns an empty * array if there are no matching markers. * * @param type the type of marker to consider, or <code>null</code> to indicate all types * @param includeSubtypes whether or not to consider sub-types of the given type * @param monitor a progress monitor, or <code>null</code> if progress * reporting is not desired * @return an array of markers * @exception CoreException if this method fails. */ public IMarker[] findMarkers(String type, boolean includeSubtypes, IProgressMonitor monitor) throws CoreException { final ResourceTraversal[] traversals = getTraversals(ResourceMappingContext.LOCAL_CONTEXT, monitor); ArrayList result = new ArrayList(); for (int i = 0; i < traversals.length; i++) traversals[i].doFindMarkers(result, type, includeSubtypes); return (IMarker[]) result.toArray(new IMarker[result.size()]); } /** * Returns the application model element associated with this * resource mapping. * * @return the application model element associated with this * resource mapping. */ public abstract Object getModelObject(); /** * Return the model provider for the model object * of this resource mapping. The model provider is obtained * using the id returned from <code>getModelProviderId()</code>. * @return the model provider */ public final ModelProvider getModelProvider() { try { return ModelProviderManager.getDefault().getModelProvider(getModelProviderId()); } catch (CoreException e) { throw new IllegalStateException(e.getMessage()); } } /** * Returns the id of the model provider that generated this resource * mapping. * * @return the model provider id */ public abstract String getModelProviderId(); /** * Returns the projects that contain the resources that constitute this * application model. * * @return the projects */ public abstract IProject[] getProjects(); /** * Returns one or more traversals that can be used to access all the * physical resources that constitute the logical resource. A traversal is * simply a set of resources and the depth to which they are to be * traversed. This method returns an array of traversals in order to provide * flexibility in describing the traversals that constitute a model element. * <p> * Subclasses should, when possible, include * all resources that are or may be members of the model element. * For instance, a model element should return the same list of * resources regardless of the existence of the files on the file system. * For example, if a logical resource called "form" maps to "/p1/form.xml" * and "/p1/form.java" then whether form.xml or form.java existed, they * should be returned by this method. *</p><p> * In some cases, it may not be possible for a model element to know all the * resources that may constitute the element without accessing the state of * the model element in another location (e.g. a repository). This method is * provided with a context which, when provided, gives access to * the members of corresponding remote containers and the contents of * corresponding remote files. This gives the model element the opportunity * to deduce what additional resources should be included in the traversal. * </p> * * @param context gives access to the state of * remote resources that correspond to local resources for the * purpose of determining traversals that adequately cover the * model element resources given the state of the model element * in another location. This parameter may be <code>null</code>, in * which case the implementor can assume that only the local * resources are of interest to the client. * @param monitor a progress monitor, or <code>null</code> if progress * reporting is not desired * @return a set of traversals that cover the resources that constitute the * model element * @exception CoreException if the traversals could not be obtained. */ public abstract ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException; /** * Override hashCode to use the model object. */ public int hashCode() { return getModelObject().hashCode(); } }
| help@eclipse.org | ViewVC Help |
| Powered by ViewVC 1.0.3 |
