Commits

nclarkekb  committed 4db2f1b

Copied message properties from ARC to GZip. Changed and added some reportable properties to GZip Module.

  • Participants
  • Parent commits 53f05a5

Comments (0)

Files changed (6)

File config/messages/gzip_messages.properties

 #   Message templates for class org.jhove2.module.format.gzip.GzipModule
 # ##############################################################################
 #
+org.jhove2.module.format.gzip.GzipModule.duplicate = \
+        Duplicate {0}: ''{1}''
+org.jhove2.module.format.gzip.GzipModule.empty = \
+        Empty {0}
+org.jhove2.module.format.gzip.GzipModule.error_expected = \
+        Empty {0}, expected ''{1}''
+org.jhove2.module.format.gzip.GzipModule.invalid = \
+        Invalid {0}
+org.jhove2.module.format.gzip.GzipModule.invalid_data = \
+        Invalid {0}, ''{1}''
+org.jhove2.module.format.gzip.GzipModule.invalid_encoding = \
+        Invalid encoded {0}, value: ''{1}'', encoding: ''{2}''
+org.jhove2.module.format.gzip.GzipModule.invalid_expected = \
+        Invalid {0}, value: ''{1}'', expected: ''{2}''
+org.jhove2.module.format.gzip.GzipModule.recommended = \
+        Invalid {0}: ''{1}''
+org.jhove2.module.format.gzip.GzipModule.required_invalid = \
+        Invalid {0}: ''{1}''
+org.jhove2.module.format.gzip.GzipModule.reserved = \
+        Invalid {0}: ''{1}''
+org.jhove2.module.format.gzip.GzipModule.undesired_data = \
+        Invalid {0}: ''{1}''
+org.jhove2.module.format.gzip.GzipModule.unknown = \
+        Invalid {0}: ''{1}''
+#
 org.jhove2.module.format.gzip.GzipModule.invalidGzipFile = \
         Invalid GZIP file: fatal error encountered (current offset={0, number, integer}): {1}
 #

File config/spring/module/format/arc/jhove2-arc-config.xml

 	      <ref bean="BnFAgent"/>
 	    </list>
 	</property>
-	<property name="recurse" value="false"/>
+	<property name="recurse" value="true"/>
 	<property name="computeBlockDigest" value="true"/>
 	<property name="blockDigestAlgorithm" value="sha1"/>
 	<property name="blockDigestEncoding" value="base32"/>

File config/spring/module/format/warc/jhove2-warc-config.xml

         <ref bean="BnFAgent"/>
       </list>
     </property>
-    <property name="recurse" value="false"/>
+    <property name="recurse" value="true"/>
     <property name="computeBlockDigest" value="true"/>
     <property name="blockDigestAlgorithm" value="sha1"/>
     <property name="blockDigestEncoding" value="base32"/>

File src/main/java/org/jhove2/module/format/gzip/GzipModule.java

                     ++deflateMemberCount;
                 }
                 // Check member validity.
-                if (! gzipEntry.isValid()) {
+                if (! gzipEntry.isCompliant()) {
                     //this.invalidMembers.incrementAndGet();
                     ++invalidMembers;
                     isValid = Validity.False;

File src/main/java/org/jhove2/module/format/gzip/properties/GzipEntryData.java

 @Persistent
 public class GzipEntryData {
 
+	protected boolean isNonCompliant;
     protected int index;
     protected long offset;
     protected CompressionMethod method;
     }
 
     public GzipEntryData(GzipEntry entry) {
+    	this.isNonCompliant = !entry.isCompliant();
     	this.offset = entry.getStartOffset();
     	this.method = CompressionMethod.fromValue(entry.cm);
     	this.extraFlags = CompressionType.fromValue(entry.xfl);

File src/main/java/org/jhove2/module/format/gzip/properties/GzipEntryProperties.java

     }
 
     /**
+     * Returns whether the entry is compliant or not.
+     * @return whether the entry is compliant or not
+     */
+    @ReportableProperty(order = 1, value = "Is non compliancy.")
+    public boolean getIsNonCompliant() {
+        return entry.isNonCompliant;
+    }
+
+    /**
      * Returns the offset of the beginning of this entry in the GZip
      * file.
      * @return the offset of this entry, as a number of bytes from the
      *         start of the GZip file.
      */
-    @ReportableProperty(order = 1, value = "Offset value.")
+    @ReportableProperty(order = 2, value = "Offset value.")
     public long getOffset() {
         return entry.offset;
     }
      * @return the name of the compressed file or <code>null</code> if
      *         the compressed data did not come from a file.
      */
-    @ReportableProperty(order = 2, value = "GZip entry name.")
+    @ReportableProperty(order = 3, value = "GZip entry name.")
     public String getName() {
         return entry.fileName;
     }
      * Returns the GZip member comment.
      * @return the GZip member comment or <code>null</code> if absent.
      */
-    @ReportableProperty(order = 3, value = "GZip entry comment.")
+    @ReportableProperty(order = 4, value = "GZip entry comment.")
     public String getComment() {
         return entry.comment;
     }
      * @return last modification date of the compressed file or
      *         <code>null</code> if none is present in the GZip header.
      */
-    @ReportableProperty(order = 4, value = "GZip entry date.")
+    @ReportableProperty(order = 5, value = "GZip entry date.")
     public Date getDate() {
         return (entry.date != null)? new Date(entry.date.getTime()): null;
     }
      * Returns the compression method used for this entry.
      * @return the compression method.
      */
-    @ReportableProperty(order = 5, value = "GZip entry compression method.")
+    @ReportableProperty(order = 6, value = "GZip entry compression method.")
     public CompressionMethod getCompressionMethod() {
         return entry.method;
     }
      *
      * @see    #isOperatingSystemValid
      */
-    @ReportableProperty(order = 6, value = "GZip entry operating system.")
+    @ReportableProperty(order = 7, value = "GZip entry operating system.")
     public OperatingSystem getOperatingSystem() {
         return entry.os;
     }
      * @see    #getComputedHeaderCrc
      * @see    #isHeaderCrcValid
      */
-    @ReportableProperty(order = 7, value = "GZip entry header crc16.")
+    @ReportableProperty(order = 8, value = "GZip entry header crc16.")
     public String getCrc16() {
     	String crc16;
     	if (entry.readCrc16 != null) {
      * @see    #getComputedDataCrc
      * @see    #isDataCrcValid
      */
-    @ReportableProperty(order = 8, value = "GZip entry crc32.")
+    @ReportableProperty(order = 9, value = "GZip entry crc32.")
     public String getCrc32() {
         return "0x" + Integer.toHexString(entry.readCrc32);
     }
     }
 
     /**
+     * Returns the ISIZE of the GZip member trailer, i.e. the announced
+     * compressed size of the member data modulo 32.
+     * @return the ISIZE value of the member trailer or
+     *         <code>-1</code> if the member trailer has not yet
+     *         been read.
+     *
+     * @see    #isISizeValid
+     */
+    @ReportableProperty(order = 10, value = "GZip entry extracted size (ISIZE) value.")
+    public long getISize() {
+        return entry.readISize;
+    }
+
+    /**
      * Returns the (computed) uncompressed size of the member data.
      * @return the uncompressed size of the member data or
      *         <code>-1</code> if the member trailer has not yet
      *         been read.
      */
-    @ReportableProperty(order = 9, value = "GZip entry (computed) uncompressed size, in bytes.")
+    @ReportableProperty(order = 11, value = "GZip entry (computed) uncompressed size, in bytes.")
     public long getSize() {
         return entry.size;
     }
      *         <code>-1</code> if the member trailer has not yet
      *         been read.
      */
-    @ReportableProperty(order = 10, value = "GZip entry (computed) compressed size, in bytes.")
+    @ReportableProperty(order = 12, value = "GZip entry (computed) compressed size, in bytes.")
     public long getCompressedSize() {
         return entry.csize;
     }
 
     /**
-     * Returns the ISIZE of the GZip member trailer, i.e. the announced
-     * compressed size of the member data modulo 32.
-     * @return the ISIZE value of the member trailer or
-     *         <code>-1</code> if the member trailer has not yet
-     *         been read.
-     *
-     * @see    #isISizeValid
-     */
-    @ReportableProperty(order = 11, value = "GZip entry extracted size (ISIZE) value.")
-    public long getISize() {
-        return entry.readISize;
-    }
-
-    /**
      * Returns the (computed) ISIZE of the GZip member trailer, i.e.
      * the compressed size of the member data modulo 32.
      * @return the computed ISIZE value of the member data or
         return entry.computedISize;
     }
 
-    @ReportableProperty(order = 12, value = "GZip entry (computed) compression ration.")
-    public String getCompressionRatio() {
-        return Float.toString((float)entry.size / (float)entry.csize);
+    @ReportableProperty(order = 13, value = "GZip entry (computed) compression ratio.")
+    public double getCompressionRatio() {
+        double ratio = -1.0;
+        long size  = entry.size;
+        long csize = entry.csize;
+        if ((size > 0L) && (csize > 0L)) {
+            // Compute compression ratio with 2 decimals only.
+            long l = ((size - csize) * 10000L) / size;
+            ratio = l / 100.00;
+        }
+        return ratio;
     }
 
     /**