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.webadapter;
039:
040: import java.io.InputStream;
041: import java.util.Collection;
042:
043: /** Interface implemented by theme sources.
044: * @author IT Mill Ltd.
045: * @version 3.1.1
046: * @since 3.0
047: */
048: public interface ThemeSource {
049:
050: /** Get the name of the ThemeSource.
051: * @return Name of the theme source.
052: */
053: public String getName();
054:
055: /** Get XSL stream for the specified theme and web-browser type.
056: * Returns the XSL templates, which are used to process the
057: * UIDL data. The <code>type</code> parameter is used to limit
058: * the templates, which are returned based on the theme fileset
059: * requirements.
060: * @param theme Theme, which XSL should be returned
061: * @param type The type of the current client.
062: * @return Collection of ThemeSource.XSLStream objects.
063: * @see Theme
064: */
065: public Collection getXSLStreams(Theme theme, WebBrowser type)
066: throws ThemeException;
067:
068: /** Get the last modification time, used to reload theme on changes.
069: * @return Last modification time of the theme source.
070: */
071: public long getModificationTime();
072:
073: /** Get input stream for the resource with the specified resource id.
074: * @return Stream where the resource can be read.
075: * @throws ThemeException If the resource is not found or there was
076: * some problem finding the resource.
077: */
078: public InputStream getResource(String resourceId)
079: throws ThemeException;
080:
081: /** Get list of themes in the theme source.
082: * @return List of themes included in the theme source.
083: */
084: public Collection getThemes();
085:
086: /** Return Theme instance by name.
087: * @param name Theme name.
088: * @return Theme instance matching the name, or null if not found.
089: */
090: public Theme getThemeByName(String name);
091:
092: /** Theme exception.
093: * Thrown by classes implementing the ThemeSource interface
094: * if some error occurs during processing.
095: * @author IT Mill Ltd.
096: * @version 3.1.1
097: * @since 3.0
098: */
099: public class ThemeException extends Exception {
100:
101: /** Create new theme exception.
102: * @param description Error message.
103: */
104: public ThemeException(String description) {
105: super (description);
106: }
107: }
108:
109: /** Wrapper class for XSL InputStreams */
110: public class XSLStream {
111: private String id;
112: private InputStream stream;
113:
114: public XSLStream(String id, InputStream stream) {
115: this .id = id;
116: this .stream = stream;
117: }
118:
119: /** Return id of this stream.
120: * @return
121: */
122: public String getId() {
123: return id;
124: }
125:
126: /** Return the actual XSL Stream.
127: * @return
128: */
129: public InputStream getStream() {
130: return stream;
131: }
132:
133: }
134: }
|