From d8adec2097071b0dbde072641a9cfde5850e70ee Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 21 Jul 2010 14:26:16 +0000 Subject: fixes #5244, patch by posto svn changeset:14291/svn branch:6.4 --- src/com/vaadin/terminal/ExternalResource.java | 44 ++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/com/vaadin/terminal/ExternalResource.java b/src/com/vaadin/terminal/ExternalResource.java index c07adf7d9d..056b5b376e 100644 --- a/src/com/vaadin/terminal/ExternalResource.java +++ b/src/com/vaadin/terminal/ExternalResource.java @@ -19,6 +19,7 @@ import com.vaadin.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ExternalResource implements Resource, Serializable { /** @@ -26,6 +27,11 @@ public class ExternalResource implements Resource, Serializable { */ private String sourceURL = null; + /** + * MIME Type for the resource + */ + private String mimeType = null; + /** * Creates a new download component for downloading directly from given URL. * @@ -40,6 +46,19 @@ public class ExternalResource implements Resource, Serializable { this.sourceURL = sourceURL.toString(); } + /** + * Creates a new download component for downloading directly from given URL. + * + * @param sourceURL + * the source URL. + * @param mimeType + * the MIME Type + */ + public ExternalResource(URL sourceURL, String mimeType) { + this(sourceURL); + this.mimeType = mimeType; + } + /** * Creates a new download component for downloading directly from given URL. * @@ -54,6 +73,19 @@ public class ExternalResource implements Resource, Serializable { this.sourceURL = sourceURL.toString(); } + /** + * Creates a new download component for downloading directly from given URL. + * + * @param sourceURL + * the source URL. + * @param mimeType + * the MIME Type + */ + public ExternalResource(String sourceURL, String mimeType) { + this(sourceURL); + this.mimeType = mimeType; + } + /** * Gets the URL of the external resource. * @@ -69,7 +101,17 @@ public class ExternalResource implements Resource, Serializable { * @see com.vaadin.terminal.Resource#getMIMEType() */ public String getMIMEType() { - return FileTypeResolver.getMIMEType(getURL().toString()); + if (mimeType == null) { + mimeType = FileTypeResolver.getMIMEType(getURL().toString()); + } + return mimeType; + } + + /** + * Sets the MIME type of the resource. + */ + public void setMIMEType(String mimeType) { + this.mimeType = mimeType; } } -- cgit v1.2.3