-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathImageFormat.java
More file actions
50 lines (37 loc) · 1.19 KB
/
ImageFormat.java
File metadata and controls
50 lines (37 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package nodebox.client;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
public final class ImageFormat {
public static final ImageFormat PDF = new ImageFormat("PDF", "pdf");
public static final ImageFormat PNG = new ImageFormat("PNG", "png");
private static final Map<String, ImageFormat> FORMAT_MAP;
static {
FORMAT_MAP = new HashMap<String, ImageFormat>();
FORMAT_MAP.put("PDF", PDF);
FORMAT_MAP.put("PNG", PNG);
}
public static ImageFormat of(String name) {
return FORMAT_MAP.get(name.toUpperCase());
}
private final String label;
private final String extension;
public ImageFormat(String label, String extension) {
this.label = label;
this.extension = extension;
}
public String getLabel() {
return label;
}
public String getExtension() {
return extension;
}
public File ensureFileExtension(File file) {
return new File(ensureFileExtension(file.getPath()));
}
public String ensureFileExtension(String file) {
if (file.endsWith("." + getExtension()))
return file;
return file + "." + getExtension();
}
}