1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import jalview.bin.Cache; |
24 |
|
import jalview.util.MessageManager; |
25 |
|
|
26 |
|
import java.util.HashMap; |
27 |
|
import java.util.Map; |
28 |
|
import java.util.StringTokenizer; |
29 |
|
|
|
|
| 91.2% |
Uncovered Elements: 6 (68) |
Complexity: 14 |
Complexity Density: 0.29 |
|
30 |
|
public class BackupFilesPresetEntry |
31 |
|
{ |
32 |
|
|
33 |
|
public String suffix; |
34 |
|
|
35 |
|
public static final int DIGITSMIN = 1; |
36 |
|
|
37 |
|
public static final int DIGITSMAX = 6; |
38 |
|
|
39 |
|
public int digits; |
40 |
|
|
41 |
|
public boolean reverse; |
42 |
|
|
43 |
|
public boolean keepAll; |
44 |
|
|
45 |
|
public static final int ROLLMAXMIN = 1; |
46 |
|
|
47 |
|
public static final int ROLLMAXMAX = 999; |
48 |
|
|
49 |
|
public int rollMax; |
50 |
|
|
51 |
|
public boolean confirmDelete; |
52 |
|
|
53 |
|
public static final String SAVEDCONFIG = BackupFiles.NS + "_SAVED"; |
54 |
|
|
55 |
|
public static final String CUSTOMCONFIG = BackupFiles.NS + "_CUSTOM"; |
56 |
|
|
57 |
|
private static final String stringDelim = "\t"; |
58 |
|
|
59 |
|
public static final int BACKUPFILESSCHEMECUSTOM = 0; |
60 |
|
|
61 |
|
public static final int BACKUPFILESSCHEMEDEFAULT = 1; |
62 |
|
|
|
|
| 81.2% |
Uncovered Elements: 3 (16) |
Complexity: 6 |
Complexity Density: 1 |
|
63 |
165 |
public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,... |
64 |
|
boolean keepAll, int rollMax, boolean confirmDelete) |
65 |
|
{ |
66 |
165 |
this.suffix = suffix == null ? "" : suffix; |
67 |
165 |
this.digits = digits < DIGITSMIN ? DIGITSMIN |
68 |
156 |
: (digits > DIGITSMAX ? DIGITSMAX : digits); |
69 |
165 |
this.reverse = reverse; |
70 |
165 |
this.keepAll = keepAll; |
71 |
165 |
this.rollMax = rollMax < ROLLMAXMIN ? ROLLMAXMIN |
72 |
156 |
: (rollMax > ROLLMAXMAX ? ROLLMAXMAX : rollMax); |
73 |
165 |
this.confirmDelete = confirmDelete; |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
0 |
public boolean equals(BackupFilesPresetEntry compare)... |
77 |
|
{ |
78 |
0 |
return suffix.equals(compare.suffix) && digits == compare.digits |
79 |
|
&& reverse == compare.reverse && keepAll == compare.keepAll |
80 |
|
&& rollMax == compare.rollMax |
81 |
|
&& confirmDelete == compare.confirmDelete; |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
84 |
4 |
@Override... |
85 |
|
public String toString() |
86 |
|
{ |
87 |
4 |
StringBuilder sb = new StringBuilder(); |
88 |
4 |
sb.append(suffix); |
89 |
4 |
sb.append(stringDelim); |
90 |
4 |
sb.append(digits); |
91 |
4 |
sb.append(stringDelim); |
92 |
4 |
sb.append(reverse); |
93 |
4 |
sb.append(stringDelim); |
94 |
4 |
sb.append(keepAll); |
95 |
4 |
sb.append(stringDelim); |
96 |
4 |
sb.append(rollMax); |
97 |
4 |
sb.append(stringDelim); |
98 |
4 |
sb.append(confirmDelete); |
99 |
4 |
return sb.toString(); |
100 |
|
} |
101 |
|
|
|
|
| 95% |
Uncovered Elements: 1 (20) |
Complexity: 3 |
Complexity Density: 0.17 |
|
102 |
140 |
public static BackupFilesPresetEntry createBackupFilesPresetEntry(... |
103 |
|
String line) |
104 |
|
{ |
105 |
140 |
if (line == null) |
106 |
|
{ |
107 |
24 |
return null; |
108 |
|
} |
109 |
116 |
StringTokenizer st = new StringTokenizer(line, stringDelim); |
110 |
116 |
String suffix = null; |
111 |
116 |
int digits = 0; |
112 |
116 |
boolean reverse = false; |
113 |
116 |
boolean keepAll = false; |
114 |
116 |
int rollMax = 0; |
115 |
116 |
boolean confirmDelete = false; |
116 |
|
|
117 |
116 |
try |
118 |
|
{ |
119 |
116 |
suffix = st.nextToken(); |
120 |
116 |
digits = Integer.valueOf(st.nextToken()); |
121 |
116 |
reverse = Boolean.valueOf(st.nextToken()); |
122 |
116 |
keepAll = Boolean.valueOf(st.nextToken()); |
123 |
116 |
rollMax = Integer.valueOf(st.nextToken()); |
124 |
116 |
confirmDelete = Boolean.valueOf(st.nextToken()); |
125 |
|
} catch (Exception e) |
126 |
|
{ |
127 |
0 |
Cache.log.error("Error parsing backupfiles scheme '" + line + "'"); |
128 |
|
} |
129 |
|
|
130 |
116 |
return new BackupFilesPresetEntry(suffix, digits, reverse, keepAll, |
131 |
|
rollMax, confirmDelete); |
132 |
|
} |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
134 |
140 |
public static BackupFilesPresetEntry getSavedBackupEntry()... |
135 |
|
{ |
136 |
140 |
String savedPresetString = Cache |
137 |
|
.getDefault(BackupFilesPresetEntry.SAVEDCONFIG, null); |
138 |
140 |
BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry |
139 |
|
.createBackupFilesPresetEntry(savedPresetString); |
140 |
140 |
if (savedPreset == null) |
141 |
|
{ |
142 |
24 |
savedPreset = backupfilesPresetEntriesValues |
143 |
|
.get(BACKUPFILESSCHEMEDEFAULT); |
144 |
|
} |
145 |
140 |
return savedPreset; |
146 |
|
} |
147 |
|
|
148 |
|
public static final IntKeyStringValueEntry[] backupfilesPresetEntries = { |
149 |
|
new IntKeyStringValueEntry(BACKUPFILESSCHEMEDEFAULT, |
150 |
|
MessageManager.getString("label.default")), |
151 |
|
new IntKeyStringValueEntry(2, |
152 |
|
MessageManager.getString("label.single_file")), |
153 |
|
new IntKeyStringValueEntry(3, |
154 |
|
MessageManager.getString("label.keep_all_versions")), |
155 |
|
new IntKeyStringValueEntry(4, |
156 |
|
MessageManager.getString("label.rolled_backups")), |
157 |
|
|
158 |
|
|
159 |
|
new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOM, |
160 |
|
MessageManager.getString("label.custom")) }; |
161 |
|
|
162 |
|
public static final String[] backupfilesPresetEntryDescriptions = { |
163 |
|
MessageManager.getString("label.default_description"), |
164 |
|
MessageManager.getString("label.single_file_description"), |
165 |
|
MessageManager.getString("label.keep_all_versions_description"), |
166 |
|
MessageManager.getString("label.rolled_backups_description"), |
167 |
|
MessageManager.getString("label.custom_description") }; |
168 |
|
|
169 |
|
public static final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>() |
170 |
|
{ |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
private static final long serialVersionUID = 125L; |
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
176 |
9 |
{... |
177 |
9 |
put(1, new BackupFilesPresetEntry( |
178 |
|
".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3, |
179 |
|
false)); |
180 |
9 |
put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false)); |
181 |
9 |
put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER, |
182 |
|
3, false, true, 10, true)); |
183 |
9 |
put(4, new BackupFilesPresetEntry( |
184 |
|
"_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9, |
185 |
|
false)); |
186 |
|
|
187 |
|
|
188 |
9 |
put(BACKUPFILESSCHEMECUSTOM, |
189 |
|
new BackupFilesPresetEntry("", 0, false, false, 0, false)); |
190 |
|
} |
191 |
|
}; |
192 |
|
|
193 |
|
} |