-
Notifications
You must be signed in to change notification settings - Fork 78
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
Conversation
carlwilson
commented
Oct 3, 2016
•
edited
Loading
edited
- created class for PDF MessageConstants; and
- factoring out all String constants.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
- 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
5b34c7b
to
b638a56
Compare
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? |
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 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 ;)
- 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; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.