org.openprovenance.prov.service.core.ExtendedDocumentResourceIndexFactory Maven / Gradle / Ivy
package org.openprovenance.prov.service.core;
import org.openprovenance.prov.storage.api.DocumentResource;
import org.openprovenance.prov.storage.api.Instantiable;
import org.openprovenance.prov.storage.api.ResourceIndex;
public class ExtendedDocumentResourceIndexFactory implements ResourceIndex {
private final ResourceIndex eri;
private final Instantiable factory;
protected final ResourceIndex dri;
public ExtendedDocumentResourceIndexFactory(ResourceIndex dri, Instantiable factory) {
this.dri=dri;
this.eri =(ResourceIndex)dri; //TODO: is this right?
this.factory=factory;
}
public EXTENDED_RESOURCE newResource(DocumentResource dr) {
final EXTENDED_RESOURCE extended_resource = factory.newResource(dr);
return extended_resource;
}
@Override
public EXTENDED_RESOURCE get(String key) {
return eri.get(key);
}
@Override
public void put(String key, EXTENDED_RESOURCE dr) {
eri.put(key,dr);
}
@Override
public void remove(String key) {
eri.remove(key);
}
@Override
public String newId() {
return eri.newId();
}
@Override
public EXTENDED_RESOURCE newResource() {
return factory.newResource();
}
@Override
public ResourceIndex.StorageKind kind() {
return eri.kind();
}
@Override
public ResourceIndex getAncestor() {
return dri;
}
/**
* Returns a thread safe instance.
*/
@Override
public ResourceIndex getIndex() {
return null;
}
@Override
public void close() {
}
/*
@Override
public ExtendedDocumentResourceIndexFactory getExtender(Instantiable factory2) {
return new ExtendedDocumentResourceIndexFactory(dri,factory2);
}
*/
}