01: /* *************************************************************************
02:
03: Millstone(TM)
04: Open Sourced User Interface Library for
05: Internet Development with Java
06:
07: Millstone is a registered trademark of IT Mill Ltd
08: Copyright (C) 2000-2005 IT Mill Ltd
09:
10: *************************************************************************
11:
12: This library is free software; you can redistribute it and/or
13: modify it under the terms of the GNU Lesser General Public
14: license version 2.1 as published by the Free Software Foundation.
15:
16: This library is distributed in the hope that it will be useful,
17: but WITHOUT ANY WARRANTY; without even the implied warranty of
18: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19: Lesser General Public License for more details.
20:
21: You should have received a copy of the GNU Lesser General Public
22: License along with this library; if not, write to the Free Software
23: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24:
25: *************************************************************************
26:
27: For more information, contact:
28:
29: IT Mill Ltd phone: +358 2 4802 7180
30: Ruukinkatu 2-4 fax: +358 2 4802 7181
31: 20540, Turku email: info@itmill.com
32: Finland company www: www.itmill.com
33:
34: Primary source for MillStone information and releases: www.millstone.org
35:
36: ********************************************************************** */
37:
38: package org.millstone.base.terminal;
39:
40: import java.net.URL;
41:
42: import org.millstone.base.service.FileTypeResolver;
43:
44: /** External resource implements source for resources fetched from
45: * location specified by URL:s. The resources are fetched directly by the
46: * client terminal and are not fetched trough the terminal adapter.
47: *
48: * @author IT Mill Ltd.
49: * @version 3.1.1
50: * @since 3.0
51: */
52: public class ExternalResource implements Resource {
53:
54: /** Url of the download */
55: private String sourceURL = null;
56:
57: /** Create new download component for downloading directly from given URL.
58: * */
59: public ExternalResource(URL sourceURL) {
60: if (sourceURL == null)
61: throw new RuntimeException("Source must be non-null");
62:
63: this .sourceURL = sourceURL.toString();
64: }
65:
66: /** Create new download component for downloading directly from given URL.
67: * */
68: public ExternalResource(String sourceURL) {
69: if (sourceURL == null)
70: throw new RuntimeException("Source must be non-null");
71:
72: this .sourceURL = sourceURL.toString();
73: }
74:
75: /** Get the URL of the external resource */
76: public String getURL() {
77: return sourceURL;
78: }
79:
80: public String getMIMEType() {
81: return FileTypeResolver.getMIMEType(getURL().toString());
82: }
83:
84: }
|