org.eclipse.emf.ecore.resource.impl
Class ResourceSetImpl.MappedResourceLocator

java.lang.Object
  extended by org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.ResourceLocator
      extended by org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.MappedResourceLocator
Enclosing class:
ResourceSetImpl

public static class ResourceSetImpl.MappedResourceLocator
extends ResourceSetImpl.ResourceLocator

An implementation of a ResourceSetImpl.ResourceLocator that maintains cached mappings for the normalized URIs and the resource set's resources.

Since:
2.8

Nested Class Summary
 class ResourceSetImpl.MappedResourceLocator.ResourceAdapter
          A content adapter that listens to the resource set for resources being added and removed, as well as to the resources in the resource set for changes to the resource's URI.
 
Field Summary
protected  URIConverter cachedURIConverter
          The cached URI converter used to calculate the cached normalization and resource mappings.
protected  int expectedModificationCount
          The cached modification count of the cached URI converter.
protected  java.util.Map<URI,URI> normalizationMap
          The cached mappings from URIs to their normalized form.
protected  java.util.Map<URI,EList<Resource>> resourceMap
          The cached mapping from normalized URIs to their corresponding resources.
 
Fields inherited from class org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.ResourceLocator
resourceSet
 
Constructor Summary
ResourceSetImpl.MappedResourceLocator(ResourceSetImpl resourceSet)
          Creates an instance of the given resource set.
 
Method Summary
protected  void buildMaps()
          Builds entries for the resource set's resource in the normalized map and the resource map.
protected  boolean cacheURIConverter()
          Caches the URI converter, checking that it's the same as the ResourceLocator#resourceSet's current URI converter and that the modification count of the URI map is the same as the expected modification count, building normalization and resource maps, if necessary.
 Resource getResource(URI uri, boolean loadOnDemand)
          The utility method used by a resource set for locating a resource.
protected  void map(URI normalizedURI, Resource resource)
          Creates a resource map entry for the resource with the given normalized URI.
protected  int modificationCount()
          Determines modification count of the cached URI converter.
 
Methods inherited from class org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.ResourceLocator
delegatedGetResource, demandCreateResource, demandLoad, demandLoadHelper, handleDemandLoadException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cachedURIConverter

protected URIConverter cachedURIConverter
The cached URI converter used to calculate the cached normalization and resource mappings.


expectedModificationCount

protected int expectedModificationCount
The cached modification count of the cached URI converter.


normalizationMap

protected java.util.Map<URI,URI> normalizationMap
The cached mappings from URIs to their normalized form.


resourceMap

protected java.util.Map<URI,EList<Resource>> resourceMap
The cached mapping from normalized URIs to their corresponding resources. If there is more than one resource corresponding to the a normalized URI, the value will be a list of all those resources and they will be ordered in the same order as they appear in the resource set with any resources not in the resource set, i.e., those located by delegation, appearing after those found in the resource set itself.

Constructor Detail

ResourceSetImpl.MappedResourceLocator

public ResourceSetImpl.MappedResourceLocator(ResourceSetImpl resourceSet)
Creates an instance of the given resource set.

Method Detail

map

protected void map(URI normalizedURI,
                   Resource resource)
Creates a resource map entry for the resource with the given normalized URI.


buildMaps

protected void buildMaps()
Builds entries for the resource set's resource in the normalized map and the resource map.


modificationCount

protected int modificationCount()
Determines modification count of the cached URI converter.


cacheURIConverter

protected boolean cacheURIConverter()
Caches the URI converter, checking that it's the same as the ResourceLocator#resourceSet's current URI converter and that the modification count of the URI map is the same as the expected modification count, building normalization and resource maps, if necessary.


getResource

public Resource getResource(URI uri,
                            boolean loadOnDemand)
Description copied from class: ResourceSetImpl.ResourceLocator
The utility method used by a resource set for locating a resource. It must implement the full logic needed to locate a resource, including delegated lookup and demand creation.

Specified by:
getResource in class ResourceSetImpl.ResourceLocator

Copyright 2001-2012 IBM Corporation and others.
All Rights Reserved.