Package uk.gov.nationalarchives.droid

Examples of uk.gov.nationalarchives.droid.FileFormatHit


            out.write("\n");
        }
        else {
          //now create an FileFormatHit element for each hit
          for (int hitCounter = 0; hitCounter < idFile.getNumHits(); hitCounter++) {
              FileFormatHit formatHit = idFile.getHit(hitCounter);
              out.write("    <FileFormatHit>");
              out.write("\n");
              out.write("      <Status>" + formatHit.getHitTypeVerbose() + "</Status>");
              out.write("\n");
              out.write("      <Name>" + formatHit.getFileFormatName().replaceAll("&", "&amp;") + "</Name>");
              out.write("\n");
              if (formatHit.getFileFormatVersion() != null) {
                  out.write("      <Version>" + formatHit.getFileFormatVersion().replaceAll("&", "&amp;") + "</Version>");
                  out.write("\n");
              }
              if (formatHit.getFileFormatPUID() != null) {
                  out.write("      <PUID>" + formatHit.getFileFormatPUID().replaceAll("&", "&amp;") + "</PUID>");
                  out.write("\n");
              }
              if (formatHit.getMimeType() != null) {
                  out.write("      <MimeType>" + formatHit.getMimeType().replaceAll("&", "&amp;") + "</MimeType>");
                  out.write("\n");
              }
              if (!"".equals(formatHit.getHitWarning())) {
                  out.write("      <IdentificationWarning>"
                          + formatHit.getHitWarning().replaceAll("&", "&amp;") + "</IdentificationWarning>");
                  out.write("\n");
              }
              out.write("    </FileFormatHit>");
              out.write("\n");
          }//end file hit FOR       
View Full Code Here


        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;
        }
        /*
         * there was no specific hit, maybe
         */
        if (found == null)
            return null;
       
        FormatInfo info = new FormatInfo();
        info.setName(found.getFileFormatName());
        info.setPuid(found.getFileFormatPUID());
        info.setVersion(found.getFileFormatVersion());
        info.setMimeType(found.getMimeType());
        /*
         * choose first file extension as default
         */
        if (found.getFileFormat().getNumExtensions() > 0)
            info.setDefaultExtension(found.getFileFormat().getExtension(0));

        return info;
    }
View Full Code Here

        return result;
    }

    private void addHits(IdentificationFile ident, List<FormatHit> allHits) {
        for (int i = 0; i < ident.getNumHits(); i++) {
            FileFormatHit ffHit = ident.getHit(i);
            FormatHit hit = new FormatHit();
           
            hit.setHitWarning(ffHit.getHitWarning());
            hit.setSpecific(ffHit.isSpecific());
           
           
            hit.getFormat().setName(ffHit.getFileFormatName());
            hit.getFormat().setPuid(ffHit.getFileFormatPUID());
            hit.getFormat().setVersion(ffHit.getFileFormatVersion());
            hit.getFormat().setMimeType(ffHit.getMimeType());
            /*
             * choose first file extension as default
             */
            if (ffHit.getFileFormat().getNumExtensions() > 0)
                hit.getFormat().setDefaultExtension(ffHit.getFileFormat().getExtension(0));
           
            allHits.add(hit);
        }
    }
View Full Code Here

            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);
View Full Code Here

TOP

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

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.