TUM CCSM Commons

edu.tum.cs.commons.html
Class CSSDeclarationBlock

java.lang.Object
  extended by edu.tum.cs.commons.html.CSSDeclarationBlock

public class CSSDeclarationBlock
extends java.lang.Object

This class describes a set of CSS declarations (property value pairs). Additionally it allows for simple multiple inheritance, where the properties of all inherited blocks are merged (including the block itself). The classes coming later in the inheritance list and the block itself will overwrite any properties defined multiple times.

Version:
$Rev: 26283 $
Author:
hummelb, $Author: juergens $
Rating:
GREEN Hash: 539B6065D69734F5F5B5E2B3B7D3461A

Constructor Summary
CSSDeclarationBlock(CSSDeclarationBlock superBlock, java.lang.Object... values)
          Create new declaration block.
CSSDeclarationBlock(java.lang.Object... values)
          Create new declaration block.
 
Method Summary
 java.lang.String getProperty(java.lang.String property)
          Returns the value of the property (or null if it is not defined for this block).
 CSSDeclarationBlock inheritFrom(CSSDeclarationBlock css)
          Adds another block to inherit from.
 CSSDeclarationBlock removeProperty(java.lang.String property)
          Removes the property from this block (whether it exists or not).
 CSSDeclarationBlock setBorder(java.lang.String width, java.lang.String style, java.lang.String color)
          Sets the border to the given values.
 CSSDeclarationBlock setBorderColor(java.lang.String color)
          Sets the border color to the given value.
 CSSDeclarationBlock setBorderStyle(java.lang.String style)
          Sets the border style to the given value.
 CSSDeclarationBlock setBorderWidth(java.lang.String width)
          Sets the border width to the given value.
 CSSDeclarationBlock setMargin(java.lang.String value)
          Sets the margin to the given value.
 CSSDeclarationBlock setPadding(java.lang.String value)
          Sets the padding to the given value.
 CSSDeclarationBlock setProperty(ECSSProperty property, java.lang.String value)
          Adds a property to this block.
 java.lang.String toInlineStyle()
          Returns the full (including inherited) properties as a single line string using the format suitable for inline styles as used in HTML.
 void writeOut(java.io.PrintStream ps, java.lang.String indent)
          Writes the full (including inherited) properties into the given stream using the format for CSS files, i.e. one property in each line followed by a colon, the value, and a semicolon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSSDeclarationBlock

public CSSDeclarationBlock(java.lang.Object... values)
Create new declaration block.

Parameters:
values - the property value pairs to add (so the number must be even).

CSSDeclarationBlock

public CSSDeclarationBlock(CSSDeclarationBlock superBlock,
                           java.lang.Object... values)
Create new declaration block.

Parameters:
superBlock - the block to inherit from.
values - the property value pairs to add (so the number must be even).
Method Detail

setProperty

public CSSDeclarationBlock setProperty(ECSSProperty property,
                                       java.lang.String value)
Adds a property to this block. Is a property with this name exists, it will be overwritten.

Returns:
this

setMargin

public CSSDeclarationBlock setMargin(java.lang.String value)
Sets the margin to the given value.

Returns:
this

setPadding

public CSSDeclarationBlock setPadding(java.lang.String value)
Sets the padding to the given value.

Returns:
this

setBorder

public CSSDeclarationBlock setBorder(java.lang.String width,
                                     java.lang.String style,
                                     java.lang.String color)
Sets the border to the given values.

Returns:
this

setBorderWidth

public CSSDeclarationBlock setBorderWidth(java.lang.String width)
Sets the border width to the given value.

Returns:
this

setBorderStyle

public CSSDeclarationBlock setBorderStyle(java.lang.String style)
Sets the border style to the given value.

Returns:
this

setBorderColor

public CSSDeclarationBlock setBorderColor(java.lang.String color)
Sets the border color to the given value.

Returns:
this

removeProperty

public CSSDeclarationBlock removeProperty(java.lang.String property)
Removes the property from this block (whether it exists or not).

Returns:
this

getProperty

public java.lang.String getProperty(java.lang.String property)
Returns the value of the property (or null if it is not defined for this block).


inheritFrom

public CSSDeclarationBlock inheritFrom(CSSDeclarationBlock css)
Adds another block to inherit from.

Returns:
this

writeOut

public void writeOut(java.io.PrintStream ps,
                     java.lang.String indent)
Writes the full (including inherited) properties into the given stream using the format for CSS files, i.e. one property in each line followed by a colon, the value, and a semicolon.


toInlineStyle

public java.lang.String toInlineStyle()
Returns the full (including inherited) properties as a single line string using the format suitable for inline styles as used in HTML.


TUM CCSM Commons

TUM CCSM Commons - 2.7