Skip to content

Commit

Permalink
Merge pull request #351 from openpreserve/refact/module-base
Browse files Browse the repository at this point in the history
MAINT - Use real enums and parent class members
  • Loading branch information
carlwilson authored May 23, 2018
2 parents bd155c2 + cabef18 commit a79dc0b
Show file tree
Hide file tree
Showing 17 changed files with 415 additions and 630 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
74 changes: 27 additions & 47 deletions jhove-core/src/main/java/edu/harvard/hul/ois/jhove/AgentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,36 @@

package edu.harvard.hul.ois.jhove;


/**
* This class defines enumerated types for an Agent.
* Applications will not create or modify AgentTypes, but will
* use one of the predefined AgentType instances COMMERCIAL, GOVERNMENT,
* EDUCATIONAL, NONPROFIT, STANDARD, or OTHER.
* This class defines enumerated types for an Agent.
* Applications will not create or modify AgentTypes, but will
* use one of the predefined AgentType instances COMMERCIAL, GOVERNMENT,
* EDUCATIONAL, NONPROFIT, STANDARD, or OTHER.
*
* @see Agent
* @see Agent
*/
public final class AgentType
extends EnumerationType
{
/******************************************************************
* PUBLIC STATIC INSTANCES.
******************************************************************/

/**
* Agent type for a commercial entity.
*/
public static final AgentType COMMERCIAL = new AgentType ("Commercial");
/**
* Agent type for a governmental body.
*/
public static final AgentType GOVERNMENT = new AgentType ("Government");
/**
* Agent type for an educational institution.
*/
public static final AgentType EDUCATIONAL = new AgentType ("Educational");
/**
* Agent type for a non-profit organization.
*/
public static final AgentType NONPROFIT = new AgentType ("Non-profit");
/**
* Agent type for a standards body.
*/
public static final AgentType STANDARD = new AgentType ("Standards body");
/**
* Agent type that doesn't fit the other categories.
*/
public static final AgentType OTHER = new AgentType ("Other");
public enum AgentType {
/** 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;
}

/**
* Applications will never create AgentTypes directly.
**/
private AgentType (String value)
{
super (value);
}
@Override
public String toString() {
return this.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +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 class AnalogDigitalFlagType extends EnumerationType {
public enum AnalogDigitalFlagType {

/** Enumeration instance for analog data */
public static final AnalogDigitalFlagType ANALOG =
new AnalogDigitalFlagType ("ANALOG");
/** 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;

/** Enumeration instance for physical digital data */
public static final AnalogDigitalFlagType PHYS_DIGITAL =
new AnalogDigitalFlagType ("PHYS_DIGITAL");

/** Enumeration instance for FILE digital data */
public static final AnalogDigitalFlagType FILE_DIGITAL =
new AnalogDigitalFlagType ("FILE_DIGITAL");

/**
* Applications will never create PropertyTypes directly.
**/
private AnalogDigitalFlagType (String value)
{
super (value);
}
private AnalogDigitalFlagType(final String value) {
this.value = value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,31 @@

package edu.harvard.hul.ois.jhove;


/**
* This class defines enumerated types for a Checksum on a content
* stream or file.
* Applications will not create or modify ChecksumTypes, but will
* use one of the predefined ChecksumType instances
* CRC32, MD5, or SHA1.
* This class defines enumerated types for a Checksum on a content
* stream or file.
* Applications will not create or modify ChecksumTypes, but will
* use one of the predefined ChecksumType instances
* CRC32, MD5, or SHA1.
*
* @see Checksum
* @see Checksum
*/
public final class ChecksumType
extends EnumerationType
{
/** 32-bit Cyclical Redundancy Checksum. */
public static final ChecksumType CRC32 = new ChecksumType ("CRC32");

/** 128-bit Message Digest 5. */
public static final ChecksumType MD5 = new ChecksumType ("MD5");
public enum ChecksumType {
/** 32-bit Cyclical Redundancy Checksum. */
CRC32("CRC32"),
/** 128-bit Message Digest 5. */
MD5("MD5"),
/** 160-bit Secure Hash Algorithm. */
SHA1("SHA-1");
/** A String name for the type, used for reporting. */
public final String name;

/** 160-bit Secure Hash Algorithm. */
public static final ChecksumType SHA1 = new ChecksumType ("SHA-1");
private ChecksumType(final String name) {
this.name = name;
}

/**
* Applications will never create ChecksumTypes directly.
**/
private ChecksumType (String value)
{
super (value);
}
@Override
public String toString() {
return this.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,39 @@

package edu.harvard.hul.ois.jhove;


/**
* This class defines enumerated types for a Document.
* Applications will not create or modify DocumentTypes, but will
* use one of the predefined DocumentType instances
* ARTICLE, BOOK, REPORT, RFC, STANDARD, WEB, or OTHER.
* This class defines enumerated types for a Document.
* Applications will not create or modify DocumentTypes, but will
* use one of the predefined DocumentType instances
* ARTICLE, BOOK, REPORT, RFC, STANDARD, WEB, or OTHER.
*
* @see Document
*
* @see Document
*
*/
public final class DocumentType
extends EnumerationType
{
/**
* Document type for a printed article.
*/
public static final DocumentType ARTICLE = new DocumentType ("Article");
/**
* Document type for an book.
*/
public static final DocumentType BOOK = new DocumentType ("Book");
/**
* Document type for a report.
*/
public static final DocumentType REPORT = new DocumentType ("Report");
/**
* Document type for an IETF Request for Comment.
*/
public static final DocumentType RFC = new DocumentType ("RFC");
/**
* Document type for a standards body publication.
*/
public static final DocumentType STANDARD = new DocumentType ("Standard");
/**
* Document type for a Web page.
*/
public static final DocumentType WEB = new DocumentType ("Web");
/**
* Document type that doesn't fit the other categories.
*/
public static final DocumentType OTHER = new DocumentType ("Other");
public enum DocumentType {
/** Document type for a printed article. */
ARTICLE("Article"),
/** Document type for an book. */
BOOK("Book"),
/** Document type for a report. */
REPORT("Report"),
/** Document type for an IETF Request for Comment. */
RFC("RFC"),
/** Document type for a standards body publication. */
STANDARD("Standard"),
/** Document type for a Web page. */
WEB("Web"),
/** 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.
******************************************************************/
private DocumentType(final String name) {
this.name = name;
}

/**
* Applications will never create DocumentTypes directly.
**/
private DocumentType (String value)
{
super (value);
}
@Override
public String toString() {
return this.name;
}
}

This file was deleted.

Loading

0 comments on commit a79dc0b

Please sign in to comment.