| 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.Locale; |
| 24 |
|
|
| 25 |
|
import java.util.ArrayList; |
| 26 |
|
import java.util.HashSet; |
| 27 |
|
import java.util.LinkedHashMap; |
| 28 |
|
import java.util.List; |
| 29 |
|
import java.util.Map; |
| 30 |
|
import java.util.Set; |
| 31 |
|
|
| 32 |
|
import jalview.bin.ApplicationSingletonProvider; |
| 33 |
|
import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
@author |
| 42 |
|
|
| 43 |
|
|
| |
|
| 0% |
Uncovered Elements: 50 (50) |
Complexity: 18 |
Complexity Density: 0.62 |
|
| 44 |
|
public class FileFormats implements ApplicationSingletonI |
| 45 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
0 |
public static FileFormats getInstance()... |
| 47 |
|
{ |
| 48 |
0 |
return ApplicationSingletonProvider.getInstance(FileFormats.class); |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 54 |
0 |
private FileFormats()... |
| 55 |
|
{ |
| 56 |
0 |
reset(); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
private Map<String, FileFormatI> formats; |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
private Set<FileFormatI> identifiable; |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 75 |
0 |
public synchronized void reset()... |
| 76 |
|
{ |
| 77 |
0 |
formats = new LinkedHashMap<String, FileFormatI>(); |
| 78 |
0 |
identifiable = new HashSet<FileFormatI>(); |
| 79 |
0 |
for (FileFormat format : FileFormat.values()) |
| 80 |
|
{ |
| 81 |
0 |
registerFileFormat(format, format.isIdentifiable()); |
| 82 |
|
} |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 89 |
0 |
public boolean isIdentifiable(FileFormatI f)... |
| 90 |
|
{ |
| 91 |
0 |
return identifiable.contains(f); |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
@param |
| 98 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 99 |
0 |
public void registerFileFormat(FileFormatI format)... |
| 100 |
|
{ |
| 101 |
0 |
boolean isIdentifiable = format instanceof FileFormat |
| 102 |
|
&& ((FileFormat) format).isIdentifiable(); |
| 103 |
0 |
registerFileFormat(format, isIdentifiable); |
| 104 |
|
} |
| 105 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 106 |
0 |
protected void registerFileFormat(FileFormatI format,... |
| 107 |
|
boolean isIdentifiable) |
| 108 |
|
{ |
| 109 |
0 |
String name = format.getName().toUpperCase(Locale.ROOT); |
| 110 |
0 |
if (formats.containsKey(name)) |
| 111 |
|
{ |
| 112 |
0 |
jalview.bin.Console |
| 113 |
|
.errPrintln("Overwriting file format: " + format.getName()); |
| 114 |
|
} |
| 115 |
0 |
formats.put(name, format); |
| 116 |
0 |
if (isIdentifiable) |
| 117 |
|
{ |
| 118 |
0 |
identifiable.add(format); |
| 119 |
|
} |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
@param |
| 126 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 127 |
0 |
public void deregisterFileFormat(String name)... |
| 128 |
|
{ |
| 129 |
0 |
FileFormatI ff = formats.remove(name.toUpperCase(Locale.ROOT)); |
| 130 |
0 |
identifiable.remove(ff); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
@param |
| 138 |
|
|
| 139 |
|
@return |
| 140 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 141 |
0 |
public List<String> getWritableFormats(boolean textOnly)... |
| 142 |
|
{ |
| 143 |
0 |
List<String> l = new ArrayList<String>(); |
| 144 |
0 |
for (FileFormatI ff : formats.values()) |
| 145 |
|
{ |
| 146 |
0 |
if (ff.isWritable() && (!textOnly || ff.isTextFormat())) |
| 147 |
|
{ |
| 148 |
0 |
l.add(ff.getName()); |
| 149 |
|
} |
| 150 |
|
} |
| 151 |
0 |
return l; |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
@return |
| 159 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 160 |
0 |
public List<String> getReadableFormats()... |
| 161 |
|
{ |
| 162 |
0 |
List<String> l = new ArrayList<String>(); |
| 163 |
0 |
for (FileFormatI ff : formats.values()) |
| 164 |
|
{ |
| 165 |
0 |
if (ff.isReadable()) |
| 166 |
|
{ |
| 167 |
0 |
l.add(ff.getName()); |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
0 |
return l; |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
@param |
| 178 |
|
@return |
| 179 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 180 |
0 |
public FileFormatI forName(String format)... |
| 181 |
|
{ |
| 182 |
0 |
return format == null ? null |
| 183 |
|
: formats.get(format.toUpperCase(Locale.ROOT)); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
@return |
| 191 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 192 |
0 |
public Iterable<FileFormatI> getFormats()... |
| 193 |
|
{ |
| 194 |
0 |
return formats.values(); |
| 195 |
|
} |
| 196 |
|
} |