NextApp Echo
App Container 1.0.5

nextapp.echoservlet.html
Class Style

java.lang.Object
  extended bynextapp.echoservlet.html.Style
All Implemented Interfaces:
Renderable, java.io.Serializable

public class Style
extends java.lang.Object
implements Renderable, java.io.Serializable

A representation of a CSS style that may be associated with multiple types of elements.

See Also:
Serialized Form

Field Summary
private  java.util.Map attributes
           
private static java.lang.String DOUBLE_INDENT
           
private  java.util.Set elementTypes
           
private  java.lang.String id
           
static java.lang.String PERCENT_UNITS
          A unit suffix for percent units.
static java.lang.String PIXEL_UNITS
          A unit suffix for pixel units.
static java.lang.String POINT_UNITS
          A unit suffix for point units.
private  java.util.Map pseudonyms
           
private static java.lang.String TRIPLE_INDENT
           
 
Fields inherited from interface nextapp.echoservlet.html.Renderable
INDENT_STRING
 
Constructor Summary
Style(java.lang.String id)
          Creates a new style with the given identifier.
 
Method Summary
 void addAttribute(java.lang.String name, int value)
          Adds an integer attribute (with no units) to this style.
 void addAttribute(java.lang.String name, int value, java.lang.String units)
          Adds an integer attribute with the specified units to this style.
 void addAttribute(java.lang.String name, java.lang.String value)
          Adds a text attribute to the style.
 void addElementType(java.lang.String elementType)
          Adds an element type to the style.
 void addPseudoAttribute(java.lang.String pseudonym, java.lang.String name, int value)
          Adds a pseudoclass integer attribute to the style.
 void addPseudoAttribute(java.lang.String pseudonym, java.lang.String name, java.lang.String value)
          Adds a pseudoclass attribute to the style.
 void render(java.io.PrintWriter pw, int depth, boolean parentWhitespaceRelevant)
          Renders this style to the given PrintWriter.
private  void renderClass(java.io.PrintWriter pw, java.lang.String elementType, java.lang.String pseudonym, java.util.Map attributeData)
          Renders a class element of the style to the given PrintWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOUBLE_INDENT

private static final java.lang.String DOUBLE_INDENT
See Also:
Constant Field Values

TRIPLE_INDENT

private static final java.lang.String TRIPLE_INDENT
See Also:
Constant Field Values

attributes

private java.util.Map attributes

pseudonyms

private java.util.Map pseudonyms

elementTypes

private java.util.Set elementTypes

id

private java.lang.String id

PERCENT_UNITS

public static final java.lang.String PERCENT_UNITS
A unit suffix for percent units.

See Also:
Constant Field Values

PIXEL_UNITS

public static final java.lang.String PIXEL_UNITS
A unit suffix for pixel units.

See Also:
Constant Field Values

POINT_UNITS

public static final java.lang.String POINT_UNITS
A unit suffix for point units.

See Also:
Constant Field Values
Constructor Detail

Style

public Style(java.lang.String id)
Creates a new style with the given identifier.

Parameters:
id - The identifier of this style.
Method Detail

addElementType

public void addElementType(java.lang.String elementType)
Adds an element type to the style. The style will be rendered identically for each element type that is specified. For example, a single style might be used for the elements <A>, <INPUT> and <TD>.

Parameters:
elementType - The element to be added, e.g. "a", "input", or "td".

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)
Adds a text attribute to the style.

Parameters:
name - The name of the attribute.
value - The value of the attribute.

addAttribute

public void addAttribute(java.lang.String name,
                         int value)
Adds an integer attribute (with no units) to this style.

Parameters:
name - The name of the attribute.
value - The value of the attribute.

addAttribute

public void addAttribute(java.lang.String name,
                         int value,
                         java.lang.String units)
Adds an integer attribute with the specified units to this style.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
units - The units of the value.

addPseudoAttribute

public void addPseudoAttribute(java.lang.String pseudonym,
                               java.lang.String name,
                               java.lang.String value)
Adds a pseudoclass attribute to the style.

Parameters:
pseudonym - The name of the pseudoclass.
name - The name of the attribute.
value - The value of the attribute.

addPseudoAttribute

public void addPseudoAttribute(java.lang.String pseudonym,
                               java.lang.String name,
                               int value)
Adds a pseudoclass integer attribute to the style.

Parameters:
pseudonym - The name of the pseudoclass.
name - The name of the attribute.
value - The value of the attribute.

render

public void render(java.io.PrintWriter pw,
                   int depth,
                   boolean parentWhitespaceRelevant)
Renders this style to the given PrintWriter.

Specified by:
render in interface Renderable
Parameters:
pw - The PrintWriter to render to.
depth - The indentation depth that should be applied to the element being rendered.
parentWhitespaceRelevant - A flag that indicates whether the containing element is sensitive to white space.
See Also:
Renderable.render(PrintWriter, int, boolean)

renderClass

private void renderClass(java.io.PrintWriter pw,
                         java.lang.String elementType,
                         java.lang.String pseudonym,
                         java.util.Map attributeData)
Renders a class element of the style to the given PrintWriter.

Parameters:
pw - The PrintWriter to print the output to.
elementType - The element type which the style is describing, e.g. "a", "span", etc.
pseudonym - The pseudoclass being rendered (null if the main class is being rendered).
attributeData - A map containing attributes (name/value pairs) as Strings.

NextApp Echo
App Container 1.0.5