diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-07-21 14:26:16 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-07-21 14:26:16 +0000 |
commit | d8adec2097071b0dbde072641a9cfde5850e70ee (patch) | |
tree | 4988b85ecc2d9951ed0d44fc042217f79a70bbc6 | |
parent | 14f0506bf38369cd72bbbe41faa14de22da86ced (diff) | |
download | vaadin-framework-d8adec2097071b0dbde072641a9cfde5850e70ee.tar.gz vaadin-framework-d8adec2097071b0dbde072641a9cfde5850e70ee.zip |
fixes #5244, patch by posto
svn changeset:14291/svn branch:6.4
-rw-r--r-- | src/com/vaadin/terminal/ExternalResource.java | 44 |
1 files changed, 43 insertions, 1 deletions
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 { /** @@ -27,6 +28,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. * * @param sourceURL @@ -45,6 +51,19 @@ public class ExternalResource implements Resource, Serializable { * * @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. + * + * @param sourceURL + * the source URL. */ public ExternalResource(String sourceURL) { if (sourceURL == null) { @@ -55,6 +74,19 @@ public class ExternalResource implements Resource, Serializable { } /** + * 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. * * @return 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; } } |