Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT - Use real enums and parent class members #351

Merged
merged 4 commits into from
May 23, 2018

Conversation

carlwilson
Copy link
Member

@carlwilson carlwilson commented May 21, 2018

  • moved repeatedly used _ckSummer, _cstream, and _dstream members to ModuleBase;
  • tidied ModuleBase parameter handling;
  • added a common method to set up module checksumming streams ModuleBase.setupDataStream();
  • BytestreamModule uses ModuleBase.setupDataStream();
  • replaced all types that extended EnumerationType with real Java enum types:
    • AgentType,
    • AnalogDigitalFlagType,
    • ChecksumType,
    • DocumentType,
    • IdentifierType,
    • PropertyArity,
    • PropertyType,
    • SignatureType,
    • SignatureUseType, and
  • removed now defunct EnumerationType.

Closes #373

- moved repeatedly used `_ckSummer`, `_cstream`, and `_dstream` members to `ModuleBase`;
- tidied `ModuleBase` parameter handling;
- added a common method to set up module checksumming streams `ModuleBase.setupDataStream()`;
- `BytestreamModule` uses `ModuleBase.setupDataStream()`;
- replaced all types that extended `EnumerationType` with real Java `enum` types:
  - `AgentType`,
  - `AnalogDigitalFlagType`,
  - `ChecksumType`,
  - `DocumentType,`
  - `IdentifierType`,
  - `PropertyArity`,
  - `PropertyType`,
  - 'SignatureType',
  - `SignatureUseType`, and
- removed now defunct `EnumerationType`.
@carlwilson carlwilson self-assigned this May 21, 2018
@carlwilson carlwilson requested a review from david-russo May 21, 2018 19:19
@codecov
Copy link

codecov bot commented May 21, 2018

Codecov Report

Merging #351 into integration will increase coverage by 0.03%.
The diff coverage is 73.64%.

Impacted file tree graph

@@                Coverage Diff                @@
##             integration     #351      +/-   ##
=================================================
+ Coverage          45.21%   45.25%   +0.03%     
- Complexity          3452     3457       +5     
=================================================
  Files                367      366       -1     
  Lines              30151    30162      +11     
  Branches            5952     5944       -8     
=================================================
+ Hits               13633    13649      +16     
+ Misses             14073    14067       -6     
- Partials            2445     2446       +1
Impacted Files Coverage Δ Complexity Δ
...va/edu/harvard/hul/ois/jhove/AESAudioMetadata.java 86.48% <ø> (ø) 36 <0> (ø) ⬇️
...arvard/hul/ois/jhove/module/pdf/PageLabelNode.java 35.37% <ø> (-0.44%) 13 <0> (ø)
.../main/java/edu/harvard/hul/ois/jhove/Property.java 41.93% <0%> (-1.15%) 15 <1> (+1)
...u/harvard/hul/ois/jhove/AnalogDigitalFlagType.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...edu/harvard/hul/ois/jhove/handler/TextHandler.java 0.54% <0%> (ø) 2 <0> (ø) ⬇️
...n/java/edu/harvard/hul/ois/jhove/ChecksumType.java 100% <100%> (ø) 3 <3> (+1) ⬆️
.../java/edu/harvard/hul/ois/jhove/PropertyArity.java 100% <100%> (ø) 3 <3> (+1) ⬆️
...main/java/edu/harvard/hul/ois/jhove/AgentType.java 100% <100%> (ø) 3 <3> (+1) ⬆️
...java/edu/harvard/hul/ois/jhove/IdentifierType.java 100% <100%> (ø) 3 <3> (+1) ⬆️
...n/java/edu/harvard/hul/ois/jhove/DocumentType.java 100% <100%> (ø) 3 <3> (+1) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd155c2...cabef18. Read the comment docs.

Copy link
Member

@david-russo david-russo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good stuff :)

* CLASS CONSTRUCTOR.
******************************************************************/
/**
* Applications will never create SignatureTypes directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect *Type referenced in comment. An old copy-paste error, though we probably don't need any of these comments anymore anyway since all enum constructors must be private. I'd do away with the large "CLASS CONSTRUCTOR"-style sign-boards as well, at least for simple enums.

_dstream = getBufferedDataStream (stream, _je != null ?
_je.getBufferSize () : 0);
}
setupDataStream(stream, info);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment preceding this call explains code now hidden inside setupDataStream, so it would make more sense there instead.

@@ -129,14 +109,14 @@ public final int parse (InputStream stream, RepInfo info, int parseIndex)
if (_nByte == 0) {
info.setMessage (new InfoMessage (CoreMessageConstants.INF_FILE_EMPTY));
}
if (ckSummer != null) {
info.setChecksum (new Checksum (ckSummer.getCRC32 (),
if (_ckSummer != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to suggest moving this checksum-related code to ModuleBase as well, but apparently there's already a setChecksums method there which you could replace this with. Might want to keep an eye out in other modules as well.

Copy link
Member Author

@carlwilson carlwilson May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the trail of a few Module similarities. The calculation of checksums is one, the proffering and checking of sigs is another. All of these were supposed to be abstract class tasks but cut and paste has prevailed.

- 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.
@carlwilson carlwilson merged commit a79dc0b into integration May 23, 2018
@carlwilson carlwilson deleted the refact/module-base branch May 23, 2018 18:46
@carlwilson carlwilson added the bug A product defect that needs fixing label Dec 13, 2018
@carlwilson carlwilson added this to the v1.22-m3 Reviewed milestone Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A product defect that needs fixing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants