org.apache.myfaces.trinidadinternal.style.cache
Class FileSystemStyleCache

java.lang.Object
  extended by org.apache.myfaces.trinidadinternal.style.cache.FileSystemStyleCache
All Implemented Interfaces:
StyleProvider
Direct Known Subclasses:
SkinStyleProvider

public class FileSystemStyleCache
extends java.lang.Object
implements StyleProvider

The FileSystemStyleCache is a StyleProvider implementation which caches generated CSS style sheets on the file system. A FileSystemStyleCache object is for one Skin. The FileSystemStyleCache instance contains Entry objects for a Skin: one Entry object per unique generated CSS style sheet (e.g., gecko and ie will most likely have different generated CSS style sheets for the same Skin because these browsers tend to need different css rules). Note that StyleProviders are responsible for providing access both to style information (eg. getStyleSheetURI(), getStyles()) as well as to icons registered via style sheets (see getIcons()).

Version:
$Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/style/cache/FileSystemStyleCache.java#0 $) $Date: 10-nov-2005.18:58:54 $
See Also:
StyleProvider, SkinStyleProvider

Constructor Summary
protected FileSystemStyleCache(java.lang.String target)
          Creates a FileSystemStyleCache.
 
Method Summary
 org.apache.myfaces.trinidad.style.Style _convertStyleNodeToStyle(StyleNode styleNode, java.util.Map<org.apache.myfaces.trinidad.style.Style,org.apache.myfaces.trinidad.style.Style> reusableStyleMap)
          Given a StyleNode object, which is an internal API that denotes a Style object with additional information like includedSelectors, create a simple public Style object which will be used in the SelectorStyleMap.
protected  StyleSheetDocument createStyleSheetDocument(StyleContext context)
          Creates the StyleSheetDocument for this StyleProvider.
 java.lang.String getContentStyleType(StyleContext context)
          Returns the mime type for the styles provided by this FileSystemStyleCache - "text/css".
 java.util.concurrent.ConcurrentMap<java.lang.String,org.apache.myfaces.trinidad.skin.Icon> getIcons(StyleContext context)
          Implementation of StyleProvider.getIcons()
 java.util.Map<java.lang.String,java.lang.String> getShortStyleClasses(StyleContext context)
          Returns a Map which maps style class names to equivalent shorter names.
 java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> getSkinProperties(StyleContext context)
          Implementation of StyleProvider.getSkinProperties()
 org.apache.myfaces.trinidad.style.Styles getStyles(StyleContext context)
          Implementation of StyleProvider.getStyles().
 java.util.List<java.lang.String> getStyleSheetURIs(StyleContext context)
          Implementation of StyleCache.getStyleSheetURI().
protected  java.lang.String getTargetStyleSheetName(StyleContext context, StyleSheetDocument document)
          Returns the name to use for the generated style sheet file .
protected  boolean hasSourceDocumentChanged(StyleContext context)
          Tests whether the source style sheet files have been modified since the last call to createStyleSheetDocument().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemStyleCache

protected FileSystemStyleCache(java.lang.String target)
Creates a FileSystemStyleCache.

Parameters:
target - The path of the target directory. Generated CSS files are stored in this directory. If the directory does not exist and can not be created, an IllegalArgumentException is thrown.
See Also:
- the subclass
Method Detail

getContentStyleType

public java.lang.String getContentStyleType(StyleContext context)
Returns the mime type for the styles provided by this FileSystemStyleCache - "text/css".

Specified by:
getContentStyleType in interface StyleProvider

getStyleSheetURIs

public java.util.List<java.lang.String> getStyleSheetURIs(StyleContext context)
Implementation of StyleCache.getStyleSheetURI().

Specified by:
getStyleSheetURIs in interface StyleProvider
Parameters:
context - The context which describes the end user environment for this request
Returns:
A list of CSS style sheet URIs

getStyles

public org.apache.myfaces.trinidad.style.Styles getStyles(StyleContext context)
Implementation of StyleProvider.getStyles().

Specified by:
getStyles in interface StyleProvider
Returns:

getSkinProperties

public java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> getSkinProperties(StyleContext context)
Implementation of StyleProvider.getSkinProperties()

Specified by:
getSkinProperties in interface StyleProvider
Parameters:
context - The context which describes the target end user environment
Returns:
A ConcurrentMap which exposes the skin properties for the specified context.

getIcons

public java.util.concurrent.ConcurrentMap<java.lang.String,org.apache.myfaces.trinidad.skin.Icon> getIcons(StyleContext context)
Implementation of StyleProvider.getIcons()

Specified by:
getIcons in interface StyleProvider
Parameters:
context - The context which describes the target end user environment
Returns:
A ConcurrentMap which exposes the Icons for the specified context.

getShortStyleClasses

public java.util.Map<java.lang.String,java.lang.String> getShortStyleClasses(StyleContext context)
Returns a Map which maps style class names to equivalent shorter names.

FileSystemStyleCache automatically generates short versions of every style class that is found the the underlying XSS document. FileSystemStyleCache clients can reduce the size of generated content by using this method to obtain short versions of any rendered style classes.

Note: The returned Map uses String keys to represent the full class names. However, the short style class values may not necessarily be type java.lang.String. Clients must avoid explicitly casting the values contained in the Map to type String. Instead, such values should be passed directly to the ResponseWriter API to be rendered. Or, if the String representation is required, toString() should be called on the value.

Specified by:
getShortStyleClasses in interface StyleProvider
Parameters:
context - The StyleContext
Returns:
A Map which maps the full style class names to the shorter equivalents.

createStyleSheetDocument

protected StyleSheetDocument createStyleSheetDocument(StyleContext context)
Creates the StyleSheetDocument for this StyleProvider.

Parameters:
context - The StyleContext (not needed here, but is needed in subclass)
Returns:
The StyleSheetDocument which defines the styles for this StyleProvider.
See Also:
org.apache.myfaces.trinidadinternal.skin.SkinStyleProvider#createStyleSheetDocument(context)

hasSourceDocumentChanged

protected boolean hasSourceDocumentChanged(StyleContext context)
Tests whether the source style sheet files have been modified since the last call to createStyleSheetDocument().

Returns:
true if the underlying source style sheets have been modified, false otherwise.

getTargetStyleSheetName

protected java.lang.String getTargetStyleSheetName(StyleContext context,
                                                   StyleSheetDocument document)
Returns the name to use for the generated style sheet file .

Parameters:
context - The StyleContext
document - The StyleSheetDocument which provides the styles

_convertStyleNodeToStyle

public org.apache.myfaces.trinidad.style.Style _convertStyleNodeToStyle(StyleNode styleNode,
                                                                        java.util.Map<org.apache.myfaces.trinidad.style.Style,org.apache.myfaces.trinidad.style.Style> reusableStyleMap)
Given a StyleNode object, which is an internal API that denotes a Style object with additional information like includedSelectors, create a simple public Style object which will be used in the SelectorStyleMap. When this method is called, the StyleNode object is already resolved (included selectors have been merged in) so that all the css properties are there.

Parameters:
styleNode -
reusableStyleMap - A Map. This is used so that we can reuse Style objects in StylesImpl if they have the same list of style property names and values.
Returns:
A Style object created from the information in the styleNode. We reuse Style objects if the properties are the same.


Copyright © 2001-2011 The Apache Software Foundation. All Rights Reserved.