You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
975 B

8 years ago
  1. /**
  2. * @license Highcharts JS v2.3.3 (2012-11-02)
  3. *
  4. * (c) 2012-2014
  5. *
  6. * Author: Gert Vaartjes
  7. *
  8. * License: www.highcharts.com/license
  9. */
  10. package com.highcharts.export.util;
  11. import java.util.EnumSet;
  12. import java.util.HashMap;
  13. import java.util.Map;
  14. public enum MimeType {
  15. PNG("image/png", "png"),
  16. JPEG("image/jpeg", "jpeg"),
  17. PDF("application/pdf", "pdf"),
  18. SVG("image/svg+xml", "svg");
  19. private static final Map<String, MimeType> lookup = new HashMap<>();
  20. static {
  21. for (MimeType m : EnumSet.allOf(MimeType.class)) {
  22. lookup.put(m.getType(), m);
  23. }
  24. }
  25. private String type;
  26. private String extension;
  27. private MimeType(String type, String extension) {
  28. this.type = type;
  29. this.extension = extension;
  30. }
  31. public String getType() {
  32. return type;
  33. }
  34. public String getExtension() {
  35. return extension;
  36. }
  37. public static MimeType get(String type) {
  38. MimeType mime = lookup.get(type);
  39. if (mime != null) {
  40. return mime;
  41. }
  42. return MimeType.PNG;
  43. }
  44. }