1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.vectomatic.common.format;
19
20 import java.util.HashMap;
21 import java.util.Map;
22
23
24
25
26 public class DrawingFormat {
27 public static final DrawingFormat SVG11 = new DrawingFormat("image/svg+xml", "svg11", ".svg");
28 public static final DrawingFormat SVG12 = new DrawingFormat("image/svg+xml", "svg12", ".svg");
29 public static final DrawingFormat PNG = new DrawingFormat("image/png", "png", ".png");
30 public static final DrawingFormat NATIVE = new DrawingFormat("text/xml", "native", ".xml");
31 private static Map<String, DrawingFormat> _descriptionToFormat;
32 static {
33 _descriptionToFormat = new HashMap<String, DrawingFormat>();
34 _descriptionToFormat.put(SVG11.getDescription(), SVG11);
35 _descriptionToFormat.put(SVG12.getDescription(), SVG12);
36 _descriptionToFormat.put(PNG.getDescription(), PNG);
37 _descriptionToFormat.put(NATIVE.getDescription(), NATIVE);
38 }
39 private String _mimeType;
40 private String _description;
41 private String _extension;
42
43 private DrawingFormat(String mimeType, String description, String extension) {
44 _mimeType = mimeType;
45 _description = description;
46 _extension = extension;
47 }
48 public static DrawingFormat fromDescription(String description) {
49 return description != null ? _descriptionToFormat.get(description) : null;
50 }
51 public String getMimeType() {
52 return _mimeType;
53 }
54 public String getDescription() {
55 return _description;
56 }
57 public String getExtension() {
58 return _extension;
59 }
60 }