diff --git a/common/common-lang/src/main/java/com/twelvemonkeys/util/Time.java b/common/common-lang/src/main/java/com/twelvemonkeys/util/Time.java index 97f8f04e..a33fcd40 100755 --- a/common/common-lang/src/main/java/com/twelvemonkeys/util/Time.java +++ b/common/common-lang/src/main/java/com/twelvemonkeys/util/Time.java @@ -129,8 +129,7 @@ public class Time { * @see #toString(String) */ public String toString() { - return "" + getMinutes() + ":" - + (getSeconds() < 10 ? "0" : "") + getSeconds(); + return getMinutes() + ":" + (getSeconds() < 10 ? "0" : "") + getSeconds(); } /** diff --git a/common/common-lang/src/main/java/com/twelvemonkeys/util/TimeFormat.java b/common/common-lang/src/main/java/com/twelvemonkeys/util/TimeFormat.java index 663cea5a..8b9ca532 100755 --- a/common/common-lang/src/main/java/com/twelvemonkeys/util/TimeFormat.java +++ b/common/common-lang/src/main/java/com/twelvemonkeys/util/TimeFormat.java @@ -44,12 +44,12 @@ import java.util.Vector; * The format is expressed in a string as follows: *
*
m (or any multiple of m's) - *
the minutes part (padded with 0's, if number has less digits than + *
the minutes part (padded with 0's, if number has less digits than * the number of m's) * m -> 0,1,...,59,60,61,... * mm -> 00,01,...,59,60,61,... *
s or ss - *
the seconds part (padded with 0's, if number has less digits than + *
the seconds part (padded with 0's, if number has less digits than * the number of s's) * s -> 0,1,...,59 * ss -> 00,01,...,59 @@ -62,7 +62,7 @@ import java.util.Vector; *

* Known bugs: *

- * The last character in the formatString is not escaped, while it should be. + * The last character in the formatString is not escaped, while it should be. * The first character after an escaped character is escaped while is shouldn't * be. *

@@ -81,15 +81,15 @@ public class TimeFormat extends Format { final static String SECOND = "s"; final static String TIME = "S"; final static String ESCAPE = "\\"; - + /** - * The default time format + * The default time format */ private final static TimeFormat DEFAULT_FORMAT = new TimeFormat("m:ss"); protected String formatString = null; - - /** + + /** * Main method for testing ONLY */ @@ -122,7 +122,7 @@ public class TimeFormat extends Format { } else time = new Time(); - + System.out.println("Time is \"" + out.format(time) + "\" according to format \"" + out.formatString + "\""); } @@ -147,18 +147,18 @@ public class TimeFormat extends Format { String previous = null; String current = null; int previousCount = 0; - + while (tok.hasMoreElements()) { current = tok.nextToken(); if (previous != null && previous.equals(ESCAPE)) { // Handle escaping of s, S or m - current = ((current != null) ? current : "") + current = ((current != null) ? current : "") + (tok.hasMoreElements() ? tok.nextToken() : ""); previous = null; previousCount = 0; } - + // Skip over first, // or if current is the same, increase count, and try again if (previous == null || previous.equals(current)) { @@ -173,12 +173,12 @@ public class TimeFormat extends Format { formatter.add(new SecondsFormatter(previousCount)); else if (previous.equals(TIME)) formatter.add(new SecondsFormatter(-1)); - else + else formatter.add(new TextFormatter(previous)); previousCount = 1; previous = current; - + } } @@ -197,7 +197,7 @@ public class TimeFormat extends Format { // Debug /* for (int i = 0; i < formatter.size(); i++) { - System.out.println("Formatter " + formatter.get(i).getClass() + System.out.println("Formatter " + formatter.get(i).getClass() + ": length=" + ((TimeFormatter) formatter.get(i)).digits); } */ @@ -206,7 +206,7 @@ public class TimeFormat extends Format { } - /** + /** * DUMMY IMPLEMENTATION!! * Not locale specific. */ @@ -259,9 +259,9 @@ public class TimeFormat extends Format { /** DUMMY IMPLEMENTATION!! */ public Object parseObject(String pStr, ParsePosition pStatus) { Time t = parse(pStr); - + pStatus.setIndex(pStr.length()); // Not 100% - + return t; } @@ -270,7 +270,7 @@ public class TimeFormat extends Format { *

* Will bug on some formats. It's safest to always use delimiters between * the minutes (m) and seconds (s) part. - * + * */ public Time parse(String pStr) { Time time = new Time(); @@ -286,7 +286,7 @@ public class TimeFormat extends Format { && (pos + skip < pStr.length()) ; i++) { // Go to next offset pos += skip; - + if (formatter[i] instanceof MinutesFormatter) { // Parse MINUTES if ((i + 1) < formatter.length @@ -327,9 +327,9 @@ public class TimeFormat extends Format { else { // Cannot possibly know how long? skip = 0; - continue; + continue; } - + // Get seconds sec = Integer.parseInt(pStr.substring(pos, skip)); // System.out.println("Only seconds: " + sec); @@ -343,7 +343,7 @@ public class TimeFormat extends Format { && formatter[i + 1] instanceof TextFormatter) { // Skip until next format element skip = pStr.indexOf(((TextFormatter) formatter[i + 1]).text, pos); - + } else if ((i + 1) >= formatter.length) { // Skip until end of string @@ -359,7 +359,7 @@ public class TimeFormat extends Format { else if (formatter[i] instanceof TextFormatter) { skip = formatter[i].digits; } - + } // Set the minutes part if we should @@ -390,7 +390,7 @@ class SecondsFormatter extends TimeFormatter { SecondsFormatter(int pDigits) { digits = pDigits; } - + String format(Time t) { // Negative number of digits, means all seconds, no padding if (digits < 0) { @@ -404,7 +404,7 @@ class SecondsFormatter extends TimeFormatter { // Else return it with leading 0's //return StringUtil.formatNumber(t.getSeconds(), digits); - return StringUtil.pad("" + t.getSeconds(), digits, "0", true); + return StringUtil.pad(String.valueOf(t.getSeconds()), digits, "0", true); } } @@ -425,7 +425,7 @@ class MinutesFormatter extends TimeFormatter { // Else return it with leading 0's //return StringUtil.formatNumber(t.getMinutes(), digits); - return StringUtil.pad("" + t.getMinutes(), digits, "0", true); + return StringUtil.pad(String.valueOf(t.getMinutes()), digits, "0", true); } } diff --git a/contrib/src/main/java/com/twelvemonkeys/contrib/tiff/TIFFUtilities.java b/contrib/src/main/java/com/twelvemonkeys/contrib/tiff/TIFFUtilities.java index d3d2e264..8dae71af 100644 --- a/contrib/src/main/java/com/twelvemonkeys/contrib/tiff/TIFFUtilities.java +++ b/contrib/src/main/java/com/twelvemonkeys/contrib/tiff/TIFFUtilities.java @@ -200,11 +200,10 @@ public final class TIFFUtilities { } public static List getPages(ImageInputStream imageInput) throws IOException { - ArrayList pages = new ArrayList(); - CompoundDirectory IFDs = (CompoundDirectory) new TIFFReader().read(imageInput); - int pageCount = IFDs.directoryCount(); + final int pageCount = IFDs.directoryCount(); + List pages = new ArrayList<>(pageCount); for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { pages.add(new TIFFPage(IFDs.getDirectory(pageIndex), imageInput)); } diff --git a/imageio/imageio-bmp/src/main/java/com/twelvemonkeys/imageio/plugins/bmp/DIBImageReader.java b/imageio/imageio-bmp/src/main/java/com/twelvemonkeys/imageio/plugins/bmp/DIBImageReader.java index 3e692dfe..7a678731 100644 --- a/imageio/imageio-bmp/src/main/java/com/twelvemonkeys/imageio/plugins/bmp/DIBImageReader.java +++ b/imageio/imageio-bmp/src/main/java/com/twelvemonkeys/imageio/plugins/bmp/DIBImageReader.java @@ -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); diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java index b4045d34..82dd331d 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java @@ -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) ); diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java index 9850a33e..a0fc21c3 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java @@ -144,7 +144,7 @@ public final class XMPReader extends MetadataReader { parseAttributesForKnownElements(subsubdirs, node); if (!subsubdirs.isEmpty()) { - List entries = new ArrayList(); + List entries = new ArrayList<>(subsubdirs.size()); for (Map.Entry> entry : subsubdirs.entrySet()) { entries.addAll(entry.getValue()); @@ -161,7 +161,7 @@ public final class XMPReader extends MetadataReader { } } - List entries = new ArrayList(); + List entries = new ArrayList(subdirs.size()); // TODO: Should we still allow asking for a subdirectory by item id? for (Map.Entry> entry : subdirs.entrySet()) { diff --git a/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReader.java b/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReader.java index 066ff541..d4cde16c 100644 --- a/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReader.java +++ b/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReader.java @@ -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); } diff --git a/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageMetadata.java b/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageMetadata.java index 823f90a4..dda6005c 100644 --- a/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageMetadata.java +++ b/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageMetadata.java @@ -1144,10 +1144,11 @@ public final class TIFFImageMetadata extends AbstractMetadata { throw new IIOInvalidTreeException("Expected \"TIFFIFD\" node", ifdNode); } - List entries = new ArrayList<>(); NodeList nodes = ifdNode.getChildNodes(); - for (int i = 0; i < nodes.getLength(); i++) { + final int size = nodes.getLength(); + List entries = new ArrayList<>(size); + for (int i = 0; i < size; i++) { entries.add(toEntry(nodes.item(i))); }