View Javadoc
1   /*
2    * Copyright (c) 2002-2026 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.javascript.host;
16  
17  import org.htmlunit.javascript.HtmlUnitScriptable;
18  import org.htmlunit.javascript.configuration.JsxClass;
19  import org.htmlunit.javascript.configuration.JsxConstructor;
20  import org.htmlunit.javascript.configuration.JsxGetter;
21  
22  /**
23   * JavaScript host object for {@code MimeType}.
24   *
25   * @author Marc Guillemot
26   * @author Ahmed Ashour
27   * @author Ronald Brill
28   *
29   * @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/MimeType">MDN Documentation</a>
30   */
31  @JsxClass
32  public class MimeType extends HtmlUnitScriptable {
33  
34      private String description_;
35      private String suffixes_;
36      private String type_;
37      private Plugin enabledPlugin_;
38  
39      /**
40       * Creates an instance.
41       */
42      public MimeType() {
43          super();
44      }
45  
46      /**
47       * Creates an instance of this object.
48       */
49      @JsxConstructor
50      public void jsConstructor() {
51          // nothing to do
52      }
53  
54      /**
55       * Creates an instance with the given properties.
56       *
57       * @param type the MIME type string
58       * @param description the human-readable description
59       * @param suffixes the file suffixes associated with this MIME type
60       * @param plugin the plugin that handles this MIME type
61       */
62      public MimeType(final String type, final String description, final String suffixes, final Plugin plugin) {
63          super();
64          type_ = type;
65          description_ = description;
66          suffixes_ = suffixes;
67          enabledPlugin_ = plugin;
68      }
69  
70      /**
71       * Returns the MIME type's description.
72       *
73       * @return the description
74       */
75      @JsxGetter
76      public String getDescription() {
77          return description_;
78      }
79  
80      /**
81       * Returns the file suffixes associated with this MIME type.
82       *
83       * @return the suffixes
84       */
85      @JsxGetter
86      public String getSuffixes() {
87          return suffixes_;
88      }
89  
90      /**
91       * Returns the MIME type string.
92       *
93       * @return the MIME type
94       */
95      @JsxGetter
96      public String getType() {
97          return type_;
98      }
99  
100     /**
101      * Returns the plugin that handles this MIME type.
102      *
103      * @return the enabled plugin
104      */
105     @JsxGetter
106     public Plugin getEnabledPlugin() {
107         return enabledPlugin_;
108     }
109 }