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

EXPERIMENTAL - Factor out PDF module string constants #120

Merged
merged 14 commits into from
Oct 30, 2017

Conversation

carlwilson
Copy link
Member

@carlwilson carlwilson commented Oct 3, 2016

  • created class for PDF MessageConstants; and
    • factoring out all String constants.

@codecov-io
Copy link

codecov-io commented Oct 3, 2016

Codecov Report

Merging #120 into integration will decrease coverage by 0.05%.
The diff coverage is 40.18%.

Impacted file tree graph

@@                Coverage Diff                @@
##             integration     #120      +/-   ##
=================================================
- Coverage          43.02%   42.97%   -0.06%     
  Complexity          3425     3425              
=================================================
  Files                394      398       +4     
  Lines              31679    31659      -20     
  Branches            6176     6174       -2     
=================================================
- Hits               13631    13604      -27     
- Misses             15614    15621       +7     
  Partials            2434     2434
Impacted Files Coverage Δ Complexity Δ
...va/edu/harvard/hul/ois/jhove/module/PdfModule.java 70.15% <ø> (-0.15%) 278 <0> (ø)
...a/edu/harvard/hul/ois/jhove/module/pdf/Stream.java 71.01% <ø> (ø) 17 <0> (ø) ⬇️
...harvard/hul/ois/jhove/module/pdf/ObjectStream.java 71.11% <ø> (ø) 6 <0> (ø) ⬇️
...rd/hul/ois/jhove/module/pdf/FileSpecification.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...rd/hul/ois/jhove/module/wave/MessageConstants.java 0% <0%> (ø) 0 <0> (?)
...arvard/hul/ois/jhove/module/pdf/StructureTree.java 53.48% <0%> (-1.06%) 10 <0> (ø)
.../edu/harvard/hul/ois/jhove/module/pdf/DocNode.java 63.15% <0%> (-1.85%) 10 <0> (ø)
...rd/hul/ois/jhove/module/aiff/MessageConstants.java 0% <0%> (ø) 0 <0> (?)
...u/harvard/hul/ois/jhove/module/pdf/PageObject.java 53.52% <0%> (-2.48%) 13 <0> (ø)
...ard/hul/ois/jhove/module/pdf/MessageConstants.java 0% <0%> (ø) 0 <0> (?)
... and 17 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 f0e9222...9cef192. Read the comment docs.

 - created class for PDF MessageConstants;
 - factoring out all String message constants to MessageConstants; and
 - started, but not finished, factoring out dict keys and property names.

sqash
@david-russo
Copy link
Member

david-russo commented Oct 6, 2016

I like how out you've factored them, but at the same time I feel they could be even further out. Like resource-file out. If we had them in such a file, it might also be useful as a source for generating the online documentation... and other language translations... the methods for working with which could all be generalised under jhove-core for the benefit of all modules... but I'm getting waaay ahead of this pull request...

Regarding which, we might want to make a note to change the message constant names for their equivalent IDs once they've been created, to avoid them possibly falling out of sync with their underlying messages.

Anyway, nice work, certainly an improvement :) I see no immediate problems with this, besides having to update the line numbers in the wiki again... Maybe leave this until after the hack day?

@carlwilson carlwilson added this to the JHOVE hack day activities milestone Oct 10, 2016
@carlwilson carlwilson added the feature New functionality to be developed label Oct 10, 2016
@carlwilson carlwilson changed the title EXPERIMENTAL - Factor out string constants EXPERIMENTAL - Factor out PDF module string constants Oct 10, 2016
template based on pdf example
Needed to comment out some of the var defs, (L46, 47, 62, 76) due to poor JAVA skillz.
This will need some pruning...
@@ -0,0 +1,160 @@
/**
Copy link

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yvonne caught another, I'm on it ;)

carlwilson and others added 7 commits October 11, 2016 17:38
- only PDF messages used in code as we have some test files; and
- checked Black Box testing by breaking a message.
…nstants

- bumped PDF Module version number;
- finally merged old message constants for PDF module; and
- tracked down some missed strings and properties in `PdfModule` class;
- string repetition in `PdfModule`; and
- Eclipse artifacts into .gitignore.

private static final String DICT_KEY_FONT_DESCRIPTOR = "FontDescriptor";
private static final String DICT_KEY_STARTXREF = "startxref";
private static final String DICT_KEY_BASE_FONT = base + font;
Copy link
Member

Choose a reason for hiding this comment

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

This code would be easier to read as a literal "BaseFont", cutting out the time it takes to confirm the contents of the variables, and allowing the key to be searched. They're also variables that are unlikely to need changing in the future, so I see little benefit in having them as variables. I think the same can be said for most of the variables declared on lines 116 to 121, with the exception of crop_box.

public static final String EXT = ".pdf";

private static final String font = "Font";
private static final String crop_box = "CropBox";
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps PROP_VAL_CROP_BOX to match the others?

private static final String PDF_SIG_HEADER = "%" + PDF_VER1_HEADER_PREFIX;
private static final String POSTSCRIPT_HEADER_PREFIX = "!PS-Adobe-";
private static final String ENCODING_PREFIX = "ENC=";
private static final String NO_HEADER = "No PDF header";
Copy link
Member

Choose a reason for hiding this comment

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

Consistent space indentation to match the rest/majority of the file.

@@ -55,6 +55,9 @@
'\u00f8','\u00f9','\u00fa','\u00fb','\u00fc','\u00fd','\u00fe','\u00ff'
};

private static final String empty = "";
private static final String stream = "stream";
Copy link
Member

Choose a reason for hiding this comment

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

EMPTY, STREAM?

- minor changes and tweaks.
@carlwilson carlwilson merged commit fc4ed1b into integration Oct 30, 2017
@carlwilson carlwilson deleted the exp-message-constants branch October 30, 2017 18:51
rgfeldman added a commit to rgfeldman/jhove that referenced this pull request Apr 10, 2019
rgfeldman added a commit to rgfeldman/jhove that referenced this pull request Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality to be developed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants