com.itmill.toolkit.terminal.web
Class Theme

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.itmill.toolkit.terminal.web.Theme
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class Theme
extends DefaultHandler

This class provides an interface to the meta-information regarding a particular theme. This entails for instanace the inheritance tree of the various xsl-template files, the different requirments that the theme imposes on the client browser, etc.

The WebAdapter uses themes to convert the UIDL description into client representation, typically HTML or XHTML. A theme consists of set of XSL template files which are used to perform XSL transform.

XSL files are divided into sets, which can have requirements. A file set is included in transformation only if the given requirements are met. Following requirements are supported:

Additionally following boolean operators may be applied to above requirements: The requirements are introduced in XML description file. See example below.

The theme description is XML data, and it can be loaded from file or stream. The default filename is specified by Theme.DESCRIPTIONFILE.

Since:
3.0
Version:
4.1.4
Author:
IT Mill Ltd.

Nested Class Summary
 class Theme.AgentRequirement
          HTTP user agent requirement This requirements is used to ensure that the User-Agent string provided in HTTP request headers contains given substring.
 class Theme.AndRequirement
          Logical AND requirement.
 class Theme.Author
          Author information class.
 class Theme.File
          Theme XSL file description Description of a single XSL file included a theme.
 class Theme.Fileset
          A recursive set of files sharing the same requirements.
 class Theme.JavaScriptRequirement
          Javascript version requirement This requirement is used to ensure a certain level of JavaScript version support.
 class Theme.MarkupLanguageRequirement
          Markup language version requirement.
 class Theme.NotRequirement
          Logical NOT requirement.
 class Theme.OrRequirement
          Logical OR requirement.
static interface Theme.Requirement
          Generic requirement.
static interface Theme.RequirementCollection
          Generic requirement collection interface.
 
Field Summary
static String DESCRIPTIONFILE
          Default description file name.
static String MESSAGE_CONFIGURE_HELP
           
static String MODE_AJAX
           
static String MODE_FALLBACK
           
static String MODE_HTML
           
 
Constructor Summary
Theme(File descriptionFile)
          Creates a new instance using XML description file.
Theme(InputStream descriptionStream)
          Creates a new instance using XML description stream.
 
Method Summary
 void characters(char[] data, int start, int length)
          Parses the character data in XML stream.
 void endElement(String namespaceURI, String localName, String qName)
          Parses the end tag in XML stream.
 Theme.Author getAuthor()
          Gets the author of this theme.
 String getDescription()
          Gets the theme description.
 List getFileNames()
          Gets the list of all files in this theme.
 List getFileNames(WebBrowser terminal, String mode)
          Gets the list of file names matching WebBrowserType.
 String getName()
          Gets the name of this theme.
 String getParent()
          Gets the name of the parent theme.
 String getPreferredMode(WebBrowser terminal, ThemeSource themeSource)
          Gets the preferred operating mode supported by this theme for given terminal.
 void startElement(String uri, String local, String qName, Attributes atts)
          Parses start tag in XML stream.
 boolean supportsMode(String mode, WebBrowser terminal, ThemeSource themeSource)
          Tests if this theme suppors given mode.
 String toString()
          String representation of Theme object.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DESCRIPTIONFILE

public static final String DESCRIPTIONFILE
Default description file name.

See Also:
Constant Field Values

MODE_AJAX

public static final String MODE_AJAX
See Also:
Constant Field Values

MODE_HTML

public static final String MODE_HTML
See Also:
Constant Field Values

MODE_FALLBACK

public static final String MODE_FALLBACK
See Also:
Constant Field Values

MESSAGE_CONFIGURE_HELP

public static final String MESSAGE_CONFIGURE_HELP
See Also:
Constant Field Values
Constructor Detail

Theme

public Theme(File descriptionFile)
      throws FileNotFoundException
Creates a new instance using XML description file. Instantiate new theme, by loading the description from given File.

Parameters:
descriptionFile - the Description file.
Throws:
FileNotFoundException - Thrown if the given file is not found.

Theme

public Theme(InputStream descriptionStream)
Creates a new instance using XML description stream. Instantiate new theme, by loading the description from given InputSource.

Parameters:
descriptionStream - the XML input to parse
Method Detail

getPreferredMode

public String getPreferredMode(WebBrowser terminal,
                               ThemeSource themeSource)
Gets the preferred operating mode supported by this theme for given terminal.

Parameters:
terminal - the type of the web browser.
themeSource -

supportsMode

public boolean supportsMode(String mode,
                            WebBrowser terminal,
                            ThemeSource themeSource)
Tests if this theme suppors given mode.

Parameters:
mode -
terminal - the type of the web browser.
themeSource -

startElement

public void startElement(String uri,
                         String local,
                         String qName,
                         Attributes atts)
Parses start tag in XML stream.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Parses the end tag in XML stream.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException
See Also:
ContentHandler.endElement(String, String, String)

characters

public void characters(char[] data,
                       int start,
                       int length)
Parses the character data in XML stream.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
See Also:
ContentHandler.characters(char[], int, int)

getFileNames

public List getFileNames()
Gets the list of all files in this theme.

Returns:
the List of filenames belonging to this theme.

getFileNames

public List getFileNames(WebBrowser terminal,
                         String mode)
Gets the list of file names matching WebBrowserType.

Parameters:
terminal - the type of the web browser.
mode -
Returns:
the list of filenames in this theme supporting the given terminal.

toString

public String toString()
String representation of Theme object. Used for debugging purposes only.

Overrides:
toString in class Object
See Also:
Object.toString()

getAuthor

public Theme.Author getAuthor()
Gets the author of this theme.

Returns:
the Author of the theme.

getName

public String getName()
Gets the name of this theme.

Returns:
the Name of the theme.

getParent

public String getParent()
Gets the name of the parent theme.

Returns:
the name of the parent theme.

getDescription

public String getDescription()
Gets the theme description.

Returns:
the theme description.


Copyright © 2000-2008 IT Mill Ltd. All Rights Reserved.