org.dspace.xoai.services.impl.AbstractMetadataSearcher Maven / Gradle / Ivy
The newest version!
/*
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.xoai.services.impl;
import org.dspace.xoai.model.xoai.Element;
import org.dspace.xoai.model.xoai.XOAIMetadata;
import org.dspace.xoai.services.api.MetadataSearch;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public abstract class AbstractMetadataSearcher implements MetadataSearch {
protected static final String DEFAULT_FIELD = "value";
protected Map> index = new HashMap>();
public AbstractMetadataSearcher (XOAIMetadata metadata) {
for (Element element : metadata.getElements()) {
consume(new ArrayList(), element);
}
}
@Override
public T findOne(String xoaiPath){
List elements = index.get(xoaiPath);
if (elements != null && !elements.isEmpty())
return elements.get(0);
return null;
};
@Override
public List findAll(String xoaiPath){
return index.get(xoaiPath);
};
@Override
public Map> index() {
return index;
}
protected void init(XOAIMetadata metadata) {
for (Element element : metadata.getElements()) {
consume(new ArrayList(), element);
}
}
protected abstract void consume(List newNames, Element element);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy