Package uk.gov.nationalarchives.droid

Examples of uk.gov.nationalarchives.droid.IdentificationFile


      throw new FitsToolException("Error initilizing DROID",e);
    }
  }

  public ToolOutput extractInfo(File file) throws FitsToolException {
    IdentificationFile idFile = droid.identify(file.getPath());
    /*List<FileIdentity> identities = new ArrayList();
    for(int i=0;i<idFile.getNumHits();i++) {
      FileFormatHit hit = idFile.getHit(i);
      FileIdentity identity = new FileIdentity(hit.getMimeType(),hit.getFileFormatName(),hit.getFileFormatVersion());
      //pronom id;
View Full Code Here


     * @param data
     * @return {@link FormatInfo}
     * @throws Exception
     */
    public FormatInfo getMostAppropriateFormat(String filename, byte[] data) throws Exception {
        IdentificationFile ident = identify(filename, data);
        if (ident == null)
            return null;
        if (ident.getNumHits() == 0)
            return null;
        FileFormatHit hit;
        FileFormatHit found = null;

        for (int i = 0; i < ident.getNumHits(); i++) {
            hit = ident.getHit(i);
            log.debug("Hit nr: " + i + " = " + hit.getFileFormatName() + " ," + hit.getFileFormatVersion() + ", hint: " + hit.getHitWarning());
            if ((hit.isSpecific() && found == null))
                found = hit;
        }
        /*
 
View Full Code Here

        return getMostAppropriateFormat(filename, data);
    }
   
    public FormatIdentification identify(String filepath) {
       
        IdentificationFile ident = droid.identify(filepath);
       
        FormatIdentification result = handelDROIDOutput(ident);
       
        return result;
    }
View Full Code Here

    /**
     * @see FormatIdentificationService#identifyFormat(byte[], String)
     */
    public FormatIdentification identifyFormat(byte[] data, String filename)throws Exception {
       
        IdentificationFile ident = identify(filename, data);
       
        FormatIdentification result = handelDROIDOutput(ident);
       
        return result;
    }
View Full Code Here

        controller.runFileFormatAnalysis();
        Iterator<IdentificationFile> iterator = controller.getFileCollection()
                .getIterator();
        // We identify one file only:
        if (iterator.hasNext()) {
            IdentificationFile file = iterator.next();
            waitFor(file);
            URI[] uris = new URI[file.getNumHits()];
            log.info("Looking at results: #" + file.getNumHits());
            // Retrieve the results:
            try {
                for (int hitCounter = 0; hitCounter < file.getNumHits(); hitCounter++) {
                    FileFormatHit formatHit = file.getHit(hitCounter);
                    uris[hitCounter] = new URI("info:pronom/"
                            + formatHit.getFileFormatPUID());
                }
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
            List<URI> result = Arrays.asList(uris);
            this.classificationText = file.getClassificationText();
            return result;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.IdentificationFile

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.