Intellij suggested changes from static code analysis.

This commit is contained in:
Koen De Groote
2020-01-28 16:18:07 +01:00
parent b6773f6983
commit aff31ebd1b
8 changed files with 46 additions and 47 deletions
@@ -84,7 +84,7 @@ abstract class DIBImageReader extends ImageReaderBase {
protected void resetMembers() {
directory = null;
headers.clear();
descriptors.clear();
@@ -551,7 +551,7 @@ abstract class DIBImageReader extends ImageReaderBase {
if (abortRequested()) {
processReadAborted();
break;
}
}
processImageProgress(100 * y / (float) pBitmap.getHeight());
}
@@ -591,7 +591,7 @@ abstract class DIBImageReader extends ImageReaderBase {
return directory.getEntry(pImageIndex);
}
/// Test code below, ignore.. :-)
public static void main(final String[] pArgs) throws IOException {
if (pArgs.length == 0) {
@@ -701,10 +701,10 @@ abstract class DIBImageReader extends ImageReaderBase {
}
});
button.setText("" + image.getWidth() + "x" +
button.setText(image.getWidth() + "x" +
image.getHeight() + ": "
+ ((image.getColorModel() instanceof IndexColorModel) ?
"" + ((IndexColorModel) image.getColorModel()).getMapSize() :
String.valueOf(((IndexColorModel) image.getColorModel()).getMapSize()) :
"TrueColor"));
pParent.add(button);
@@ -60,10 +60,10 @@ public abstract class AbstractEntry implements Entry {
}
/**
* Returns a format-native identifier.
* For example {@code "2:00"} for IPTC "Record Version" field, or {@code "0x040c"} for PSD "Thumbnail" resource.
* Returns a format-native identifier.
* For example {@code "2:00"} for IPTC "Record Version" field, or {@code "0x040c"} for PSD "Thumbnail" resource.
* This default implementation simply returns {@code String.valueOf(getIdentifier())}.
*
*
* @return a format-native identifier.
*/
protected String getNativeIdentifier() {
@@ -174,7 +174,7 @@ public abstract class AbstractEntry implements Entry {
}
AbstractEntry other = (AbstractEntry) pOther;
return identifier.equals(other.identifier) && (
value == null && other.value == null || value != null && valueEquals(other)
);
@@ -144,7 +144,7 @@ public final class XMPReader extends MetadataReader {
parseAttributesForKnownElements(subsubdirs, node);
if (!subsubdirs.isEmpty()) {
List<Entry> entries = new ArrayList<Entry>();
List<Entry> entries = new ArrayList<>(subsubdirs.size());
for (Map.Entry<String, List<Entry>> entry : subsubdirs.entrySet()) {
entries.addAll(entry.getValue());
@@ -161,7 +161,7 @@ public final class XMPReader extends MetadataReader {
}
}
List<Directory> entries = new ArrayList<Directory>();
List<Directory> entries = new ArrayList<Directory>(subdirs.size());
// TODO: Should we still allow asking for a subdirectory by item id?
for (Map.Entry<String, List<Entry>> entry : subdirs.entrySet()) {
@@ -340,7 +340,7 @@ public final class ThumbsDBImageReader extends ImageReaderBase {
// TODO: Rethink this...
// Seems to be up to Windows and the installed programs what formats
// are supported...
// Some thumbs are just icons, and it might be better to use ImageIO to create thumbs for these... :-/
// Some thumbs are just icons, and it might be better to use ImageIO to create thumbs for these... :-/
// At least this seems fine for now
String extension = FileUtil.getExtension(pFileName);
if (StringUtil.isEmpty(extension)) {
@@ -351,7 +351,7 @@ public final class ThumbsDBImageReader extends ImageReaderBase {
return !"psd".equals(extension) && !"svg".equals(extension) && catalog != null && catalog.getIndex(pFileName) != -1;
}
/// Test code below
/// Test code below
public static void main(String[] pArgs) throws IOException {
ThumbsDBImageReader reader = new ThumbsDBImageReader();
@@ -421,7 +421,7 @@ public final class ThumbsDBImageReader extends ImageReaderBase {
return SIZE;
}
});
label.setText("" + image.getWidth() + "x" + image.getHeight() + ": " + pName);
label.setText(image.getWidth() + "x" + image.getHeight() + ": " + pName);
label.setToolTipText(image.toString());
pParent.add(label);
}
@@ -1144,10 +1144,11 @@ public final class TIFFImageMetadata extends AbstractMetadata {
throw new IIOInvalidTreeException("Expected \"TIFFIFD\" node", ifdNode);
}
List<Entry> entries = new ArrayList<>();
NodeList nodes = ifdNode.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
final int size = nodes.getLength();
List<Entry> entries = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
entries.add(toEntry(nodes.item(i)));
}