mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-02 02:55:28 -04:00
Intellij suggested changes from static code analysis.
This commit is contained in:
parent
b6773f6983
commit
aff31ebd1b
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,12 +44,12 @@ import java.util.Vector;
|
||||
* The format is expressed in a string as follows:
|
||||
* <DL>
|
||||
* <DD>m (or any multiple of m's)
|
||||
* <DT>the minutes part (padded with 0's, if number has less digits than
|
||||
* <DT>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,...
|
||||
* <DD>s or ss
|
||||
* <DT>the seconds part (padded with 0's, if number has less digits than
|
||||
* <DT>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;
|
||||
* <P>
|
||||
* Known bugs:
|
||||
* <P>
|
||||
* 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.
|
||||
* <P>
|
||||
@ -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 {
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,11 +200,10 @@ public final class TIFFUtilities {
|
||||
}
|
||||
|
||||
public static List<TIFFPage> getPages(ImageInputStream imageInput) throws IOException {
|
||||
ArrayList<TIFFPage> pages = new ArrayList<TIFFPage>();
|
||||
|
||||
CompoundDirectory IFDs = (CompoundDirectory) new TIFFReader().read(imageInput);
|
||||
|
||||
int pageCount = IFDs.directoryCount();
|
||||
final int pageCount = IFDs.directoryCount();
|
||||
List<TIFFPage> pages = new ArrayList<>(pageCount);
|
||||
for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) {
|
||||
pages.add(new TIFFPage(IFDs.getDirectory(pageIndex), imageInput));
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user