You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by dl...@apache.org on 2004/04/13 19:51:30 UTC
cvs commit: jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/util MimeTypeMap.java
dlr 2004/04/13 10:51:30
Modified: mimetype/api/src/java/org/apache/fulcrum/mimetype
MimeTypeService.java
mimetype/impl/src/java/org/apache/fulcrum/mimetype
DefaultMimeTypeService.java
mimetype/impl/src/java/org/apache/fulcrum/mimetype/util
MimeTypeMap.java
Log:
Per John's recommendation, clarify the semantics of the
getContentType() method overloads.
* mimetype/impl/src/java/org/apache/fulcrum/mimetype/util/MimeTypeMap.java
getContentType(String, String): Changed the semantics so that this
method is clear about its operation on file names rather than
extensions already parsed from file names. Updated JavaDoc
accordingly.
getContentType(String): Updated to immediately delegate to the
getContentType(String, String) overload.
* mimetype/impl/src/java/org/apache/fulcrum/mimetype/DefaultMimeTypeService.java
* mimetype/api/src/java/org/apache/fulcrum/mimetype/MimeTypeService.java
getContentType(File), getContentType(String), getContentType(String,
String): JavaDoc updates.
Issue: CollabNet PCN27885
Reviewed by: John McNally <jm...@collab.net>
Revision Changes Path
1.2 +9 -8 jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype/MimeTypeService.java
Index: MimeTypeService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype/MimeTypeService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- MimeTypeService.java 13 Nov 2003 20:28:29 -0000 1.1
+++ MimeTypeService.java 13 Apr 2004 17:51:30 -0000 1.2
@@ -87,7 +87,7 @@
/**
* Gets the MIME content type for a file as a string.
*
- * @param file the file.
+ * @param file The file to look up a MIME type mapping for.
* @return the MIME type string.
*/
public String getContentType(File file);
@@ -95,20 +95,21 @@
/**
* Gets the MIME content type for a named file as a string.
*
- * @param name the name of the file.
+ * @param fileName The name of the file to look up a MIME type
+ * mapping for.
* @return the MIME type string.
*/
- public String getContentType(String name);
+ public String getContentType(String fileName);
/**
* Gets the MIME content type for a file name extension as a string.
*
- * @param ext the file name extension.
- * @param def the default type if none is found.
+ * @param fileName The name of the file to look up a MIME type
+ * mapping for.
+ * @param def The default MIME type to use if no mapping exists.
* @return the MIME type string.
*/
- public String getContentType(String ext,
- String def);
+ public String getContentType(String fileName, String def);
/**
* Gets the MIME content type for a file.
1.3 +11 -9 jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/DefaultMimeTypeService.java
Index: DefaultMimeTypeService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/DefaultMimeTypeService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -u -r1.2 -r1.3
--- DefaultMimeTypeService.java 14 Feb 2004 16:18:00 -0000 1.2
+++ DefaultMimeTypeService.java 13 Apr 2004 17:51:30 -0000 1.3
@@ -137,7 +137,7 @@
/**
* Gets the MIME content type for a file as a string.
*
- * @param file the file.
+ * @param file The file to look up a MIME type mapping for.
* @return the MIME type string.
*/
public String getContentType(File file)
@@ -147,23 +147,25 @@
/**
* Gets the MIME content type for a named file as a string.
*
- * @param name the name of the file.
+ * @param fileName The name of the file to look up a MIME type
+ * mapping for.
* @return the MIME type string.
*/
- public String getContentType(String name)
+ public String getContentType(String fileName)
{
- return mimeTypeMap.getContentType(name);
+ return mimeTypeMap.getContentType(fileName);
}
/**
* Gets the MIME content type for a file name extension as a string.
*
- * @param ext the file name extension.
- * @param def the default type if none is found.
+ * @param fileName The name of the file to look up a MIME type
+ * mapping for.
+ * @param def The default MIME type to use if no mapping exists.
* @return the MIME type string.
*/
- public String getContentType(String ext, String def)
+ public String getContentType(String fileName, String def)
{
- return mimeTypeMap.getContentType(ext, def);
+ return mimeTypeMap.getContentType(fileName, def);
}
/**
* Gets the MIME content type for a file.
1.3 +19 -23 jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/util/MimeTypeMap.java
Index: MimeTypeMap.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/util/MimeTypeMap.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -u -r1.2 -r1.3
--- MimeTypeMap.java 13 Apr 2004 02:24:07 -0000 1.2
+++ MimeTypeMap.java 13 Apr 2004 17:51:30 -0000 1.3
@@ -291,40 +291,36 @@
* mapping for.
* @return The MIME type, or {@link #DEFAULT_TYPE} if unmapped.
*/
- public String getContentType(String name)
+ public String getContentType(String fileName)
{
- String ext = parseFileExtension(name);
- return ext != null ? getContentType(ext, DEFAULT_TYPE) : DEFAULT_TYPE;
+ return getContentType(fileName, DEFAULT_TYPE);
}
/**
* Gets the MIME content type for a file name extension as a string.
*
- * @param ext The file name extension.
- * @param def The default content type to use, if no mapping exists.
+ * @param fileName The name of the file to look up a MIME type
+ * mapping for.
+ * @param def The default MIME type to use if no mapping exists.
* @return The MIME type, or <code>def</code> if unmapped.
*/
- public String getContentType(String ext, String def)
+ public String getContentType(String fileName, String def)
{
- // ### Why do this when we should already have the file
- // ### extension?
- String e = parseFileExtension(ext);
- if (e != null)
+ String ext = parseFileExtension(fileName);
+ if (ext != null)
{
- ext = e;
- }
-
- String mimeType;
- MimeTypeMapper mapper;
- for (int i = 0; i < mappers.length; i++)
- {
- mapper = mappers[i];
- if (mapper != null)
+ String mimeType;
+ MimeTypeMapper mapper;
+ for (int i = 0; i < mappers.length; i++)
{
- mimeType = mapper.getContentType(ext);
- if (mimeType != null)
+ mapper = mappers[i];
+ if (mapper != null)
{
- return mimeType;
+ mimeType = mapper.getContentType(ext);
+ if (mimeType != null)
+ {
+ return mimeType;
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org