All Downloads are FREE. Search and download functionalities are using the official Maven repository.

js.template.xhtml.CssClass Maven / Gradle / Ivy

Go to download

Reference implementation for j(s)-lib template API, declarative, natural and based on X(HT)ML language.

The newest version!
package js.template.xhtml;

import java.util.ArrayList;
import java.util.List;

import js.dom.Element;
import js.util.Strings;

/**
 * Element CSS class wrapper.
 * 
 * @author Iulian Rotaru
 */
final class CssClass extends AttrImpl
{
  private static final String ATTR_CLASS = "class";

  private List classNames;

  protected CssClass(Element element)
  {
    super(ATTR_CLASS);
    classNames = Strings.split(element.getAttr(ATTR_CLASS));
    if(this.classNames == null) {
      this.classNames = new ArrayList();
    }
  }

  protected void add(String className)
  {
    if(!this.classNames.contains(className)) {
      this.classNames.add(className);
    }
  }

  protected void remove(String className)
  {
    this.classNames.remove(className);
  }

  @Override
  public String getValue()
  {
    return Strings.join(classNames);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy