git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-3141 Reformatted code in eclipse
[jalview.git]
/
src
/
jalview
/
io
/
BackupFilenameParts.java
diff --git
a/src/jalview/io/BackupFilenameParts.java
b/src/jalview/io/BackupFilenameParts.java
index
93aa602
..
6f7da93
100644
(file)
--- a/
src/jalview/io/BackupFilenameParts.java
+++ b/
src/jalview/io/BackupFilenameParts.java
@@
-16,27
+16,19
@@
public class BackupFilenameParts
boolean isBackupFile;
boolean isBackupFile;
- public BackupFilenameParts(File file, String base, String template, int digits)
+ public BackupFilenameParts(File file, String base, String template,
+ int digits)
{
this(file.getName(), base, template, digits);
}
public BackupFilenameParts(String filename, String base, String template,
{
this(file.getName(), base, template, digits);
}
public BackupFilenameParts(String filename, String base, String template,
- int digits)
+ int suggesteddigits)
{
this.isBackupFile = false;
{
this.isBackupFile = false;
- // calculate minimum length of a backup filename
- int minlength = base.length() + template.length()
- - BackupFiles.NUM_PLACEHOLDER.length() + digits ;
-
- if (!(filename.startsWith(base) && filename.length() >= minlength))
- {
- // non-starter
- return;
- }
-
int numcharstart = template.indexOf(BackupFiles.NUM_PLACEHOLDER);
int numcharstart = template.indexOf(BackupFiles.NUM_PLACEHOLDER);
+ int digits = 0;
String templateStart = template;
String templateEnd = "";
if (numcharstart > -1)
String templateStart = template;
String templateEnd = "";
if (numcharstart > -1)
@@
-44,27
+36,38
@@
public class BackupFilenameParts
templateStart = template.substring(0, numcharstart);
templateEnd = template.substring(
numcharstart + BackupFiles.NUM_PLACEHOLDER.length());
templateStart = template.substring(0, numcharstart);
templateEnd = template.substring(
numcharstart + BackupFiles.NUM_PLACEHOLDER.length());
+ digits = suggesteddigits;
}
}
-
+
+ // calculate minimum length of a backup filename
+ int minlength = base.length() + template.length()
+ - BackupFiles.NUM_PLACEHOLDER.length() + digits;
+
+ if (!(filename.startsWith(base) && filename.length() >= minlength))
+ {
+ // non-starter
+ return;
+ }
+
int startLength = base.length() + templateStart.length();
int endLength = templateEnd.length();
int startLength = base.length() + templateStart.length();
int endLength = templateEnd.length();
- String numString = filename.substring(startLength,
- filename.length() - endLength);
+ String numString = numcharstart > -1
+ ? filename.substring(startLength, filename.length() - endLength)
+ : "";
if (filename.length() >= startLength + digits + endLength
&& filename.startsWith(base + templateStart)
&& filename.endsWith(templateEnd)
if (filename.length() >= startLength + digits + endLength
&& filename.startsWith(base + templateStart)
&& filename.endsWith(templateEnd)
- && numString.matches("[0-9]+"))
+ && numString.matches("[0-9]*"))
{
this.base = base;
this.templateStart = templateStart;
{
this.base = base;
this.templateStart = templateStart;
- this.num = Integer.parseInt(numString);
+ this.num = numString.length() > 0 ? Integer.parseInt(numString) : 0;
this.digits = digits;
this.digits = digits;
- this.templateStart = templateStart;
this.templateEnd = templateEnd;
this.isBackupFile = true;
}
this.templateEnd = templateEnd;
this.isBackupFile = true;
}
-
+
}
public boolean isBackupFile()
}
public boolean isBackupFile()