gov.nasa.pds.registry.common.meta.CollectionMetadataExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of registry-common Show documentation
Show all versions of registry-common Show documentation
Common code used by Harvest and Registry Manager.
package gov.nasa.pds.registry.common.meta;
import java.util.Set;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import gov.nasa.pds.registry.common.util.xml.XPathUtils;
/**
* Extracts collection metadata
* @author karpenko
*/
public class CollectionMetadataExtractor
{
private XPathExpression xFileName;
/**
* Constructor
* @throws Exception an exception
*/
public CollectionMetadataExtractor() throws Exception
{
XPathFactory xpf = XPathFactory.newInstance();
xFileName = XPathUtils.compileXPath(xpf, "//File_Area_Inventory/File/file_name");
}
/**
* Extract collection inventory file names
* @param doc Parsed collection label (XML DOM)
* @return a set of files (usually there is only one inventory file)
* @throws Exception an exception
*/
public Set extractInventoryFileNames(Document doc) throws Exception
{
return XPathUtils.getStringSet(doc, xFileName);
}
}