/plugins/email/ext/src/activation-1.1.1/source/javax/activation/FileTypeMap.java

https://github.com/srnsw/xena · Java · 97 lines · 36 code · 11 blank · 50 comment · 7 complexity · de91ff452ca6563ee34b6809c058b327 MD5 · raw file

  1. /*
  2. * FileTypeMap.java
  3. * Copyright (C) 2004 The Free Software Foundation
  4. *
  5. * This file is part of GNU Java Activation Framework (JAF), a library.
  6. *
  7. * GNU JAF is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * GNU JAF is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * As a special exception, if you link this library with other files to
  22. * produce an executable, this library does not by itself cause the
  23. * resulting executable to be covered by the GNU General Public License.
  24. * This exception does not however invalidate any other reasons why the
  25. * executable file might be covered by the GNU General Public License.
  26. */
  27. package javax.activation;
  28. import java.io.File;
  29. /**
  30. * Classifier for the MIME content type of files.
  31. *
  32. * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
  33. * @version 1.1
  34. */
  35. public abstract class FileTypeMap
  36. {
  37. /* Class scope */
  38. private static FileTypeMap defaultMap;
  39. /**
  40. * Returns the system default file type map.
  41. * If one has not been set, this returns a MimetypesFileTypeMap.
  42. */
  43. public static FileTypeMap getDefaultFileTypeMap()
  44. {
  45. if (defaultMap == null)
  46. {
  47. defaultMap = new MimetypesFileTypeMap();
  48. }
  49. return defaultMap;
  50. }
  51. /**
  52. * Sets the default file type map.
  53. * @param map the new file type map
  54. */
  55. public static void setDefaultFileTypeMap(FileTypeMap map)
  56. {
  57. SecurityManager security = System.getSecurityManager();
  58. if (security != null)
  59. {
  60. try
  61. {
  62. security.checkSetFactory();
  63. }
  64. catch (SecurityException e)
  65. {
  66. if (map != null && FileTypeMap.class.getClassLoader() !=
  67. map.getClass().getClassLoader())
  68. {
  69. throw e;
  70. }
  71. }
  72. }
  73. defaultMap = map;
  74. }
  75. /* Instance scope */
  76. /**
  77. * Returns the content type of the specified file.
  78. * @param file the file to classify
  79. */
  80. public abstract String getContentType(File file);
  81. /**
  82. * Returns the content type of the specified file path.
  83. * @param filename the path of the file to classify
  84. */
  85. public abstract String getContentType(String filename);
  86. }