Package uk.gov.nationalarchives.droid.core.signature

Examples of uk.gov.nationalarchives.droid.core.signature.FileFormat


        // Build a set of format ids the results have priority over:
        FileFormatCollection allFormats = sigFile.getFileFormatCollection();
        Set<Integer> lowerPriorityIDs = new HashSet<Integer>();
        for (IdentificationResult result : results.getResults()) {
            final String resultPUID = result.getPuid();
            final FileFormat format = allFormats.getFormatForPUID(resultPUID);
            lowerPriorityIDs.addAll(format.getFormatIdsHasPriorityOver());
        }
       
        // If a result has an id in this set, add it to the remove list;
        List<IdentificationResult> lowerPriorityResults = new ArrayList<IdentificationResult>();
        for (IdentificationResult result : results.getResults()) {
            final String resultPUID = result.getPuid();
            final FileFormat format = allFormats.getFormatForPUID(resultPUID);
            if (lowerPriorityIDs.contains(format.getID())) {
                lowerPriorityResults.add(result);
            }
        }
        
        // Now remove any lower priority results from the collection:
View Full Code Here


            IdentificationResultCollection results, String fileExtension) {
        if (fileExtension == null || fileExtension.isEmpty()) {
            FileFormatCollection allFormats = sigFile.getFileFormatCollection();
            for (IdentificationResult result : results.getResults()) {
                final String resultPUID = result.getPuid();
                final FileFormat format = allFormats.getFormatForPUID(resultPUID);
                if (format.getNumExtensions() > 0) {
                    results.setExtensionMismatch(true);
                    break;
                }
            }
        } else {
            FileFormatCollection allFormats = sigFile.getFileFormatCollection();
            for (IdentificationResult result : results.getResults()) {
                final String resultPUID = result.getPuid();
                final FileFormat format = allFormats.getFormatForPUID(resultPUID);
                if (format.hasExtensionMismatch(fileExtension)) {
                    results.setExtensionMismatch(true);
                    break;
                }
            }
        }
View Full Code Here

       
        Set<String> puidsWithSignatures = new HashSet<String>();
       
        for (InternalSignature sig : signatures) {
            for (int i = 0; i < sig.getNumFileFormats(); i++) {
                FileFormat format = sig.getFileFormat(i);
                puidsWithSignatures.add(format.getPUID());
            }
        }
       
        assertEquals(193, puidsWithSignatures.size());
       
View Full Code Here

    private String getFileFormatPUIDs() {
        StringBuffer formats = new StringBuffer();
        final int endOfFileFormats = fileFormatList.size();
        for (int fileFormatIndex = 0;
              fileFormatIndex < endOfFileFormats; fileFormatIndex++) {
            final FileFormat format = fileFormatList.get(fileFormatIndex);
            if (fileFormatIndex > 0) {
                formats.append(SPACE);
            }
            formats.append(format.getPUID());
        }
        return formats.toString();
    }
View Full Code Here

    private String getFileFormatNames() {
        StringBuffer formats = new StringBuffer();
        final int endOfFileFormats = fileFormatList.size();
        for (int fileFormatIndex = 0;
              fileFormatIndex < endOfFileFormats; fileFormatIndex++) {
            final FileFormat format = fileFormatList.get(fileFormatIndex);
            if (fileFormatIndex > 0) {
                formats.append(SPACE);
            }
            formats.append(format.getName());
        }
        return formats.toString();
    }
View Full Code Here

     * signature attached to them.
     *
     * @param puid The puid.
     */
    public final void puidHasOverridingSignatures(String puid) {
        FileFormat format = getFileFormat(puid);
        if (format != null) {
            // 1. remove all the internal signature ids from the file format:
            List<Integer> removedSignatureIDs = format.clearSignatures();

            // 2. For each signature removed from the file format,
            //    also remove the file format from the signature:
            for (Integer id : removedSignatureIDs) {
                InternalSignature signature = intSigs.getInternalSignature(id);
                if (signature != null) {
                    signature.removeFileFormat(format);
                    // 3. If the signature no longer points at any
                    //    file formats, remove the signature entirely:
                    if (signature.getNumFileFormats() == 0) {
                        intSigs.removeInternalSignature(signature);
                    }
                }
            }

            // 4. The file format no longer has any internal signatures.
            //    It is possible that it never had any, and was a
            //    tentative format.  We can't tell at this point,
            //    as this method may have been called before.
            //    However, it is definitely not a tentative format now,
            //    as it has an overriding signature (probably a container
            //    signature at the time of writing for DROID 6).
            //    Therefore, remove it from the tentative extensions lists,
            //    if it ever existed there. 
            for (String extension : format.getExtensions()) {
                List<FileFormat> tentativeFormatsForExtension = tentativeFormats.get(extension);
                if (tentativeFormatsForExtension != null) {
                    tentativeFormatsForExtension.remove(format);
                    // 5.  If there are no more file formats defined
                    //     for this extension, remove the entry entirely
View Full Code Here

   
    // Builds a mapped list of file formats with no binary signatures, indexed against their file extensions.
    private void buildFileExtensions() {
        final int numFileFormats = this.getNumFileFormats();
        for (int iFormat = 0; iFormat < numFileFormats; iFormat++) {
            final FileFormat theFormat = this.getFileFormat(iFormat);
            if (theFormat.getNumInternalSignatures() == 0) {
                addTentativeFormat(theFormat);
            }
            addExtensions(theFormat);
        }
    }
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.core.signature.FileFormat

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.