Package uk.gov.nationalarchives.droid.container

Examples of uk.gov.nationalarchives.droid.container.ContainerFileIdentificationRequest


     */
    @Override
    public IdentificationResultCollection process(
        final InputStream in, final IdentificationResultCollection containerResults) throws IOException {
       
        final IdentificationRequest request = new ContainerFileIdentificationRequest(null);

        try {
            request.open(in);
           
            int maxBytesToScan = -1;
            ContainerSignatureMatchCollection matches =
                new ContainerSignatureMatchCollection(getContainerIdentifierInit().getContainerSignatures(),
                    getContainerIdentifierInit().getUniqueFileEntries(), maxBytesToScan);
       
            getIdentifierEngine().process(request, matches);
       
            final Map<String, String> puidMap = new HashMap<String, String>();     
            for (ContainerSignatureMatch match : matches.getContainerSignatureMatches()) {
                if (match.isMatch()) {
                    List<FileFormatMapping> mappings = getFormats().get(match.getSignature().getId());
                    for (FileFormatMapping mapping : mappings) {
                        IdentificationResultImpl result = new IdentificationResultImpl();
                        result.setMethod(IdentificationMethod.CONTAINER);
                        result.setRequestMetaData(request.getRequestMetaData());
                        String puid = mapping.getPuid();
                        result.setPuid(mapping.getPuid());
                        if (!puidMap.containsKey(puid)) {
                            puidMap.put(puid, "");
                            containerResults.addResult(result);
                        }
                    }
                }
            }
            request.close();
        } finally {
            if (in != null) {
                in.close();
            }
        }
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.container.ContainerFileIdentificationRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.