1 package org.apache.turbine.services.mimetype;
2
3 /* ====================================================================
4 * The Apache Software License, Version 1.1
5 *
6 * Copyright (c) 2001 The Apache Software Foundation. All rights
7 * reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. The end-user documentation included with the redistribution,
22 * if any, must include the following acknowledgment:
23 * "This product includes software developed by the
24 * Apache Software Foundation (http://www.apache.org/)."
25 * Alternately, this acknowledgment may appear in the software itself,
26 * if and wherever such third-party acknowledgments normally appear.
27 *
28 * 4. The names "Apache" and "Apache Software Foundation" and
29 * "Apache Turbine" must not be used to endorse or promote products
30 * derived from this software without prior written permission. For
31 * written permission, please contact apache@apache.org.
32 *
33 * 5. Products derived from this software may not be called "Apache",
34 * "Apache Turbine", nor may "Apache" appear in their name, without
35 * prior written permission of the Apache Software Foundation.
36 *
37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This software consists of voluntary contributions made by many
52 * individuals on behalf of the Apache Software Foundation. For more
53 * information on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57 import java.io.File;
58 import java.util.Locale;
59
60 import org.apache.turbine.services.Service;
61 import org.apache.turbine.services.mimetype.util.MimeType;
62
63 /***
64 * The MimeType Service maintains mappings between MIME types and
65 * the corresponding file name extensions, and between locales and
66 * character encodings. The mappings are typically defined in
67 * properties or files located in user's home directory, Java home
68 * directory or the current class jar depending on the implementation.
69 *
70 * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
71 * @version $Id: MimeTypeService.java,v 1.1.1.1 2001/08/16 05:09:06 jvanzyl Exp $
72 */
73 public interface MimeTypeService extends Service
74 {
75 /***
76 * The name of the service.
77 */
78 public static final String SERVICE_NAME = "MimeTypeService";
79
80 /***
81 * Sets a MIME content type mapping to extensions to the map.
82 * The extension is specified by a MIME type name followed
83 * by a list of file name extensions separated by a whitespace.
84 *
85 * @param spec a MIME type extension specification to add.
86 */
87 public void setContentType(String spec);
88
89 /***
90 * Gets the MIME content type for a file as a string.
91 *
92 * @param file the file.
93 * @return the MIME type string.
94 */
95 public String getContentType(File file);
96
97 /***
98 * Gets the MIME content type for a named file as a string.
99 *
100 * @param name the name of the file.
101 * @return the MIME type string.
102 */
103 public String getContentType(String name);
104
105 /***
106 * Gets the MIME content type for a file name extension as a string.
107 *
108 * @param ext the file name extension.
109 * @param def the default type if none is found.
110 * @return the MIME type string.
111 */
112 public String getContentType(String ext,
113 String def);
114
115 /***
116 * Gets the MIME content type for a file.
117 *
118 * @param file the file.
119 * @return the MIME type.
120 */
121 public MimeType getMimeContentType(File file);
122
123 /***
124 * Gets the MIME content type for a named file.
125 *
126 * @param name the name of the file.
127 * @return the MIME type.
128 */
129 public MimeType getMimeContentType(String name);
130
131 /***
132 * Gets the MIME content type for a file name extension.
133 *
134 * @param ext the file name extension.
135 * @param def the default type if none is found.
136 * @return the MIME type.
137 */
138 public MimeType getMimeContentType(String ext,
139 String def);
140
141 /***
142 * Gets the default file name extension for a MIME type.
143 * Note that the mappers are called in the reverse order.
144 *
145 * @param type the MIME type as a string.
146 * @return the file name extension or null.
147 */
148 public String getDefaultExtension(String type);
149
150 /***
151 * Gets the default file name extension for a MIME type.
152 * Note that the mappers are called in the reverse order.
153 *
154 * @param mime the MIME type.
155 * @return the file name extension or null.
156 */
157 public String getDefaultExtension(MimeType mime);
158
159 /***
160 * Sets a locale-charset mapping.
161 *
162 * @param key the key for the charset.
163 * @param charset the corresponding charset.
164 */
165 public void setCharSet(String key,
166 String charset);
167
168 /***
169 * Gets the charset for a locale. First a locale specific charset
170 * is searched for, then a country specific one and lastly a language
171 * specific one. If none is found, the default charset is returned.
172 *
173 * @param locale the locale.
174 * @return the charset.
175 */
176 public String getCharSet(Locale locale);
177
178 /***
179 * Gets the charset for a locale with a variant. The search
180 * is performed in the following order:
181 * "lang"_"country"_"variant"="charset",
182 * _"counry"_"variant"="charset",
183 * "lang"__"variant"="charset",
184 * __"variant"="charset",
185 * "lang"_"country"="charset",
186 * _"country"="charset",
187 * "lang"="charset".
188 * If nothing of the above is found, the default charset is returned.
189 *
190 * @param locale the locale.
191 * @param variant a variant field.
192 * @return the charset.
193 */
194 public String getCharSet(Locale locale,
195 String variant);
196
197 /***
198 * Gets the charset for a specified key.
199 *
200 * @param key the key for the charset.
201 * @return the found charset or the default one.
202 */
203 public String getCharSet(String key);
204
205 /***
206 * Gets the charset for a specified key.
207 *
208 * @param key the key for the charset.
209 * @param def the default charset if none is found.
210 * @return the found charset or the given default.
211 */
212 public String getCharSet(String key,
213 String def);
214 }
This page was automatically generated by Maven