org.loom.tags
Class CssBuilder

java.lang.Object
  extended by org.loom.tags.CssBuilder

public class CssBuilder
extends java.lang.Object

Concatenates CSS styles, separating with spaces the different styles. Admits null as a css class (that will not get added) and ignores a css class if it is already present.


Constructor Summary
CssBuilder()
           
CssBuilder(java.lang.String... cssClasses)
          Initializes a CssBuilder with the given css classes
 
Method Summary
 CssBuilder add(java.lang.String cssClass)
          Appends a css class if the class is != null
 CssBuilder addAll(CssBuilder other)
          Adds all the CSS classes included in another instance of CssBuilder into this one.
 void clear()
          Clears this cssBuilder instance
 boolean contains(java.lang.String cssClassName)
           
 CssBuilder filter(java.util.Set<java.lang.String> includedClassNames)
           
 java.lang.String getCss()
           
 boolean isEmpty()
           
 void setCss(java.lang.String css)
          Clears the current css classes and add a new one.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CssBuilder

public CssBuilder()

CssBuilder

public CssBuilder(java.lang.String... cssClasses)
Initializes a CssBuilder with the given css classes

Parameters:
cssClasses - the list of css classes to be included by default
Method Detail

filter

public CssBuilder filter(java.util.Set<java.lang.String> includedClassNames)
Parameters:
includedClassNames - the css class names that should be included in the copy. The rest are discarded.
Returns:
a copy of this CssBuilder instance, including only the filtered classes

add

public CssBuilder add(java.lang.String cssClass)
Appends a css class if the class is != null

Parameters:
cssClass - the CSS class to be added. If null, it will be ignored.

addAll

public CssBuilder addAll(CssBuilder other)
Adds all the CSS classes included in another instance of CssBuilder into this one.

Parameters:
other - the CSS builder to be added.

getCss

public java.lang.String getCss()
Returns:
the accumulated CSS, null if empty

clear

public void clear()
Clears this cssBuilder instance


isEmpty

public boolean isEmpty()
Returns:
true if this css builder does not have any css styles yet

setCss

public void setCss(java.lang.String css)
Clears the current css classes and add a new one.

Parameters:
css -

size

public int size()
Returns:
the number of CSS classes added to this instance

contains

public boolean contains(java.lang.String cssClassName)
Returns:
true if this CSS builder contains the provided css class name. This is (supposedly) faster than querying the concatenated string, specially when the CSS is not found.