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