org.apache.myfaces.trinidadinternal.skin
Class SkinImpl

java.lang.Object
  extended by org.apache.myfaces.trinidad.skin.Skin
      extended by org.apache.myfaces.trinidadinternal.skin.SkinImpl
All Implemented Interfaces:
DocumentProviderSkin
Direct Known Subclasses:
BaseSkin, SkinExtension, SkinNotAvailable

public abstract class SkinImpl
extends org.apache.myfaces.trinidad.skin.Skin
implements DocumentProviderSkin

Defines the components (icons, styles, etc) which are used to implement a particular skin. This implementation class adds the details that should not be exposed outside of this API.

Version:
$Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/skin/Skin.java#0 $) $Date: 10-nov-2005.18:58:54 $
See Also:
SkinFactory, org.apache.myfaces.trinidadinternal.ui.UIXRenderingContext#getSkinFactory

Constructor Summary
SkinImpl()
           
 
Method Summary
 void addSkinAddition(org.apache.myfaces.trinidad.skin.SkinAddition skinAddition)
          Adds a SkinAddition on this Skin.
protected abstract  java.lang.String getBundleName()
          Returns the name of the ResourceBundle for this Skin instance.
protected  java.lang.Object getCachedTranslatedValue(org.apache.myfaces.trinidad.context.LocaleContext lContext, java.lang.String key)
          Returns a translated value in the LocaleContext's translation Locale, or null if the key could not be found.
 java.lang.String getFamily()
          Returns the name of the skin "family" for this skin.
 org.apache.myfaces.trinidad.skin.Icon getIcon(java.lang.String iconName)
          Our renderers call this to get the icon.
 org.apache.myfaces.trinidad.skin.Icon getIcon(java.lang.String iconName, boolean resolveIcon)
          Returns an Icon object; can be a ReferenceIcon.
 java.lang.String getId()
          Returns an string identifier which uniquely identies this Skin implementation.
 java.lang.Object getProperty(java.lang.Object key)
          Retrieves a property that was set via a call to setProperty().
 java.lang.String getRenderKitId()
          Returns the renderKitId for the Skin.
 java.util.List<org.apache.myfaces.trinidad.skin.SkinAddition> getSkinAdditions()
          Gets an unmodifiable List of SkinAdditions that have been added on this Skin.
 java.util.Map<java.lang.String,java.lang.String> getStyleClassMap(org.apache.myfaces.trinidad.context.RenderingContext arc)
          Returns the style class map, or null if there is no map.
 StyleSheetDocument getStyleSheetDocument(StyleContext context)
          Returns the StyleSheetDocument object which defines all of the styles for this Skin, including any styles that are contributed by skin-additions.
 java.lang.String getStyleSheetDocumentId(org.apache.myfaces.trinidad.context.RenderingContext arc)
          Returns the id of the Skin's stylesheet document.
abstract  java.lang.String getStyleSheetName()
          Returns the name of the style sheet for this Skin.
 java.lang.String getTranslatedString(org.apache.myfaces.trinidad.context.LocaleContext lContext, java.lang.String key)
          Returns a translated String in the LocaleContext's translation Locale.
 java.lang.Object getTranslatedValue(org.apache.myfaces.trinidad.context.LocaleContext lContext, java.lang.String key)
          Returns a translated value in the LocaleContext's translation Locale.
protected abstract  javax.el.ValueExpression getTranslationSourceValueExpression()
          Returns the ValueExpression of the translation source for this Skin instance.
 org.apache.myfaces.trinidad.skin.SkinVersion getVersion()
           
 boolean isDirty()
          Check to see if this Skin has been marked dirty.
protected  void putTranslatedValueInLocaleCache(org.apache.myfaces.trinidad.context.LocaleContext lContext, java.lang.String key, java.lang.Object value)
          Put the locale/key/value in the cache (i.e., translations map).
 void registerIcon(java.lang.String iconName, org.apache.myfaces.trinidad.skin.Icon icon)
          Registers an Icon for the specified icon name.
 void registerStyleSheet(java.lang.String styleSheetName)
          Deprecated. Use addSkinAddition instead
 void setDirty(boolean dirty)
          Sets the dirty flag of the Skin.
 void setProperty(java.lang.Object key, java.lang.Object value)
          Sets a value for the specified property key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SkinImpl

public SkinImpl()
Method Detail

getId

public java.lang.String getId()
Returns an string identifier which uniquely identies this Skin implementation. Skin implementations can be retrieved by id via SkinFactory.getSkin().

Specified by:
getId in class org.apache.myfaces.trinidad.skin.Skin
See Also:
org.apache.myfaces.trinidadinternal.skin.SkinFactory#getSkin

getFamily

public java.lang.String getFamily()
Returns the name of the skin "family" for this skin. The family name is used when specifying a preferred skin in trinidad-config.xml. This provides a way to refer to a group of related skin implementations while allowing the particular skin instance to be selected based on the current render-kit-id.

Specified by:
getFamily in class org.apache.myfaces.trinidad.skin.Skin

getVersion

public org.apache.myfaces.trinidad.skin.SkinVersion getVersion()
Overrides:
getVersion in class org.apache.myfaces.trinidad.skin.Skin

getRenderKitId

public java.lang.String getRenderKitId()
Returns the renderKitId for the Skin.

Specified by:
getRenderKitId in class org.apache.myfaces.trinidad.skin.Skin

getStyleSheetDocumentId

public java.lang.String getStyleSheetDocumentId(org.apache.myfaces.trinidad.context.RenderingContext arc)
Returns the id of the Skin's stylesheet document. This is the StyleSheetDocument's id for the StyleContext.

Specified by:
getStyleSheetDocumentId in class org.apache.myfaces.trinidad.skin.Skin

getStyleSheetName

public abstract java.lang.String getStyleSheetName()
Returns the name of the style sheet for this Skin.

Specified by:
getStyleSheetName in class org.apache.myfaces.trinidad.skin.Skin

getTranslatedString

public java.lang.String getTranslatedString(org.apache.myfaces.trinidad.context.LocaleContext lContext,
                                            java.lang.String key)
                                     throws java.util.MissingResourceException
Returns a translated String in the LocaleContext's translation Locale.

Specified by:
getTranslatedString in class org.apache.myfaces.trinidad.skin.Skin
Throws:
java.util.MissingResourceException

getTranslatedValue

public java.lang.Object getTranslatedValue(org.apache.myfaces.trinidad.context.LocaleContext lContext,
                                           java.lang.String key)
                                    throws java.util.MissingResourceException
Returns a translated value in the LocaleContext's translation Locale. This value may or may not be a String, and developers should avoid calling toString() unless absolutely necessary.

Specified by:
getTranslatedValue in class org.apache.myfaces.trinidad.skin.Skin
Parameters:
lContext - The LocaleContext which provides the translation Locale. Cannot be null.
key - The key of the translation to retrieve. Cannot be null.
Throws:
java.lang.NullPointerException - if lContext or key is null.
java.util.MissingResourceException - if the resource key cannot be found in the skin's bundle or the skin additions' bundles.

getIcon

public org.apache.myfaces.trinidad.skin.Icon getIcon(java.lang.String iconName)
Our renderers call this to get the icon. This returns a renderable icon. (ReferenceIcons are resolved -- the real icon they point to is returned)

Specified by:
getIcon in class org.apache.myfaces.trinidad.skin.Skin

getIcon

public org.apache.myfaces.trinidad.skin.Icon getIcon(java.lang.String iconName,
                                                     boolean resolveIcon)
Returns an Icon object; can be a ReferenceIcon.

Specified by:
getIcon in class org.apache.myfaces.trinidad.skin.Skin
Parameters:
iconName - The name of the icon to retrieve. Cannot be null
Throws:
java.lang.NullPointerException - if iconName is null.

registerIcon

public void registerIcon(java.lang.String iconName,
                         org.apache.myfaces.trinidad.skin.Icon icon)
Registers an Icon for the specified icon name.

Specified by:
registerIcon in class org.apache.myfaces.trinidad.skin.Skin
Parameters:
iconName - The name of the icon. Cannot be null.
icon - The Icon to register.
Throws:
java.lang.NullPointerException - if iconName is null.

addSkinAddition

public void addSkinAddition(org.apache.myfaces.trinidad.skin.SkinAddition skinAddition)
Adds a SkinAddition on this Skin. You can call this method as many times as you like for the Skin, and it will add the SkinAddition to the list of SkinAdditions. However, it does not make sense to call this method more than once with the same SkinAddition object. This is meant for the skin-addition use-cases, where a custom component developer has a style sheet and/or resource bundle for their custom components, and they want the style sheet and/or resource bundle to work for this Skin and the children Skins. The stylesheets specified in the SkinAdditions will be merged with the Skin's own styles. The resource bundles specified in the SkinAdditions will be looked into if the translated key is not found in the Skin's own resource bundle during the call to getTranslatedString or getTranslatedValue.

Specified by:
addSkinAddition in class org.apache.myfaces.trinidad.skin.Skin
Parameters:
skinAddition - The SkinAddition object to add to the Skin.
Throws:
java.lang.NullPointerException - if SkinAddition is null.

getSkinAdditions

public java.util.List<org.apache.myfaces.trinidad.skin.SkinAddition> getSkinAdditions()
Gets an unmodifiable List of SkinAdditions that have been added on this Skin. To add to the SkinAdditions List, call addSkinAddition(SkinAddition)

Specified by:
getSkinAdditions in class org.apache.myfaces.trinidad.skin.Skin
Returns:
List an unmodifiable List of SkinAdditions.
See Also:
addSkinAddition(SkinAddition)

getStyleClassMap

public java.util.Map<java.lang.String,java.lang.String> getStyleClassMap(org.apache.myfaces.trinidad.context.RenderingContext arc)
Returns the style class map, or null if there is no map. Some StyleProvider implementations, such as the FileSystemStyleCache, automatically provide compressed versions style class names. The short style classes can be used instead of the full style class names to reduce the overall size of generated content.

Specified by:
getStyleClassMap in class org.apache.myfaces.trinidad.skin.Skin
Parameters:
arc - RenderingContext
Returns:
Map<String, String> It should be a map that contains the full style class name as the key, and the value could be a shortened style class name, or a portlet style class name, etc.

getStyleSheetDocument

public StyleSheetDocument getStyleSheetDocument(StyleContext context)
Returns the StyleSheetDocument object which defines all of the styles for this Skin, including any styles that are contributed by skin-additions.

Specified by:
getStyleSheetDocument in interface DocumentProviderSkin

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Retrieves a property that was set via a call to setProperty(). Some Renderer implementations may store properties on the Skin instance to avoid having to re-compute Skin-specific values on each render.

Specified by:
getProperty in class org.apache.myfaces.trinidad.skin.Skin

setProperty

public void setProperty(java.lang.Object key,
                        java.lang.Object value)
Sets a value for the specified property key.

Specified by:
setProperty in class org.apache.myfaces.trinidad.skin.Skin

registerStyleSheet

public void registerStyleSheet(java.lang.String styleSheetName)
Deprecated. Use addSkinAddition instead

Specified by:
registerStyleSheet in class org.apache.myfaces.trinidad.skin.Skin
Parameters:
styleSheetName -
See Also:
addSkinAddition(SkinAddition)

isDirty

public boolean isDirty()
Check to see if this Skin has been marked dirty. The only way to mark a Skin dirty is to call setDirty(true).

Specified by:
isDirty in class org.apache.myfaces.trinidad.skin.Skin
Returns:
true if the Skin is marked dirty.

setDirty

public void setDirty(boolean dirty)
Sets the dirty flag of the Skin. Use this if you want to regenerate the skin. During rendering, if isDirty is true, the skin's css file will be reprocessed regardless of whether the css file has been modified or if the CHECK_FILE_MODIFICATION flag was set. The Skinning Framework calls setDirty(false) after the skin has been reprocessed.

Specified by:
setDirty in class org.apache.myfaces.trinidad.skin.Skin

getCachedTranslatedValue

protected java.lang.Object getCachedTranslatedValue(org.apache.myfaces.trinidad.context.LocaleContext lContext,
                                                    java.lang.String key)
Returns a translated value in the LocaleContext's translation Locale, or null if the key could not be found. This value may or may not be a String, and developers should avoid calling toString() unless absolutely necessary. This method protects against MissingResourceExceptions by checking that the key exists before calling the bundle's getObject method. It eats any MissingResourceExceptions as a result of not finding the bundle, since there can be multiple bundles per skin, and we could get a lot of MissingResourceExceptions otherwise. Then the method caches the value once it is found in a particular resource bundle. This method is useful for SkinExtensions which will also check their ancestor skins for the resource if it is not found in the SkinExtension. MissingResourceExceptions would be numerous if we didn't protect against them. If you want to throw a MissingResourceException once all the ancestor skins and their bundles and registered bundles are checked, then you should call getTranslatedValue for the most base skin, and it will throw a MissingResourceException if the key was not found in any of the bundles.

Parameters:
lContext - The LocaleContext which provides the translation Locale. Cannot be null.
key - The key of the translation to retrieve. Cannot be null.
Returns:
Object translated value of the key; null if bundleName and skin-addition bundleNames are null for this Skin; null if the key cannot be found in the bundle or registered bundles -or-
Throws:
java.lang.NullPointerException - if lContext or key is null.
See Also:
getTranslatedValue(LocaleContext, String)

putTranslatedValueInLocaleCache

protected void putTranslatedValueInLocaleCache(org.apache.myfaces.trinidad.context.LocaleContext lContext,
                                               java.lang.String key,
                                               java.lang.Object value)
Put the locale/key/value in the cache (i.e., translations map). This is useful for subclasses to call so that they can store/retrieve the key/value locally rather than always having to look in the parent skins' maps.

Parameters:
lContext -
key -
value -

getBundleName

protected abstract java.lang.String getBundleName()
Returns the name of the ResourceBundle for this Skin instance. This does not include the SkinAddition resource bundles. We differentiate between the two types of resource bundles so that the Skin's own resource bundle can take precedence. Note: A skin cannot have both a bundleName and a translation source value expression. If they do, then the bundlename takes precedence.


getTranslationSourceValueExpression

protected abstract javax.el.ValueExpression getTranslationSourceValueExpression()
Returns the ValueExpression of the translation source for this Skin instance. This does not include the SkinAddition translation source. The Skin's own resource bundle or translation source can take precedence over the SkinAdditions resource bundle or translation source. Note: A skin cannot have both a bundleName and a translation source value expression. If they do, then the bundleName takes precedence.



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