Skip to content

Commit

Permalink
REVIEW - Addressing review comments
Browse files Browse the repository at this point in the history
- picked up a few more variable first `var.equals(const)` constructs;
- improved and cleaned up comments in enumerated types;
- tidied a few nested `if else` constructs;
- `BytestreamModule` now uses `ModuleBase.setChecksums()` method; and
- begun to add log statements for ingored exceptions.
  • Loading branch information
carlwilson committed May 23, 2018
1 parent 6d68029 commit cabef18
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 204 deletions.
6 changes: 3 additions & 3 deletions jhove-apps/src/main/java/WDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public static void main (String [] args)
System.out.print (leading (os, 8) + os + ": " + ckID +
" " + ckSize);
long alreadyRead = 0;
if (ckID.equals ("fact")) {
if ("fact".equals (ckID)) {
long sampleLength =
ModuleBase.readUnsignedInt (stream, ENDIAN);
System.out.print (": " + sampleLength);
alreadyRead = 4;
}
else if (ckID.equals ("fmt ")) {
else if ("fmt ".equals (ckID)) {
int formatTag = ModuleBase.readUnsignedShort (stream,
ENDIAN);
int channels = ModuleBase.readUnsignedShort (stream,
Expand Down Expand Up @@ -146,7 +146,7 @@ else if (ckID.equals ("fmt ")) {
}
System.out.println ();

if (ckID.equals ("list") || ckID.equals ("LIST")) {
if ("list".equals (ckID) || "LIST".equals (ckID)) {
readNestedChunks (ckID, stream, ckSize, os + 8);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,10 @@ public double getSampleRate () {
* in _Java in a Nutshell_.
*/
class FaceImpl implements Face {
List<FaceRegion> _regionList;
TimeDesc _startTime;
TimeDesc _duration;
String _direction;
private List<FaceRegion> _regionList;
private TimeDesc _startTime;
private TimeDesc _duration;
private String _direction;


/** Constructor. Initially the duration is set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
* @see Agent
*/
public enum AgentType {
/******************************************************************
* PUBLIC STATIC INSTANCES.
******************************************************************/
/** Commercial organisation **/
COMMERCIAL("Commercial"),
/** Commercial organisation **/
GOVERNMENT("Government"),
/** Educational Institution **/
EDUCATIONAL("Educational"),
/** Not for profit organisation **/
NONPROFIT("Non-profit"),
/** Standardisation body, e.g ANSI, ISO **/
STANDARD("Standards body"),
/** None of the above categories **/
OTHER("Other");

/** A String name for the type, used for reporting. */
public final String name;

/******************************************************************
* CLASS CONSTRUCTOR.
******************************************************************/
private AgentType(final String name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
package edu.harvard.hul.ois.jhove;

/**
* This class defines enumerated types for the analog/digital
* flag of AESAudioMetadata.
* Applications will not create or modify instances of this class, but will
* use one of the predefined AnalogDigitalFlagType instances.
* This class defines enumerated types for the analog/digital
* flag of AESAudioMetadata.
* Applications will not create or modify instances of this class, but will
* use one of the predefined AnalogDigitalFlagType instances.
*
* @author Gary McGath
*
*/
public enum AnalogDigitalFlagType {

/** Enumeration instance for analog data */
ANALOG("ANALOG"),
PHYS_DIGITAL("PHYS_DIGITAL"),
FILE_DIGITAL("FILE_DIGITAL");
/** Enumeration instance for analog data */
ANALOG("ANALOG"),
/** Enumeration instance for physical digital data */
PHYS_DIGITAL("PHYS_DIGITAL"),
/** Enumeration instance for FILE digital data */
FILE_DIGITAL("FILE_DIGITAL");
/** A String value for the type */
public final String value;
/**
* Applications will never create PropertyTypes directly.
**/
private AnalogDigitalFlagType (final String value)
{
this.value = value;
}

private AnalogDigitalFlagType(final String value) {
this.value = value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ public enum ChecksumType {
MD5("MD5"),
/** 160-bit Secure Hash Algorithm. */
SHA1("SHA-1");
/** A String name for the type, used for reporting. */
public final String name;
/**
* Applications will never create ChecksumTypes directly.
**/

private ChecksumType(final String name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,23 @@
*
*/
public enum DocumentType {
/**
* Document type for a printed article.
*/
/** Document type for a printed article. */
ARTICLE("Article"),
/**
* Document type for an book.
*/
/** Document type for an book. */
BOOK("Book"),
/**
* Document type for a report.
*/
/** Document type for a report. */
REPORT("Report"),
/**
* Document type for an IETF Request for Comment.
*/
/** Document type for an IETF Request for Comment. */
RFC("RFC"),
/**
* Document type for a standards body publication.
*/
/** Document type for a standards body publication. */
STANDARD("Standard"),
/**
* Document type for a Web page.
*/
/** Document type for a Web page. */
WEB("Web"),
/**
* Document type that doesn't fit the other categories.
*/
/** Document type that doesn't fit the other categories. */
OTHER("Other");
/** A String name for the type, used for reporting. */
public final String name;

/******************************************************************
* CLASS CONSTRUCTOR.
******************************************************************/

/**
* Applications will never create DocumentTypes directly.
**/
private DocumentType(final String name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,96 +16,52 @@
* @see Identifier
*/
public enum IdentifierType {
/**
* Identifier type for American National Standards Institute.
*/
/** Identifier type for American National Standards Institute. */
ANSI("ANSI"),
/**
* Identifier type for Dewey Decimal Classification.
*/
/** Identifier type for Dewey Decimal Classification. */
DDC("DDC"),
/**
* Identifier type for Digital Object Identifier.
*/
/** Identifier type for Digital Object Identifier. */
DOI("DOI"),
/**
* Identifier type for ECMA.
*/
/** Identifier type for ECMA. */
ECMA("ECMA"),
/**
* Identifier type for CNRI Handle.
*/
/** Identifier type for CNRI Handle. */
HANDLE("Handle"),
/**
* Identifier type for International Standards Organization.
*/
/** Identifier type for International Standards Organization. */
ISO("ISO"),
/**
* Identifier type for International Standard Book Number.
*/
/** Identifier type for International Standard Book Number. */
ISBN("ISBN"),
/**
* Identifier type for Library of Congress classification.
*/
/** Identifier type for Library of Congress classification. */
LC("LC"),
/**
* Identifier type for Library of Congress catalogue number.
*/
/** Identifier type for Library of Congress catalogue number. */
LCCN("LCCN"),
/**
* Identifier type for NISO standard number.
*/
/** Identifier type for NISO standard number. */
NISO("NISO"),
/**
* Identifier type for Publisher Item Identifier.
*/
/** Identifier type for Publisher Item Identifier. */
PII("PII"),
/**
* Identifier type for IETF Request for Comment.
*/
/** Identifier type for IETF Request for Comment. */
RFC("RFC"),
/**
* Identifier type for Serial Item and Contribution Identifier.
*/
/** Identifier type for Serial Item and Contribution Identifier. */
SICI("SICI"),
/**
* Identifier type for Uniform Resource Identifier.
*/
/** Identifier type for Uniform Resource Identifier. */
URI("URI"),
/**
* Identifier type for Uniform Resource Locator.
*/
/** Identifier type for Uniform Resource Locator. */
URL("URL"),
/**
* Identifier type for Uniform Resource Name.
*/
/** Identifier type for Uniform Resource Name. */
URN("URN"),
/**
* Identifier type for CCITT.
*/
/** Identifier type for CCITT. */
CCITT("CCITT"),
/**
* Identifier type for International Telecommunication Union.
*/
/** Identifier type for International Telecommunication Union. */
ITU("ITU"),
/**
* Identifier type for Japan Electronics and Information Technology
* Industries Association.
*/
JEITA("JEITA"),
/**
* Identifier type for whatever doesn't fit other categories.
*/
/** Identifier type for whatever doesn't fit other categories. */
OTHER("Other");
/** A String name for the type, used for reporting. */
public final String name;

/******************************************************************
* CLASS CONSTRUCTOR.
******************************************************************/

/**
* Applications will never create SignatureTypes directly.
**/
private IdentifierType(final String name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ protected void calcRAChecksum (Checksummer ckSummer, RandomAccessFile raf)
* @param ckSummer Checksummer object
* @param info RepInfo object
*/
protected void setChecksums (Checksummer ckSummer, RepInfo info)
protected static void setChecksums (Checksummer ckSummer, RepInfo info)
{
if (ckSummer != null){
info.setChecksum (new Checksum (ckSummer.getCRC32 (),
Expand Down Expand Up @@ -1466,6 +1466,8 @@ protected Property[] vectorToPropArray (Vector vec)
}

protected void setupDataStream(final InputStream stream, final RepInfo info) {
/* Are checksums requested and ensure they're not already calculated
* when handling a temp file. */
if (_je.getChecksumFlag() &&
info.getChecksum().isEmpty()) {
_ckSummer = new Checksummer ();
Expand Down
26 changes: 9 additions & 17 deletions jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,21 @@ private void init (String name, PropertyType type, PropertyArity arity,
if (value == null) {
throw new NullPointerException (CoreMessageConstants.EXC_PROP_VAL_NULL);
}
if (arity == PropertyArity.SCALAR) {
if (value instanceof List ||
value instanceof Map ||
value instanceof Set) {
if ((arity == PropertyArity.SCALAR) && !isObjScalarProp(value)) {
throw new IncompatibleClassChangeError
(CoreMessageConstants.EXC_SCL_PROP_CLSS_INCMPT);
}
}
else if (arity == PropertyArity.MAP) {
if (!(value instanceof Map)) {
else if ((arity == PropertyArity.MAP) && (!(value instanceof Map))) {
throw new IncompatibleClassChangeError
(CoreMessageConstants.EXC_MAP_PROP_CLSS_INCMPT);
}

}
else if (arity == PropertyArity.SET) {
if (!(value instanceof Set)) {
else if ((arity == PropertyArity.SET) && (!(value instanceof Set))) {
throw new IncompatibleClassChangeError
(CoreMessageConstants.EXC_SET_PROP_CLSS_INCMPT);
}

}
else if (arity == PropertyArity.LIST) {
if (!(value instanceof List)) {
else if ((arity == PropertyArity.LIST) && (!(value instanceof List))) {
throw new IncompatibleClassChangeError
(CoreMessageConstants.EXC_LIST_PROP_CLSS_INCMPT);
}

}

_name = name;
Expand All @@ -115,6 +102,11 @@ else if (arity == PropertyArity.LIST) {
_value = value;
}

private static boolean isObjScalarProp(Object toTest) {
return !(toTest instanceof List ||
toTest instanceof Map ||
toTest instanceof Set);
}
/******************************************************************
* PUBLIC INSTANCE METHODS.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ public enum PropertyArity {
* An Arity corresponding to java.util.Set or any of its derived classes.
*/
SET("Set");
/** A String name for the Arity, used for reporting. */
public final String name;

/**
* Applications will never create PropertyArities directly.
**/
private PropertyArity(final String name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,9 @@ public enum PropertyType {
*/
RATIONAL("Rational");

/******************************************************************
* CLASS CONSTRUCTOR.
******************************************************************/
/** A String name for the type, used for reporting. */
public final String name;

/**
* Applications will never create PropertyTypes directly.
**/
private PropertyType(final String name) {
this.name = name;
}
Expand Down
Loading

0 comments on commit cabef18

Please sign in to comment.