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

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

public class CSSUtils
extends java.lang.Object

CSS-related utilities. I think as we move away from xss, most of this code will be removed.

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
CSSUtils()
           
 
Method Summary
static java.lang.String getAbsoluteURIValue(java.lang.String styleSheetName, java.lang.String baseURI, java.lang.String uri)
          Convert a relative URI values to an absolute URI value.
static java.lang.String getBaseSkinStyleSheetURI(java.lang.String styleSheetName)
          Given a Skin's stylesheet name that is being parsed, return an absolute base URI pointing to the directory which contains the skin style sheet.
static java.lang.String getColorValue(java.awt.Color color)
          Converts the specified Color to a valid CSS color value.
static boolean isAbsoluteURI(java.lang.String uriString)
           
static java.awt.Color parseColor(java.lang.String value)
          Parses the CSS color value.
static java.lang.String[] parseFontFamilies(java.lang.String value)
          Parses a CSS font family value into a list of font family names.
static java.lang.Integer parseFontSize(java.lang.String value)
          Parses a CSS font size.
static java.lang.Object parseFontStyle(java.lang.String value)
          Parses a CSS font style
static java.lang.Object parseFontWeight(java.lang.String value)
          Parses a CS font weight
static java.lang.Integer parseLength(java.lang.String value)
          Parses a CSS length value.
static CSSStyle parseStyle(java.lang.String text)
          Parse an inline style into a CSSStyle object.
static java.lang.String resolvePropertyValue(java.lang.String styleSheetName, java.lang.String baseURI, java.lang.String propertyName, java.lang.String propertyValue)
          Resolve the propertyValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSSUtils

public CSSUtils()
Method Detail

resolvePropertyValue

public static java.lang.String resolvePropertyValue(java.lang.String styleSheetName,
                                                    java.lang.String baseURI,
                                                    java.lang.String propertyName,
                                                    java.lang.String propertyValue)
Resolve the propertyValue. For example, if the propertyValue is an url, then we run it through the encodeResourceURL method.

Parameters:
styleSheetName - - The Skin's stylesheet name.
baseURI - - An absolute base URI pointing to the directory which contains the skin style sheet. You can compute this value by calling getBaseSkinStyleSheetURI and passing in the styleSheetName.
propertyName - - The css property name, like background-image
propertyValue - -The css property value, like url("skins/purple/error.gif");
Returns:
the propertyValue, possibly changed to a 'resolved' propertyValue. For instance, if it is an url, the return value will be the encoded url.

getBaseSkinStyleSheetURI

public static java.lang.String getBaseSkinStyleSheetURI(java.lang.String styleSheetName)
Given a Skin's stylesheet name that is being parsed, return an absolute base URI pointing to the directory which contains the skin style sheet. We will use this base URI to ensure that URLs specified in the style sheet (eg. background-image URLs) are resolved appropriately (ie. not relative to the generated style sheet).

Parameters:
styleSheetName - - The Skin's stylesheet name. E.g., "/skins/purple/purpleSkin.css"
Returns:
an absolute base URI pointing to the // directory which contains the skin style sheet. e.g., "/trinidad-context/skins/purple"

isAbsoluteURI

public static boolean isAbsoluteURI(java.lang.String uriString)

getAbsoluteURIValue

public static java.lang.String getAbsoluteURIValue(java.lang.String styleSheetName,
                                                   java.lang.String baseURI,
                                                   java.lang.String uri)
Convert a relative URI values to an absolute URI value. For example, if the baseURI is "/trinidad-context/skins/purple" and the uri is "../../skins/purple/xyz.gif", we return

Parameters:
styleSheetName - - the name of the Skin's stylesheet. We use this in any warning messages.
baseURI - - absolute base URI pointing to the directory which contains the skin style sheet. This is used to figure out the absolute uri of the uri parameter.
uri - - a uri. If this is an uri that begins with "../", then we convert it to be an absolute url that has no "../" at the start.
Returns:
An uri that does not begin with one or more "../" strings.

parseStyle

public static CSSStyle parseStyle(java.lang.String text)
Parse an inline style into a CSSStyle object.


parseColor

public static java.awt.Color parseColor(java.lang.String value)
                                 throws PropertyParseException
Parses the CSS color value.

Parameters:
value - A CSS color value.
Returns:
A Color object which corresponds to the provided value
Throws:
PropertyParseException - Thrown if the specified color value can not be parsed.

parseFontFamilies

public static java.lang.String[] parseFontFamilies(java.lang.String value)
                                            throws PropertyParseException
Parses a CSS font family value into a list of font family names.

Parameters:
value - A CSS font family value.
Returns:
The list of font family names present in the font family property
Throws:
PropertyParseException - Thrown if the specified font family value can not be parsed.

parseFontSize

public static java.lang.Integer parseFontSize(java.lang.String value)
                                       throws PropertyParseException
Parses a CSS font size.

Parameters:
value - A CSS font size value. At the moment, all font sizes must be specified in points (eg. "12pt").
Returns:
An Integer font size suitable for use as an AWT Font size
Throws:
PropertyParseException - Thrown if the specified font size value can not be parsed.

parseFontStyle

public static java.lang.Object parseFontStyle(java.lang.String value)
                                       throws PropertyParseException
Parses a CSS font style

Parameters:
value - A CSS font style value.
Returns:
An integer font style suitable for use as an AWT Font style
Throws:
PropertyParseException - Thrown if the specified font style value can not be parsed.

parseFontWeight

public static java.lang.Object parseFontWeight(java.lang.String value)
                                        throws PropertyParseException
Parses a CS font weight

Parameters:
value - A CSS font weight value. At the moment, all font weights must be specified as either "bold" or "normal".
Returns:
An integer font weight suitable for use as the weight component of an AWT Font style
Throws:
PropertyParseException - Thrown if the specified font weight value can not be parsed.

parseLength

public static java.lang.Integer parseLength(java.lang.String value)
                                     throws PropertyParseException
Parses a CSS length value.

Parameters:
value - A CSS length value.
Returns:
An Integer font size representing the length
Throws:
PropertyParseException - Thrown if the specified value can not be parsed.

getColorValue

public static java.lang.String getColorValue(java.awt.Color color)
Converts the specified Color to a valid CSS color value.



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