From cc23eda24deb1f3656fd56bf48bf3c14e1f18e6c Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 09:00:10 +0200 Subject: [PATCH 01/10] add default to switch in Jhove Apps RepTreeRoot --- .../hul/ois/jhove/viewer/RepTreeRoot.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/RepTreeRoot.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/RepTreeRoot.java index 254167838..203541e0a 100644 --- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/RepTreeRoot.java +++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/RepTreeRoot.java @@ -33,7 +33,7 @@ public class RepTreeRoot extends DefaultMutableTreeNode * Constructor. * @param info The RepInfo object whose contents are to * be displayed. - * @param app The App object under which we're operating. + * @param base The JhoveBase object under which we're operating. */ public RepTreeRoot (RepInfo info, JhoveBase base) { @@ -52,6 +52,8 @@ public RepTreeRoot (RepInfo info, JhoveBase base) /** * Constructs a DefaultMutableTreeNode representing a property + * @param pProp: the property + * @return: the DefaultMutableTreeNode representing a property */ private DefaultMutableTreeNode propToNode (Property pProp) { @@ -129,13 +131,16 @@ private DefaultMutableTreeNode propToNode (Property pProp) /** * Find the index of an object in its parent. * Understands the Jhove property structure. + * @param parent: the parent object + * @param child: the child object of which we want the index + * @return the index of the child object in its parent */ public int getIndexOfChild (Object parent, Object child) { Property pProp = (Property) parent; PropertyArity arity = pProp.getArity (); // For Lists, Maps, and Sets we construct an Iterator. - Iterator iter = null; + Iterator iter; if (arity == PropertyArity.SET || arity == PropertyArity.LIST || arity == PropertyArity.MAP) { @@ -175,7 +180,7 @@ else if (iter.next () == child) { Property[] propArray = null; Rational[] rationalArray = null; Object[] objArray = null; - int n = 0; + int n; if (null == propType) { return 0; // non-object array type @@ -298,12 +303,14 @@ private void snarfRepInfo () if (_info.getWellFormed () == RepInfo.TRUE) { switch (_info.getValid ()) { case RepInfo.TRUE: - wfStr += " and valid"; - break; + wfStr += " and valid"; + break; case RepInfo.FALSE: - wfStr += ", but not valid"; - break; + wfStr += ", but not valid"; + break; + default: wfStr += ""; + break; // case UNDETERMINED: add nothing } @@ -935,9 +942,8 @@ private DefaultMutableTreeNode nisoToNode (NisoImageMetadata niso) DefaultMutableTreeNode nod = (new DefaultMutableTreeNode ("YCbCrCoefficients", true)); val.add (nod); - for (int i = 0; i < rarray.length; i++) { - nod.add (new DefaultMutableTreeNode - (rarray[i].toString (), false)); + for (Rational rarray1 : rarray) { + nod.add(new DefaultMutableTreeNode(rarray1.toString(), false)); } } rarray = niso.getReferenceBlackWhite (); @@ -945,9 +951,8 @@ private DefaultMutableTreeNode nisoToNode (NisoImageMetadata niso) DefaultMutableTreeNode nod = (new DefaultMutableTreeNode ("ReferenceBlackWhite", true)); val.add (nod); - for (int i = 0; i < rarray.length; i++) { - nod.add (new DefaultMutableTreeNode - (rarray[i].toString (), false)); + for (Rational rarray1 : rarray) { + nod.add(new DefaultMutableTreeNode(rarray1.toString(), false)); } } if ((n = niso.getSegmentType ()) != NisoImageMetadata.NULL) { From d6468079f720e6cd4042c932f7a4c1df4cc6f6f1 Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 09:15:49 +0200 Subject: [PATCH 02/10] add default switch statement in Jhove Core TextHandler.java --- .../hul/ois/jhove/handler/TextHandler.java | 334 ++++++++++-------- 1 file changed, 177 insertions(+), 157 deletions(-) diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/handler/TextHandler.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/handler/TextHandler.java index befee2931..3ad770403 100644 --- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/handler/TextHandler.java +++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/handler/TextHandler.java @@ -91,6 +91,7 @@ public void show () * Outputs detailed information about the application, * including configuration, available modules and handlers, * etc. + * @param app: the app that's used */ @Override public void show (App app) @@ -144,6 +145,7 @@ public void show (App app) /** * Outputs information about the OutputHandler specified * in the parameter + * @param handler: the OutputHandler of which information is demanded */ @Override public void show (OutputHandler handler) @@ -202,7 +204,7 @@ public void show (Module module) _writer.print (margin + " MIMEtype: " + ss[0]); for (int i=1; i Date: Tue, 22 Oct 2019 09:29:08 +0200 Subject: [PATCH 03/10] add default switch statement to mcgath png package of external modules --- .../mcgath/jhove/module/png/BkgdChunk.java | 19 +++++++++++++------ .../mcgath/jhove/module/png/ZtxtChunk.java | 7 ++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/jhove-ext-modules/src/main/java/com/mcgath/jhove/module/png/BkgdChunk.java b/jhove-ext-modules/src/main/java/com/mcgath/jhove/module/png/BkgdChunk.java index e30084dd7..e2a6c463e 100644 --- a/jhove-ext-modules/src/main/java/com/mcgath/jhove/module/png/BkgdChunk.java +++ b/jhove-ext-modules/src/main/java/com/mcgath/jhove/module/png/BkgdChunk.java @@ -8,7 +8,10 @@ /** The bKGD (background color) chunk */ public class BkgdChunk extends PNGChunk { - /** Constructor */ + /** Constructor + * @param sig: the chunktype + * @param leng: the length + */ public BkgdChunk(int sig, long leng) { chunkType = sig; length = leng; @@ -22,6 +25,8 @@ public BkgdChunk(int sig, long leng) { * The greyscale, RGB, and palette backgrounds are all * different kinds of data, so make them three different * properties so that processing software doesn't get confused. + * @param info: RepInfo object + * @throws Exception */ @Override public void processChunk(RepInfo info) throws Exception { @@ -42,6 +47,8 @@ public void processChunk(RepInfo info) throws Exception { case 3: minLength = 1; break; + default: + break; } if (_module.isIdatSeen()) { msg = new ErrorMessage (MessageConstants.PNG_GDM_1); @@ -56,7 +63,7 @@ else if (length < minLength) { int grayBkgd = readUnsignedShort(); Property grayProp = new Property ("Gray background value", PropertyType.INTEGER, - Integer.valueOf(grayBkgd)); + grayBkgd); info.setProperty (grayProp); break; case 2: @@ -66,22 +73,22 @@ else if (length < minLength) { int blueBkgd = readUnsignedShort(); Property redProp = new Property ("Red background value", PropertyType.INTEGER, - Integer.valueOf(redBkgd)); + redBkgd); info.setProperty (redProp); Property greenProp = new Property ("Green background value", PropertyType.INTEGER, - Integer.valueOf(greenBkgd)); + greenBkgd); info.setProperty (greenProp); Property blueProp = new Property ("Blue background value", PropertyType.INTEGER, - Integer.valueOf(blueBkgd)); + blueBkgd); info.setProperty (blueProp); break; case 3: int bkgdIndex = readUnsignedByte(); Property bkgdProp = new Property ("Background palette index", PropertyType.INTEGER, - Integer.valueOf(bkgdIndex)); + bkgdIndex); info.setProperty (bkgdProp); break; } diff --git a/jhove-ext-modules/src/main/java/com/mcgath/jhove/module/png/ZtxtChunk.java b/jhove-ext-modules/src/main/java/com/mcgath/jhove/module/png/ZtxtChunk.java index 0005e93f0..08a5644ea 100644 --- a/jhove-ext-modules/src/main/java/com/mcgath/jhove/module/png/ZtxtChunk.java +++ b/jhove-ext-modules/src/main/java/com/mcgath/jhove/module/png/ZtxtChunk.java @@ -8,7 +8,10 @@ /** Representation of the zTXt (compressed text) chunk */ public class ZtxtChunk extends GeneralTextChunk { - /** Constructor */ + /** Constructor + * @param sig: int representing chunktype + * @param leng: long representing length + */ public ZtxtChunk(int sig, long leng) { chunkType = sig; length = leng; @@ -59,6 +62,8 @@ public void processChunk(RepInfo info) throws Exception { case 2: compressedData[cmprsIdx++] = (byte) c; break; + default: + break; } } if (keyword != null) { From c0cacafd16eadd8f60c94e01654bd3e10d2f0628 Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 13:28:10 +0200 Subject: [PATCH 04/10] add default switch statement to WarcRecordData of external Warc Module --- .../ois/jhove/module/warc/WarcRecordData.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/WarcRecordData.java b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/WarcRecordData.java index 9a22827ca..ecc9989a1 100644 --- a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/WarcRecordData.java +++ b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/WarcRecordData.java @@ -140,8 +140,8 @@ public WarcRecordData(WarcRecord record) { throw new IllegalArgumentException(MessageConstants.ERR_RECORD_DATA_NULL); } WarcHeader header = record.header; - startOffset = Long.valueOf(record.getStartOffset()); - consumed = Long.valueOf(record.getConsumed()); + startOffset = record.getStartOffset(); + consumed = record.getConsumed(); if (header.bValidVersionFormat) { this.warcVersionStr = header.versionStr; } @@ -257,13 +257,13 @@ public WarcRecordData(WarcRecord record) { /* * Compliance. */ - bIsNonCompliant = Boolean.valueOf(!record.isCompliant()); + bIsNonCompliant = !record.isCompliant(); isValidBlockDigest = record.isValidBlockDigest; isValidPayloadDigest = record.isValidPayloadDigest; /* * Payload. */ - bHasPayload = Boolean.valueOf(record.hasPayload()); + bHasPayload = record.hasPayload(); Payload payload = record.getPayload(); HeaderLine headerLine; if (payload != null) { @@ -276,24 +276,26 @@ public WarcRecordData(WarcRecord record) { payloadLength = Long.toString(httpHeader.getPayloadLength()); protocolVersion = httpHeader.httpVersion; switch (httpHeader.headerType) { - case HttpHeader.HT_RESPONSE: - resultCode = httpHeader.statusCodeStr; - protocolContentType = httpHeader.contentType; - headerLine = httpHeader.getHeader("server"); - if (headerLine != null && headerLine.value != null) { - protocolServer = headerLine.value; - } - break; - case HttpHeader.HT_REQUEST: - headerLine = httpHeader.getHeader("user-agent"); - if (headerLine != null && headerLine.value != null) { - protocolUserAgent = headerLine.value; - } - break; + case HttpHeader.HT_RESPONSE: + resultCode = httpHeader.statusCodeStr; + protocolContentType = httpHeader.contentType; + headerLine = httpHeader.getHeader("server"); + if (headerLine != null && headerLine.value != null) { + protocolServer = headerLine.value; + } + break; + case HttpHeader.HT_REQUEST: + headerLine = httpHeader.getHeader("user-agent"); + if (headerLine != null && headerLine.value != null) { + protocolUserAgent = headerLine.value; + } + break; + default: + break; } } else { - payloadLength = Long.toString(payload.getTotalLength());; + payloadLength = Long.toString(payload.getTotalLength()); } } /* From 908b94dec3e29ebae2a9e30844ff17e0d22acb9d Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 13:44:19 +0200 Subject: [PATCH 05/10] add default switch statement to HtmlModule --- .../hul/ois/jhove/module/HtmlModule.java | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/jhove-modules/html-hul/src/main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java b/jhove-modules/html-hul/src/main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java index 427f77342..4b030d7d6 100644 --- a/jhove-modules/html-hul/src/main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java +++ b/jhove-modules/html-hul/src/main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java @@ -147,7 +147,7 @@ public class HtmlModule extends ModuleBase { XHTML_1_0_TRANSITIONAL = 9, XHTML_1_0_FRAMESET = 10, XHTML_1_1 = 11; /* Profile names, matching the above indices */ - private static final String[] profileNames = { null, null, // there are no + private static final String[] PROFILENAMES = { null, null, // there are no // profiles for // HTML 3.2 STRICT, FRAMESET, TRANSITIONAL, STRICT, FRAMESET, TRANSITIONAL, @@ -160,7 +160,7 @@ public class HtmlModule extends ModuleBase { }; /* Version names, matching the above indices */ - private static final String[] versionNames = { null, "HTML 3.2", HTML_4_0, + private static final String[] VERSIONNAMES = { null, "HTML 3.2", HTML_4_0, HTML_4_0, HTML_4_0, HTML_4_01, HTML_4_01, HTML_4_01, XHTML_1_0, XHTML_1_0, XHTML_1_0, "XHTML 1.1" }; @@ -290,6 +290,8 @@ public HtmlModule() { * Must be 0 in first call to parse. If * parse returns a nonzero value, it must be called * again with parseIndex equal to that return value. + * + * @return parseInt */ @Override public int parse(InputStream stream, RepInfo info, int parseIndex) { @@ -350,9 +352,9 @@ public int parse(InputStream stream, RepInfo info, int parseIndex) { */ setupDataStream(stream, info); - ParseHtml parser = null; + ParseHtml parser; HtmlMetadata metadata = null; - HtmlCharStream cstream = null; + HtmlCharStream cstream; try { cstream = new HtmlCharStream(_dstream, "ISO-8859-1"); parser = new ParseHtml(this, cstream); @@ -436,6 +438,8 @@ public int parse(InputStream stream, RepInfo info, int parseIndex) { return 0; case 2: // probably XHTML return 100; + default: + break; } info.setMessage(new ErrorMessage( MessageConstants.HTML_HUL_16)); @@ -443,14 +447,10 @@ public int parse(InputStream stream, RepInfo info, int parseIndex) { // But keep going } - HtmlDocDesc docDesc = null; + HtmlDocDesc docDesc; switch (type) { case HTML_3_2: - default: - docDesc = new Html3_2DocDesc(); - _textMD.setMarkup_basis("HTML"); - _textMD.setMarkup_basis_version("3.2"); - break; + case HTML_4_0_FRAMESET: docDesc = new Html4_0FrameDocDesc(); @@ -506,7 +506,7 @@ public int parse(InputStream stream, RepInfo info, int parseIndex) { _textMD.setCharset(TextMDMetadata.CHARSET_ISO8859_1); } String textMDEncoding = _textMD.getCharset(); - if (textMDEncoding.indexOf("UTF") != -1) { + if (textMDEncoding.contains("UTF")) { _textMD.setByte_order(_bigEndian ? TextMDMetadata.BYTE_ORDER_BIG : TextMDMetadata.BYTE_ORDER_LITTLE); _textMD.setByte_size("8"); @@ -535,10 +535,10 @@ public int parse(InputStream stream, RepInfo info, int parseIndex) { } if (type != 0) { - if (profileNames[type] != null) { - info.setProfile(profileNames[type]); + if (PROFILENAMES[type] != null) { + info.setProfile(PROFILENAMES[type]); } - info.setVersion(versionNames[type]); + info.setVersion(VERSIONNAMES[type]); } if (metadata != null) { @@ -573,6 +573,8 @@ public int parse(InputStream stream, RepInfo info, int parseIndex) { * @param info * A fresh RepInfo object which will be modified to reflect the * results of the test + * + * @throws IOException */ @Override public void checkSignatures(File file, InputStream stream, RepInfo info) @@ -617,7 +619,6 @@ public void checkSignatures(File file, InputStream stream, RepInfo info) } // If we fall through, there was no sig match info.setWellFormed(false); - return; } @@ -652,22 +653,26 @@ protected int checkDoctype(List elements) { } str = stripQuotes(((String) dt.get(2)).toUpperCase()); _doctype = str; - if ("-//W3C//DTD HTML 3.2 FINAL//EN".equals(str) - || "-//W3C//DTD HTML 3.2//EN".equals(str)) { - return HTML_3_2; - } else if ("-//W3C//DTD HTML 4.0//EN".equals(str)) { - return HTML_4_0_STRICT; - } else if ("-//W3C//DTD HTML 4.0 TRANSITIONAL//EN".equals(str)) { - return HTML_4_0_TRANSITIONAL; - } else if ("-//W3C//DTD HTML 4.0 FRAMESET//EN".equals(str)) { - return HTML_4_0_FRAMESET; - } else if ("-//W3C//DTD HTML 4.01//EN".equals(str)) { - return HTML_4_01_STRICT; - } else if ("-//W3C//DTD HTML 4.01 TRANSITIONAL//EN".equals(str)) { - return HTML_4_01_TRANSITIONAL; - } else if ("-//W3C//DTD HTML 4.01 FRAMESET//EN".equals(str)) { - return HTML_4_01_FRAMESET; - } + if (null + != str) switch (str) { + case "-//W3C//DTD HTML 3.2 FINAL//EN": + case "-//W3C//DTD HTML 3.2//EN": + return HTML_3_2; + case "-//W3C//DTD HTML 4.0//EN": + return HTML_4_0_STRICT; + case "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN": + return HTML_4_0_TRANSITIONAL; + case "-//W3C//DTD HTML 4.0 FRAMESET//EN": + return HTML_4_0_FRAMESET; + case "-//W3C//DTD HTML 4.01//EN": + return HTML_4_01_STRICT; + case "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN": + return HTML_4_01_TRANSITIONAL; + case "-//W3C//DTD HTML 4.01 FRAMESET//EN": + return HTML_4_01_FRAMESET; + default: + break; + } } catch (Exception e) { // Really shouldn't happen, but if it does we've got // a bad doctype From bea3bbc07991c9508255d7f581726a09cc573e7a Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 13:47:15 +0200 Subject: [PATCH 06/10] add default switch statement to TLMMarkerSegment JPEG2000 Module --- .../module/jpeg2000/TLMMarkerSegment.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/jhove-modules/jpeg2000-hul/src/main/java/edu/harvard/hul/ois/jhove/module/jpeg2000/TLMMarkerSegment.java b/jhove-modules/jpeg2000-hul/src/main/java/edu/harvard/hul/ois/jhove/module/jpeg2000/TLMMarkerSegment.java index 27cb9ed49..a5f9da112 100644 --- a/jhove-modules/jpeg2000-hul/src/main/java/edu/harvard/hul/ois/jhove/module/jpeg2000/TLMMarkerSegment.java +++ b/jhove-modules/jpeg2000-hul/src/main/java/edu/harvard/hul/ois/jhove/module/jpeg2000/TLMMarkerSegment.java @@ -27,14 +27,16 @@ public TLMMarkerSegment() { } /** - * Processes the marker segment. The DataInputStream - * will be at the point of having read the marker code. The - * process method must consume exactly the number - * of bytes remaining in the marker segment. + * Processes the marker segment.The DataInputStream + will be at the point of having read the marker code.The + process method must consume exactly the number + of bytes remaining in the marker segment. * * @param bytesToEat The number of bytes that must be consumed. * If it is 0 for a MarkerSegment, the * number of bytes to consume is unknown. + * @return boolean process + * @throws IOException */ @Override protected boolean process(int bytesToEat) throws IOException { @@ -48,15 +50,17 @@ protected boolean process(int bytesToEat) throws IOException { switch (st) { // case 0: add nothing case 1: - partLength += 1; - break; + partLength += 1; + break; case 2: - partLength += 2; - break; + partLength += 2; + break; case 3: - _repInfo.setMessage (new ErrorMessage + _repInfo.setMessage (new ErrorMessage (MessageConstants.JPEG2000_HUL_55)); - return false; // invalid st value + return false; // invalid st value + default: + break; } int nParts = (bytesToEat - 2) / partLength; @@ -79,8 +83,7 @@ protected boolean process(int bytesToEat) throws IOException { ttlm = _module.readUnsignedShort (_dstream); } tpList.add (new Property ("Index", - PropertyType.INTEGER, - new Integer (ttlm))); + PropertyType.INTEGER, ttlm)); } int length; if (sp == 1) { @@ -90,8 +93,7 @@ protected boolean process(int bytesToEat) throws IOException { length = _module.readUnsignedShort (_dstream); } tpList.add (new Property ("Length", - PropertyType.INTEGER, - new Integer (length))); + PropertyType.INTEGER, length)); _cs.addTileLength (new Property ("TilePartLength", PropertyType.PROPERTY, PropertyArity.LIST, From 416a08a158219614fc6dfe14d8beaf49c4e84efa Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 16:24:53 +0200 Subject: [PATCH 07/10] add default switch statement to PDF Module --- .../hul/ois/jhove/module/pdf/Literal.java | 127 ++++++++++-------- .../ois/jhove/module/pdf/PageLabelNode.java | 37 +++-- 2 files changed, 97 insertions(+), 67 deletions(-) diff --git a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/Literal.java b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/Literal.java index 17e622391..66d3ee154 100644 --- a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/Literal.java +++ b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/Literal.java @@ -108,10 +108,11 @@ public Literal () } /** - * Append a hex character. This is used only for hex literals - * (those that start with '<'). + * Append a hex character.This is used only for hex literals + * (those that start with '<'). * * @param ch The integer 8-bit code for a hex character + * @throws edu.harvard.hul.ois.jhove.module.pdf.PdfException */ public void appendHex (int ch) throws PdfException { @@ -119,7 +120,7 @@ public void appendHex (int ch) throws PdfException _rawBytes = new Vector<> (32); } if (haveHi) { - _rawBytes.add(new Integer (hexToInt (hi, ch))); + _rawBytes.add(hexToInt (hi, ch)); haveHi = false; } else { @@ -129,20 +130,20 @@ public void appendHex (int ch) throws PdfException } /** - * Process the incoming characters into a string literal. - * This is used for literals delimited - * by parentheses, as opposed to hex strings. + * Process the incoming characters into a string literal.This is used for literals delimited + by parentheses, as opposed to hex strings. * * @param tok The tokenizer, passed to give access to its getChar * function. * @return true if the character was processed * normally, false if a terminating * parenthesis was reached. + * @throws IOException */ public long processLiteral (Tokenizer tok) throws IOException { /** Variable for UTF-16 chars. */ - int utfch = 0; + int utfch; /** First byte of a UTF-16 character. */ int b1 = 0x00; /* Character read from tokenizer. */ @@ -160,7 +161,7 @@ public long processLiteral (Tokenizer tok) throws IOException throw new EOFException (MessageConstants.PDF_HUL_10.getMessage()); // PDF-HUL-10 } offset++; - _rawBytes.add (new Integer (ch)); + _rawBytes.add (ch); if (_state == State.LITERAL) { // We are still in a state of flux, determining the encoding @@ -175,16 +176,17 @@ else if (ch == CLOSE_PARENTHESIS && --_parenLevel < 0) { } else if (ch == BACKSLASH) { ch = readBackslashSequence (false, tok); - if (ch == 0) { - continue; // invalid character, ignore - } - else if (ch == FE) { - _state = State.LITERAL_FE; - } - else { - // any other char is treated nonspecially - setPDFDocEncoding (true); - buffer.append (PDFDOCENCODING[ch]); + switch (ch) { + case 0: + continue; // invalid character, ignore + case FE: + _state = State.LITERAL_FE; + break; + default: + // any other char is treated nonspecially + setPDFDocEncoding (true); + buffer.append (PDFDOCENCODING[ch]); + break; } } else { @@ -201,33 +203,33 @@ else if (ch == FE) { } } else if (_state == (State.LITERAL_FE)) { - if (ch == FF) { - _state = State.LITERAL_UTF16_1; - setPDFDocEncoding (false); - } - else if (ch == BACKSLASH) { - ch = readBackslashSequence (false, tok); - if (ch == 0) { - continue; // invalid character, ignore - } - if (ch == FF) { + switch (ch) { + case FF: _state = State.LITERAL_UTF16_1; setPDFDocEncoding (false); - } - else { - // any other char is treated nonspecially + break; + case BACKSLASH: + ch = readBackslashSequence (false, tok); + if (ch == 0) { + continue; // invalid character, ignore + } if (ch == FF) { + _state = State.LITERAL_UTF16_1; + setPDFDocEncoding (false); + } + else { + // any other char is treated nonspecially + setPDFDocEncoding (true); + // The FE is just an FE, put it in the buffer + buffer.append (PDFDOCENCODING[FE]); + buffer.append (PDFDOCENCODING[ch]); + } break; + default: + _state = State.LITERAL_PDF; setPDFDocEncoding (true); // The FE is just an FE, put it in the buffer buffer.append (PDFDOCENCODING[FE]); buffer.append (PDFDOCENCODING[ch]); - } - } - else { - _state = State.LITERAL_PDF; - setPDFDocEncoding (true); - // The FE is just an FE, put it in the buffer - buffer.append (PDFDOCENCODING[FE]); - buffer.append (PDFDOCENCODING[ch]); + break; } } else if (_state == (State.LITERAL_PDF)) { @@ -252,19 +254,19 @@ else if (_state == (State.LITERAL_UTF16_1)) { // paren or backslash is a single-byte character. // Parens within the string are double-byte characters, // so we don't have to worry about them. - if (ch == CLOSE_PARENTHESIS) { - setValue(buffer.toString()); - return offset; - } - else if (ch == BACKSLASH) { - utfch = readBackslashSequence (true, tok); - if (utfch == 0) { - continue; // invalid character, ignore - } - } - else { - _state = State.LITERAL_UTF16_2; - b1 = ch; + switch (ch) { + case CLOSE_PARENTHESIS: + setValue(buffer.toString()); + return offset; + case BACKSLASH: + utfch = readBackslashSequence (true, tok); + if (utfch == 0) { + continue; // invalid character, ignore + } break; + default: + _state = State.LITERAL_UTF16_2; + b1 = ch; + break; } } else if (_state == (State.LITERAL_UTF16_2)) { @@ -298,9 +300,10 @@ else if (_state == (State.LITERAL_UTF16_2)) { /** - * Convert the raw hex data. Two buffers are saved: _rawBytes - * for the untranslated hex-encoded data, and _value for the - * PDF or UTF encoded string. + * Convert the raw hex data.Two buffers are saved: _rawBytes + * for the untranslated hex-encoded data, and _value for the + * PDF or UTF encoded string. + * @throws edu.harvard.hul.ois.jhove.module.pdf.PdfException */ public void convertHex () throws PdfException { @@ -309,7 +312,7 @@ public void convertHex () throws PdfException StringBuffer localBuffer = new StringBuffer(); // If a high byte is left hanging, complete it with a '0' if (haveHi) { - _rawBytes.add(new Integer(hexToInt(hi, '0'))); + _rawBytes.add(hexToInt(hi, '0')); } if (_rawBytes.size() >= 2 && rawByte(0) == 0XFE && rawByte(1) == 0XFF) { @@ -365,13 +368,15 @@ private int rawByte (int idx) if (idx >= _rawBytes.size ()) { return 0; } - return _rawBytes.elementAt (idx).intValue(); + return _rawBytes.elementAt (idx); } /** * Returns true if this string is in PDFDocEncoding, * false if UTF-16. + * + * @return isPdfDocEncoding */ public boolean isPDFDocEncoding () { @@ -380,6 +385,7 @@ public boolean isPDFDocEncoding () /** * Sets the value of pDFDocEncoding. + * @param pdfDocEncoding: boolean if the is in PDFDocEncoding */ public void setPDFDocEncoding (boolean pdfDocEncoding) { @@ -393,6 +399,8 @@ public void setPDFDocEncoding (boolean pdfDocEncoding) * If we take this literally, the format is frighteningly ambiguous * (imagine, for instance, leaving out hours but not minutes and * seconds), so the checking is a bit loose. + * + * @return if it's a Date */ public boolean isDate () { @@ -407,6 +415,8 @@ public boolean isDate () * Adobe doesn't actually say so, but I'm assuming that if a * field is included, everything to its left must be included, * e.g., you can't have seconds but leave out minutes. + * + * @return date of string value */ public Date parseDate () { @@ -419,7 +429,7 @@ public Date parseDate () char timezonechar = '?'; // +, -, or Z int timezonehour = 0; int timezoneminute = 0; - Calendar cal = null; + Calendar cal; String str = getValue (); if (str == null) { @@ -572,6 +582,7 @@ public Date parseDate () /** * Returns true if this token doesn't violate any * PDF/A rules, false if it does. + * @return if it's PDF/A compliant */ public boolean isPDFACompliant () { diff --git a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PageLabelNode.java b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PageLabelNode.java index b08006def..9f169a015 100644 --- a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PageLabelNode.java +++ b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PageLabelNode.java @@ -58,12 +58,13 @@ public PageLabelNode (PdfModule module, /** * Build the subtree of descendants of this node, using - * the Kids entry in the dictionary. Leaf nodes are - * recognized by not having a Kids entry. + * the Kids entry in the dictionary.Leaf nodes are + * recognized by not having a Kids entry. + * @throws edu.harvard.hul.ois.jhove.module.pdf.PdfException */ public void buildSubtree () throws PdfException { - PdfArray kids = null; + PdfArray kids; try { kids = (PdfArray) _dict.get("Kids"); if (kids != null) { @@ -118,6 +119,7 @@ public void startWalk () * under this node, and finally will return null when there are no more. * A leaf object is one which has no Kids; it is required to have a * Nums entry. + * @return nextLeafObject: the leaf object under this node */ public PageLabelNode nextLeafObject () { @@ -153,12 +155,16 @@ public PageLabelNode nextLeafObject () } /** - * Obtain the next key-value pair from the tree. This returns true - * if a pair is available, false if not. After this is called, - * getCurrentKey and getCurrentValue may be called to retrieve the - * key and value thus found. Each time this is called, - * currentKey and currentValue get copied into prevKey and - * prevValue. + * Obtain the next key-value pair from the tree.This returns true + * if a pair is available, false if not. After this is called, + * getCurrentKey and getCurrentValue may be called to retrieve the + * key and value thus found. Each time this is called, + * currentKey and currentValue get copied into prevKey and + * prevValue. + * + * @return boolean: true if a next key-value pair is available, + * false if no + * @throws edu.harvard.hul.ois.jhove.module.pdf.PdfException */ public boolean findNextKeyValue () throws PdfException { @@ -205,6 +211,7 @@ public boolean findNextKeyValue () throws PdfException /** * Returns key at current position in traversing tree + * @return int */ public int getCurrentKey () { @@ -213,6 +220,7 @@ public int getCurrentKey () /** * Returns value associated with current key + * @return PdfObject */ public PdfObject _getCurrentValue () { @@ -221,6 +229,7 @@ public PdfObject _getCurrentValue () /** * Returns key previously obtained in traversing tree + * @return int */ public int getPrevKey () { @@ -230,6 +239,7 @@ public int getPrevKey () /** * Returns value associated with key previously obtained * in traversing tree + * @return PdfObject */ public PdfObject getPrevValue () { @@ -239,6 +249,9 @@ public PdfObject getPrevValue () /** * A convenience method to turn integers into Roman * numerals, for the generation of page labels. + * @param n: the integer + * @param upperCase: true if upperCase Roman numerals are wanted + * @return */ public static String intToRoman (int n, boolean upperCase) { @@ -326,6 +339,8 @@ public static String intToRoman (int n, boolean upperCase) case 9: buf.append ("IX"); break; + default: + break; } String val = buf.toString (); if (upperCase) { @@ -338,6 +353,10 @@ public static String intToRoman (int n, boolean upperCase) * "letter" page numbers as defined for PDF. * The first 26 pages are A-Z, the next 26 AA-ZZ, * etc. + * @param n: integers to be turned into letters + * @param upperCase: true if uppercase letters are wanted + * + * @return String */ public static String intToBase26 (int n, boolean upperCase) { From e85af8dfb8a910ff1e7285a23f04c939d1ce600e Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 16:33:51 +0200 Subject: [PATCH 08/10] add default switch statement to PDF Module (bis) --- .../jhove/module/pdf/PdfFlateInputStream.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PdfFlateInputStream.java b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PdfFlateInputStream.java index 4b4526c42..7e32a2d96 100644 --- a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PdfFlateInputStream.java +++ b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PdfFlateInputStream.java @@ -120,6 +120,9 @@ public PdfFlateInputStream (InputStream is, PdfDictionary parms) /** Reads one byte from the stream. * Returns -1 if end of file is reached. + * + * @return number of bytes + * @throws IOException */ @Override public int read() throws IOException @@ -140,9 +143,14 @@ public int read() throws IOException return rowBuf[rowBufOff++] & 0xFF; } - /** Reads the specified number of bytes into a buffer. - * Returns the number of bytes actually read, or -1 if - * end of file has been reached. */ + /** * Reads the specified number of bytes into a buffer.Returns the number of bytes actually read, or -1 if + end of file has been reached. + * + * @param b: array of bytes in buffer + * @return int: the number of bytes actually read or -1 if + * end of file has been reached + * @throws IOException + */ @Override public int read (byte[] b) throws IOException { @@ -155,6 +163,12 @@ public int read (byte[] b) throws IOException * Returns -1 if end of file has been reached. * No matter how much is requested, this will only return one * row's worth of data at most. + * + * @param b: array of bytes of file + * @param off: the specified offset + * @param len: the specified length + * @return number of bytes or -1 if end of file is reached + * @throws IOException */ @Override public int read (byte[] b, int off, int len) throws IOException @@ -266,6 +280,8 @@ else if (pb<=pc) { break; case 15: // optimum -- per line determination break; + default: + break; } } From 027727b38e5bc35dedbdc1acc76b257a511d60b8 Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 17:18:44 +0200 Subject: [PATCH 09/10] add default switch statement to TIFF module --- .../hul/ois/jhove/module/tiff/IFD.java | 219 +++++++++++++++--- .../ois/jhove/module/tiff/TiffProfileFXC.java | 6 + 2 files changed, 190 insertions(+), 35 deletions(-) diff --git a/jhove-modules/tiff-hul/src/main/java/edu/harvard/hul/ois/jhove/module/tiff/IFD.java b/jhove-modules/tiff-hul/src/main/java/edu/harvard/hul/ois/jhove/module/tiff/IFD.java index 7eacbd0a5..4297c0d26 100644 --- a/jhove-modules/tiff-hul/src/main/java/edu/harvard/hul/ois/jhove/module/tiff/IFD.java +++ b/jhove-modules/tiff-hul/src/main/java/edu/harvard/hul/ois/jhove/module/tiff/IFD.java @@ -38,7 +38,7 @@ public abstract class IFD ******************************************************************/ /* Set to true to allow out-of-sequence tags. */ - private static final boolean debug_allowoutofsequence = false; + private static final boolean DEBUG_ALLOW_OUT_OF_SEQUENCE = false; /****************************************************************** * PUBLIC CLASS FIELDS. @@ -166,55 +166,78 @@ public IFD(long offset, RepInfo info, RandomAccessFile raf, * PUBLIC INSTANCE METHODS. ******************************************************************/ - /** Get any errors discovered during parsing. */ + /** Get any errors discovered during parsing. + * @return list of strings with errors + */ public List getErrors() { return _errors; } - /** Get the offset of the next IFD. */ + /** Get the offset of the next IFD. + * @return next + */ public long getNext() { return _next; } - /** Get the IFD offset. */ + /** Get the IFD offset. + * @return IFD offset + */ public long getOffset() { return _offset; } - /** Get the IFD properties. */ + /** Get the IFD properties. + * @param rawOutput: boolean + * @return Property + * @throws edu.harvard.hul.ois.jhove.module.tiff.TiffException + */ public abstract Property getProperty(boolean rawOutput) throws TiffException; - /** Get the TIFF version. */ + /** Get the TIFF version. + * @return TIFF version + */ public int getVersion() { return _version; } - /** Return true if this is the first IFD. */ + /** Return true if this is the first IFD. + * @return if it's first? + */ public boolean isFirst() { return _first; } - /** Return true if this is the thumbnail IFD. */ + /** Return true if this is the thumbnail IFD. + * @return if it's a thumbnail + */ public boolean isThumbnail() { return _thumbnail; } - /** Lookup IFD tag. */ + /** Lookup IFD tag. + * @param tag + * @param type + * @param count + * @param value + * @throws edu.harvard.hul.ois.jhove.module.tiff.TiffException + */ public abstract void lookupTag(int tag, int type, long count, long value) throws TiffException; - /** Parse the IFD. Errors are not suppressed, and odd byte offsets for - * tags not allowed. + /** Parse the IFD.Errors are not suppressed, and odd byte offsets for + * tags not allowed. * * @return The offset of the next IFD + * @throws edu.harvard.hul.ois.jhove.module.tiff.TiffException */ public long parse() throws TiffException @@ -226,6 +249,7 @@ public long parse() * @param byteOffsetIsValid If true, allow offsets on odd byte boundaries * @param suppressErrors If true, return IFD even with errors * @return The offset of the next IFD + * @throws edu.harvard.hul.ois.jhove.module.tiff.TiffException */ public long parse(boolean byteOffsetIsValid, boolean suppressErrors) throws TiffException @@ -247,10 +271,11 @@ public long parse(boolean byteOffsetIsValid, boolean suppressErrors) } - /** Parse the IFD. Errors are not suppressed. + /** Parse the IFD.Errors are not suppressed. * * @param byteOffsetIsValid If true, allow offsets on odd byte boundaries * @return The offset of the next IFD + * @throws edu.harvard.hul.ois.jhove.module.tiff.TiffException */ public long parse(boolean byteOffsetIsValid) throws TiffException @@ -288,8 +313,8 @@ public long parse(boolean byteOffsetIsValid) int tag = ModuleBase.readUnsignedShort(ifdStream, _bigEndian, null); /* Tags must be in ascending numerical order. */ - if (!debug_allowoutofsequence && tag < prevTag) { - String mess = MessageFormat.format(MessageConstants.TIFF_HUL_2.getMessage(), Integer.valueOf(tag)); + if (!DEBUG_ALLOW_OUT_OF_SEQUENCE && tag < prevTag) { + String mess = MessageFormat.format(MessageConstants.TIFF_HUL_2.getMessage(), tag); JhoveMessage message = JhoveMessages.getMessageInstance(MessageConstants.TIFF_HUL_2.getId(), mess); _info.setMessage(new ErrorMessage(message, _offset + 2 + 12*i)); _info.setWellFormed(false); @@ -300,7 +325,7 @@ public long parse(boolean byteOffsetIsValid) _bigEndian, null); /* Skip over tags with unknown type. */ if (type < BYTE || type > IFD) { - String subMess = MessageFormat.format(MessageConstants.TIFF_HUL_3_SUB.getMessage(), Integer.valueOf(type), Integer.valueOf(tag)); + String subMess = MessageFormat.format(MessageConstants.TIFF_HUL_3_SUB.getMessage(), type, Integer.valueOf(tag)); _info.setMessage(new ErrorMessage(MessageConstants.TIFF_HUL_3, subMess, _offset + 4 + 12*i)); } @@ -318,7 +343,7 @@ public long parse(boolean byteOffsetIsValid) /* Value is the word-aligned offset of the actual * value. */ if ((value & 1) != 0) { - final String mess = MessageFormat.format(MessageConstants.TIFF_HUL_4.getMessage(), Long.valueOf(value)); + final String mess = MessageFormat.format(MessageConstants.TIFF_HUL_4.getMessage(), value); JhoveMessage message = JhoveMessages.getMessageInstance(MessageConstants.TIFF_HUL_4.getId(), mess); if (byteOffsetIsValid) { _info.setMessage(new InfoMessage(message, _offset + 10 + 12*i)); @@ -345,7 +370,9 @@ public long parse(boolean byteOffsetIsValid) return _next; } - /** Sets flag indicating whether this is the first IFD. */ + /** Sets flag indicating whether this is the first IFD. + * @param first: true if it's the first IFD + */ public void setFirst(boolean first) { _first = first; @@ -353,7 +380,9 @@ public void setFirst(boolean first) /** Sets flag indicating whether this is the "thumbnail" IFD. * The second IFD in the top-level chain is assumed to be - * the Thumbnail IFD. */ + * the Thumbnail IFD. + * @param thumbnail: flag true if this is the thumbnail IFD + */ public void setThumbnail(boolean thumbnail) { _thumbnail = thumbnail; @@ -369,6 +398,14 @@ public void setThumbnail(boolean thumbnail) * the low-order bit as bit 0. * if rawOutput is false, returns a LONG * property whose numeric value is value. + * + * @param name + * @param value + * @param labels + * @param rawOutput: true if string output is wanted, false returns + * a long property + * @return property representing a bitmask + * */ protected Property addBitmaskProperty(String name, long value, String [] labels, boolean rawOutput) @@ -390,7 +427,7 @@ protected Property addBitmaskProperty(String name, long value, PropertyArity.LIST, list); } if (prop == null) { - prop = new Property(name, PropertyType.LONG, new Long(value)); + prop = new Property(name, PropertyType.LONG, value); } return prop; @@ -404,6 +441,13 @@ protected Property addBitmaskProperty(String name, long value, * returns a STRING property, with the * string being the element of labels * whose index is value. + * + * @param name + * @param value + * @param labels + * @param rawOutput: true if integer output is wanted, false returns + * a string property + * @return property representing an integer value */ protected Property addIntegerProperty(String name, int value, String [] labels, boolean rawOutput) @@ -418,8 +462,7 @@ protected Property addIntegerProperty(String name, int value, } } if (prop == null) { - prop = new Property(name, PropertyType.INTEGER, - new Integer(value)); + prop = new Property(name, PropertyType.INTEGER, value); } return prop; @@ -434,6 +477,14 @@ protected Property addIntegerProperty(String name, int value, * string being the element of labels * whose index is the index of * value in index. + * + * @param name + * @param value + * @param labels + * @param index + * @param rawOutput: true if int output is wanted, false returns + * a string property + * @return property representing an integer value */ protected Property addIntegerProperty(String name, int value, String [] labels, int [] index, @@ -457,7 +508,7 @@ protected Property addIntegerProperty(String name, int value, } if (prop == null) { prop = new Property(name, PropertyType.INTEGER, - new Integer(value)); + value); } return prop; @@ -470,6 +521,13 @@ protected Property addIntegerProperty(String name, int value, * the elements of the array are STRING properties, with the * elements of value used as indices into * labels. + * + * @param name + * @param value + * @param labels + * @param rawOutput: true if int output is wanted, false returns + * a string property + * @return property representing an integer array */ protected Property addIntegerArrayProperty(String name, int [] value, String [] labels, @@ -502,7 +560,14 @@ protected Property addIntegerArrayProperty(String name, int [] value, * If rawOutput is true, returns a property with type * RATIONAL. Otherwise, returns a property with type * STRING, and the text representation of the Rational - * value as a floating-point ratio. */ + * value as a floating-point ratio. + * + * @param name + * @param r: a rational value + * @param rawOutput: true if int output is wanted, false returns + * a string property + * @return property for a tag with a RATIONAL value + */ protected Property addRationalProperty(String name, Rational r, boolean rawOutput) { @@ -545,12 +610,16 @@ protected void postParseInitialization() { } - /** Standard IFD property header. */ + /** Standard IFD property header. + * + * @param type + * @param entries + * @return IDF property header + */ protected Property propertyHeader(String type, List entries) { Property [] array = new Property [3]; - array[0] = new Property("Offset", PropertyType.LONG, - new Long(_offset)); + array[0] = new Property("Offset", PropertyType.LONG,_offset); array[1] = new Property("Type", PropertyType.STRING, type); array[2] = new Property("Entries", PropertyType.PROPERTY, PropertyArity.LIST, entries); @@ -560,10 +629,12 @@ protected Property propertyHeader(String type, List entries) } /** - * Reads a string value from the TIFF file. + * Reads a string value from the TIFF file. * If there are non-ASCII characters, they're escaped as %XX * @param count Length of string * @param value Offset of string + * @return ASCII string + * @throws IOException */ protected String readASCII(long count, long value) throws IOException @@ -595,7 +666,9 @@ protected String readASCII(long count, long value) * * @param count Number of strings to read * @param value Offset from which to read - * + * + * @return ASCII string array + * @throws IOException */ protected String [] readASCIIArray(long count, long value) throws IOException @@ -639,7 +712,9 @@ protected String readASCII(long count, long value) * @param type TIFF type to read; must be an 8-bit type * @param count Unused * @param value Offset from which to read - * + * + * @return unsigned 8-bit integer value + * @throws java.io.IOException */ protected int readByte(int type, long count, long value) throws IOException @@ -654,6 +729,9 @@ protected int readByte(int type, long count, long value) * @param type TIFF type to read; must be an 8-bit type * @param count Number of bytes to read * @param value Offset from which to read + * + * @return int array of bytes + * @throws IOException */ protected int [] readByteArray(int type, long count, long value) throws IOException @@ -674,6 +752,9 @@ protected int readByte(int type, long count, long value) * @param type Unused * @param count Number of bytes to read * @param value Offset from which to read + * + * @return byte array + * @throws java.io.IOException */ protected byte [] readTrueByteArray(int type, long count, long value) throws IOException @@ -690,6 +771,9 @@ protected int readByte(int type, long count, long value) * * @param count Number of values to read * @param value Offset from which to read + * + * @return double array + * @throws IOException */ protected double [] readDoubleArray(long count, long value) throws IOException @@ -709,7 +793,9 @@ protected int readByte(int type, long count, long value) * @param type TIFF type to read; must be a 32-bit type * @param count Unused * @param value Offset from which to read - * + * + * @return unsigned 32-bit integer value + * @throws IOException */ protected long readLong(int type, long count, long value) throws IOException @@ -728,6 +814,9 @@ protected long readLong(int type, long count, long value) * @param type TIFF type to read; must be a 32-bit type * @param count Number of values to read * @param value Offset from which to read + * + * @return long array + * @throws IOException */ protected long [] readLongArray(int type, long count, long value) throws IOException @@ -743,6 +832,9 @@ protected long readLong(int type, long count, long value) /** Reads an unsigned number of any type. * @param type TIFF type to read + * + * @return unsigned number + * @throws IOException */ public long readUnsigned(int type) throws IOException @@ -761,6 +853,8 @@ public long readUnsigned(int type) case IFD: u = ModuleBase.readUnsignedInt(_raf, _bigEndian); break; + default: + break; } return u; @@ -768,6 +862,12 @@ public long readUnsigned(int type) /** Reads a RATIONAL value and returns it as a Rational. + * + * @param count + * @param value + * + * @return rational + * @throws IOException */ protected Rational readRational(long count, long value) throws IOException @@ -781,6 +881,12 @@ protected Rational readRational(long count, long value) /** Reads an array of RATIONAL values and returns it as an * array of Rational. + * + * @param count + * @param value + * + * @return array of rational values + * @throws IOException */ protected Rational [] readRationalArray(long count, long value) throws IOException @@ -805,6 +911,12 @@ protected Rational readRational(long count, long value) } /** Reads an SRATIONAL value and returns it as a Rational. + * + * @param count + * @param value + * + * @return rational + * @throws IOException */ protected Rational readSignedRational(long count, long value) throws IOException @@ -818,6 +930,12 @@ protected Rational readSignedRational(long count, long value) /** Reads an array of SRATIONAL values and returns it as an * array of Rational. + * + * @param count + * @param value + * + * @return array of rational values + * @throws IOException */ protected Rational [] readSignedRationalArray(long count, long value) throws IOException @@ -842,7 +960,15 @@ protected Rational readSignedRational(long count, long value) } - /** Reads and returns a single unsigned 16-bit value. */ + /** Reads and returns a single unsigned 16-bit value. + * + * @param type + * @param count + * @param value + * + * @return unsigned 16-bit value + * @throws IOException + */ protected int readShort(int type, long count, long value) throws IOException { @@ -854,6 +980,13 @@ protected int readShort(int type, long count, long value) /** * Reads a TIFF array of unsigned 16-bit values and returns * it as an int array. + * + * @param type + * @param count + * @param value + * + * @return int array + * @throws IOException */ protected int [] readShortArray(int type, long count, long value) throws IOException @@ -870,6 +1003,13 @@ protected int readShort(int type, long count, long value) /** * Reads a TIFF array of signed 16-bit values and returns * it as an int array. + * + * @param type + * @param count + * @param value + * + * @return int array + * @throws IOException */ protected int [] readSShortArray(int type, long count, long value) throws IOException @@ -888,6 +1028,8 @@ protected int readShort(int type, long count, long value) * type will require. * @param type Field type * @param count Field count + * + * @return number of bytes */ public static long calcValueSize(int type, long count) { @@ -914,6 +1056,8 @@ public static long calcValueSize(int type, long count) case DOUBLE: fieldSize = 8; break; + default: + break; } return count*fieldSize; } @@ -938,12 +1082,14 @@ public boolean isBigEndian() * @param tag Tag entry value * @param count Tag entry count * @param minCount Tag count + * @throws edu.harvard.hul.ois.jhove.module.tiff.TiffException */ protected static void checkCount(int tag, long count, int minCount) throws TiffException { if (count < minCount) { - String mess = MessageFormat.format(MessageConstants.TIFF_HUL_6.getMessage(), Integer.valueOf(tag), Integer.valueOf(minCount), Long.valueOf(count)); + String mess = MessageFormat.format(MessageConstants.TIFF_HUL_6.getMessage(), + tag, Integer.valueOf(minCount), Long.valueOf(count)); JhoveMessage message = JhoveMessages.getMessageInstance(MessageConstants.TIFF_HUL_6.getId(), mess); throw new TiffException(message); } @@ -953,7 +1099,8 @@ protected static void checkCount(int tag, long count, int minCount) * Check the tag entry type. * @param tag Tag entry value * @param type Tag entry type - * @param expected Tag type + * @param expected Tag + * @throws edu.harvard.hul.ois.jhove.module.tiff.TiffException */ protected static void checkType(int tag, int type, int expected) throws TiffException @@ -967,7 +1114,7 @@ protected static void checkType(int tag, int type, int expected) } } if (type != expected) { - String mess = MessageFormat.format(MessageConstants.TIFF_HUL_7.getMessage(), Integer.valueOf(tag), Integer.valueOf(expected), Integer.valueOf(type)); + String mess = MessageFormat.format(MessageConstants.TIFF_HUL_7.getMessage(), tag, Integer.valueOf(expected), Integer.valueOf(type)); JhoveMessage message = JhoveMessages.getMessageInstance(MessageConstants.TIFF_HUL_7.getId(), mess); throw new TiffException(message); } @@ -979,12 +1126,14 @@ protected static void checkType(int tag, int type, int expected) * @param type Tag entry type * @param type1 Tag type * @param type2 Alternate tag type + * @throws edu.harvard.hul.ois.jhove.module.tiff.TiffException */ protected static void checkType(int tag, int type, int type1, int type2) throws TiffException { if (type != type1 && type != type2) { - String mess = MessageFormat.format(MessageConstants.TIFF_HUL_8.getMessage(), Integer.valueOf(tag), Integer.valueOf(type1), Integer.valueOf(type2), Integer.valueOf(type)); + String mess = MessageFormat.format(MessageConstants.TIFF_HUL_8.getMessage(), + tag, Integer.valueOf(type1), Integer.valueOf(type2), Integer.valueOf(type)); JhoveMessage message = JhoveMessages.getMessageInstance(MessageConstants.TIFF_HUL_8.getId(), mess); throw new TiffException(message); } diff --git a/jhove-modules/tiff-hul/src/main/java/edu/harvard/hul/ois/jhove/module/tiff/TiffProfileFXC.java b/jhove-modules/tiff-hul/src/main/java/edu/harvard/hul/ois/jhove/module/tiff/TiffProfileFXC.java index 49d272e6c..894dce562 100644 --- a/jhove-modules/tiff-hul/src/main/java/edu/harvard/hul/ois/jhove/module/tiff/TiffProfileFXC.java +++ b/jhove-modules/tiff-hul/src/main/java/edu/harvard/hul/ois/jhove/module/tiff/TiffProfileFXC.java @@ -34,6 +34,10 @@ public TiffProfileFXC () * Returns true if the IFD satisfies the requirements of a * TIFF/FX C profile. See the TIFF/FX specification for * details. + * + * @param ifd: IDF object + * + * @return true if it satifies the profile */ @Override public boolean satisfiesThisProfile(IFD ifd) @@ -125,6 +129,8 @@ public boolean satisfiesThisProfile(IFD ifd) return false; } break; + default: + break; } // By my best reading, the colormap is needed only From abb2b15d2e1b24875a04cd4297883ef51bcd3e21 Mon Sep 17 00:00:00 2001 From: nvanderperren Date: Tue, 22 Oct 2019 21:56:11 +0200 Subject: [PATCH 10/10] bugfix HTML module (thank you travis :sweat_smile:) --- .../main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhove-modules/html-hul/src/main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java b/jhove-modules/html-hul/src/main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java index 4b030d7d6..d953b3f92 100644 --- a/jhove-modules/html-hul/src/main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java +++ b/jhove-modules/html-hul/src/main/java/edu/harvard/hul/ois/jhove/module/HtmlModule.java @@ -447,7 +447,7 @@ public int parse(InputStream stream, RepInfo info, int parseIndex) { // But keep going } - HtmlDocDesc docDesc; + HtmlDocDesc docDesc = null; switch (type) { case HTML_3_2: