/** * @since 2.4 */ @Override protected void doClear() { super.doClear(); // don't iterate the values of the map per resource but just clear it all at once getURIResourceMap().clear(); }
/** * @since 2.3 */ protected void registerURI(Resource resource) { Map<URI, Resource> map = getURIResourceMap(); if (map != null) { final URI uri = resource.getURI(); if (uri != null) { URI normalized = getURIConverter().normalize(uri); if (!normalized.equals(uri)) { Resource previous = map.put(normalized, resource); if (previous != null && previous != resource) { throw new IllegalStateException("A resource with the normalized URI '"+normalized+"' was already registered. The resource with the URI '"+previous+"' is no longer registered with the normalized form."); } } } Resource previous = map.put(uri, resource); if (previous != null && previous != resource) { throw new IllegalStateException("A different resource with the URI '"+uri+"' was already registered."); } } } /**
@Override public void notifyChanged(Notification notification) { final Map<URI, Resource> map = getURIResourceMap(); if (map != null && notification.getFeatureID(Resource.class) == Resource.RESOURCE__URI && notification.getNotifier() instanceof Resource) { URI oldOne = (URI) notification.getOldValue(); map.remove(oldOne); if (oldOne != null) { URI oldNormalized = getURIConverter().normalize(oldOne); if (!oldOne.equals(oldNormalized)) map.remove(oldNormalized); } Resource resource = (Resource) notification.getNotifier(); registerURI(resource); } super.notifyChanged(notification); } }
@Override public Resource getResource(URI uri, boolean loadOnDemand) { Map<URI, Resource> map = getURIResourceMap(); if (map == null) return super.getResource(uri, loadOnDemand);