1 /*
2 * Copyright (c) 2002-2025 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 * A JavaScript 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">MimeType</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 * JavaScript constructor.
48 */
49 @JsxConstructor
50 public void jsConstructor() {
51 // nothing to do
52 }
53
54 /**
55 * Constructor initializing fields.
56 * @param type the mime type
57 * @param description the type description
58 * @param suffixes the file suffixes
59 * @param plugin the associated plugin
60 */
61 public MimeType(final String type, final String description, final String suffixes, final Plugin plugin) {
62 super();
63 type_ = type;
64 description_ = description;
65 suffixes_ = suffixes;
66 enabledPlugin_ = plugin;
67 }
68
69 /**
70 * Returns the mime type's description.
71 * @return the description
72 */
73 @JsxGetter
74 public String getDescription() {
75 return description_;
76 }
77
78 /**
79 * Returns the mime type's suffixes.
80 * @return the suffixes
81 */
82 @JsxGetter
83 public String getSuffixes() {
84 return suffixes_;
85 }
86
87 /**
88 * Returns the mime type's suffixes.
89 * @return the suffixes
90 */
91 @JsxGetter
92 public String getType() {
93 return type_;
94 }
95
96 /**
97 * Returns the mime type's associated plugin.
98 * @return the plugin
99 */
100 @JsxGetter
101 public Plugin getEnabledPlugin() {
102 return enabledPlugin_;
103 }
104 }