001: /* *************************************************************************
002:
003: Millstone(TM)
004: Open Sourced User Interface Library for
005: Internet Development with Java
006:
007: Millstone is a registered trademark of IT Mill Ltd
008: Copyright (C) 2000-2005 IT Mill Ltd
009:
010: *************************************************************************
011:
012: This library is free software; you can redistribute it and/or
013: modify it under the terms of the GNU Lesser General Public
014: license version 2.1 as published by the Free Software Foundation.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: *************************************************************************
026:
027: For more information, contact:
028:
029: IT Mill Ltd phone: +358 2 4802 7180
030: Ruukinkatu 2-4 fax: +358 2 4802 7181
031: 20540, Turku email: info@itmill.com
032: Finland company www: www.itmill.com
033:
034: Primary source for MillStone information and releases: www.millstone.org
035:
036: ********************************************************************** */
037:
038: package org.millstone.base.terminal;
039:
040: import org.millstone.base.service.FileTypeResolver;
041:
042: /** Theme resource is a named theme dependant resource provided and
043: * managed by a theme. The actual resource contents are dynamically
044: * resolved to comply with the used theme by the terminal adapter.
045: * This is commonly used to provide static images, flash,
046: * java-applets, etc for the terminals.
047: *
048: * @author IT Mill Ltd.
049: * @version 3.1.1
050: * @since 3.0
051: */
052: public class ThemeResource implements Resource {
053:
054: /** Id of the terminal managed resource. */
055: private String resourceID = null;
056:
057: /** Create a resource. */
058: public ThemeResource(String resourceId) {
059: if (resourceId == null)
060: throw new NullPointerException(
061: "Resource ID must not be null");
062: if (resourceId.length() == 0)
063: throw new IllegalArgumentException(
064: "Resource ID can not be empty");
065: if (resourceId.charAt(0) == '/')
066: throw new IllegalArgumentException(
067: "Resource ID must be relative (can not begin with /)");
068:
069: this .resourceID = resourceId;
070: }
071:
072: /** Tests if the given object equals this Resource.
073: *
074: * @param obj the object to be tested for equality
075: * @return <code>true</code> if the given object equals this Icon,
076: * <code>false</code> if not
077: * @see java.lang.Object#equals(Object)
078: */
079: public boolean equals(Object obj) {
080: return obj instanceof ThemeResource
081: && resourceID.equals(((ThemeResource) obj).resourceID);
082: }
083:
084: /** @see java.lang.Object#hashCode()
085: */
086: public int hashCode() {
087: return resourceID.hashCode();
088: }
089:
090: public String toString() {
091: return resourceID.toString();
092: }
093:
094: /** Get the resource id */
095: public String getResourceId() {
096: return resourceID;
097: }
098:
099: public String getMIMEType() {
100: return FileTypeResolver.getMIMEType(getResourceId());
101: }
102: }
|