org.apache.myfaces.trinidadinternal.style.util
Class CSSGenerationUtils

java.lang.Object
  extended by org.apache.myfaces.trinidadinternal.style.util.CSSGenerationUtils

public class CSSGenerationUtils
extends java.lang.Object

CSS-generation related utilities used when we write out our css-2 stylesheet document based on the skin's css-3 stylesheet document.

Version:
$Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/style/util/CSSUtils.java#0 $) $Date: 10-nov-2005.18:58:49 $

Constructor Summary
CSSGenerationUtils()
           
 
Method Summary
static java.lang.String getMappedSelector(java.util.Map<java.lang.String,java.lang.String> afSelectorMap, java.lang.String[] namespacePrefixArray, java.lang.String selector)
          Runs a selector through a map.
static java.util.Iterator<java.lang.String> getNamespacedSelectors(java.lang.String selector, java.lang.String namespace, java.util.Map<java.lang.String,java.lang.String> afSelectorMap)
          Called when creating the shortened styleclass map.
static void getNamespacePrefixes(java.util.Set<java.lang.String> namespacePrefixes, java.lang.String selector)
          Add to the namespacePrefixes Set any namespace prefixes found in this selector.
static java.lang.String getShortSelector(java.util.Map<java.lang.String,java.lang.String> shortStyleClassMap, java.lang.String[] namespacePrefixArray, java.lang.String selector)
          Shorten (compress) the selector.
static java.util.Iterator<java.lang.String> getStyleClasses(java.lang.String selector)
          Returns an Iterator of all of the style class selectors included in the specified selector.
static java.lang.String getValidFullNameSelector(java.lang.String selector, java.lang.String[] namespacePrefixArray)
          get rid of the | and :: that browsers don't like, and add the '.' where needed to make the af| component selector into a style class selector that is valid to be written to the css file.
static boolean isSingleStyleClassSelector(java.lang.String selector)
          Tests whether the specified selector is a single style class selector.
static void writeCSS(StyleContext context, java.lang.String styleSheetName, StyleNode[] styles, StyleWriterFactory writerFactory, boolean compressStyles, java.util.Map<java.lang.String,java.lang.String> shortStyleClassMap, java.lang.String[] namespacePrefixArray, java.util.Map<java.lang.String,java.lang.String> afSelectorMap)
          Converts the specified set of StyleNodes to CSS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSSGenerationUtils

public CSSGenerationUtils()
Method Detail

writeCSS

public static void writeCSS(StyleContext context,
                            java.lang.String styleSheetName,
                            StyleNode[] styles,
                            StyleWriterFactory writerFactory,
                            boolean compressStyles,
                            java.util.Map<java.lang.String,java.lang.String> shortStyleClassMap,
                            java.lang.String[] namespacePrefixArray,
                            java.util.Map<java.lang.String,java.lang.String> afSelectorMap)
Converts the specified set of StyleNodes to CSS. We output either full styleclass names or compressed styleclass names.

Parameters:
context - The current StyleContext
styleSheetName - The stylesheet name that is registered with the skin. e.g. skins/purple/purpleSkin.css
styles - The style nodes to convert
writerFactory - The factory to obtain PrintWriter instances
compressStyles - This tells us whether or not we want to output the short names.
shortStyleClassMap - A Map which maps style class names to short names.
namespacePrefixArray - an array with the namespace prefixes of our special selectors. e.g., "af|" or "tr|" .
afSelectorMap - A Map which maps the namespaced component selectors to their base names (e.g., 'af|menuPath::step' maps to 'af|menuPath A')

getShortSelector

public static java.lang.String getShortSelector(java.util.Map<java.lang.String,java.lang.String> shortStyleClassMap,
                                                java.lang.String[] namespacePrefixArray,
                                                java.lang.String selector)
Shorten (compress) the selector.

Parameters:
shortStyleClassMap -
namespacePrefixArray -
selector -
Returns:
the shortened selector, or selector if nothing could be shortened.

isSingleStyleClassSelector

public static boolean isSingleStyleClassSelector(java.lang.String selector)
Tests whether the specified selector is a single style class selector. A single style class selector is something like ".AFInstructionText". Examples that are not single style class selectors are "af|inputText" or ".AFFoo .AFBar" or ".foo:hover"


getStyleClasses

public static java.util.Iterator<java.lang.String> getStyleClasses(java.lang.String selector)
Returns an Iterator of all of the style class selectors included in the specified selector. For example, ".OraNav1Enabled" returns a single element Iterator with the string "OraNav1Enabled". "P.OraNav1Enabled SPAN.text" returns a two element Iterator with "OraNav1Enabled" and "text". .OraLink:visited returns "OraLink" .star.moon returns "star" and "moon"


getNamespacedSelectors

public static java.util.Iterator<java.lang.String> getNamespacedSelectors(java.lang.String selector,
                                                                          java.lang.String namespace,
                                                                          java.util.Map<java.lang.String,java.lang.String> afSelectorMap)
Called when creating the shortened styleclass map. Returns an Iterator of all of the component selectors that begin with the given namespace. All styleclasses and pseudo-classes are ignored and NOT returned. For example, ".OraNav1Enabled af|menuPath" returns a single element Iterator with the string "af|menuPath". "af|menuPath.OraNav1Enabled af|treeTable.text" returns a two element Iterator with "af|menuPath" and "af|treeTable". af|inputText:disabled af|inputText::content returns two "af|inputText" and "af|inputText::content". It also looks at the afSelectorMap to map any special selectors if necessary. e.g., "af|menuPath::step" maps to "af|menuPath A", so ".OraNav1Enabled af|menuPath::step" returns "af|menuPath"


getNamespacePrefixes

public static void getNamespacePrefixes(java.util.Set<java.lang.String> namespacePrefixes,
                                        java.lang.String selector)
Add to the namespacePrefixes Set any namespace prefixes found in this selector.

Parameters:
namespacePrefixes -
selector -

getMappedSelector

public static java.lang.String getMappedSelector(java.util.Map<java.lang.String,java.lang.String> afSelectorMap,
                                                 java.lang.String[] namespacePrefixArray,
                                                 java.lang.String selector)
Runs a selector through a map. It returns the selector unchanged (except for converted pseudo-classes) if there is no namespace in the selector. This could be a map to convert the public no-html selector to an internal selector that has html-specifics (e.g., 'af|menuPath::step:hover' -> 'af|menuPath A:hover') or it could be a map to shorten the selector (e.g., 'af|menuPath A:hover' -> '.x11 A:hover') We call this method first with the public->internal map, and then to shorten it. Only the pieces of the selector that start with the namespace are mapped.

Parameters:
afSelectorMap - if shortenPass is true, then this map shortens the af| selector. else, it maps the public af| selector to the internal selector (a selector that is closer to what is written to the CSS file. e.g., af|inputText:error::content becomes af|inputText.p_AFError af|inputText::content
namespacePrefixArray - most likely, "af|". The selectors with this namespace are the ones we map.
selector - selector to map.

getValidFullNameSelector

public static java.lang.String getValidFullNameSelector(java.lang.String selector,
                                                        java.lang.String[] namespacePrefixArray)
get rid of the | and :: that browsers don't like, and add the '.' where needed to make the af| component selector into a style class selector that is valid to be written to the css file.

Parameters:
selector -
Returns:


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