Package com.adobe.granite.ui.components
Class AttrBuilder
java.lang.Object
com.adobe.granite.ui.components.AttrBuilder
A builder to generate HTML attributes. This builder is designed to be secured
using
XSSAPI. It will encode the value automatically. If the value is
null, it will be ignored.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds attribute with the given name.voidAdds attribute with the given name.voidAdds attribute with the given name.voidAdds attribute with the given name.voidaddBoolean(String name, boolean value) Adds boolean attribute (behaves likedisabled) for the given name.voidaddChecked(boolean checked) Addscheckedattribute.voidAddsclassattribute with the given value.voidaddDisabled(boolean disabled) Addsdisabledattribute.voidAdds an attribute that behave likehrefattribute.voidaddMultiple(boolean multiple) Addsmultipleattribute.voidAdds the given name asdata-*attribute.voidAdds the given data asdata-*attributes.voidAdds relationship.voidaddSelected(boolean selected) Addsselectedattribute.build()Builds the attributes in the form of<attr-name>='<attr-value>'*.voidBuilds the attributes in the form of<attr-name>='<attr-value>'**.getData()Gets the rawMapof attributes, with un-encoded valuesbooleanisEmpty()Returnstrueif there is no attribute in this builder,falseotherwise.voidSets attribute with the given name.toString()
-
Constructor Details
-
AttrBuilder
-
-
Method Details
-
getData
Gets the rawMapof attributes, with un-encoded values- Returns:
Mapof attributes
-
addRel
Adds relationship. Currently it is implemented asclassattribute.- Parameters:
value- the relationship to add
-
addClass
Addsclassattribute with the given value.- Parameters:
value- the class attribute to add
-
addHref
Adds an attribute that behave likehrefattribute. i.e. the value will be prepended with context path (if absolute path) and checked usingXSSAPI.getValidHref(String).- Parameters:
name- the name of the attribute to addvalue- the value of the specified attribute
-
addDisabled
public void addDisabled(boolean disabled) Addsdisabledattribute.- Parameters:
disabled- the boolean value of thedisabledattribute
-
addChecked
public void addChecked(boolean checked) Addscheckedattribute.- Parameters:
checked- the boolean value of thecheckedattribute
-
addSelected
public void addSelected(boolean selected) Addsselectedattribute.- Parameters:
selected- the boolean value of theselectedattribute
-
addMultiple
public void addMultiple(boolean multiple) Addsmultipleattribute.- Parameters:
multiple- the boolean value of themultipleattribute
-
addBoolean
Adds boolean attribute (behaves likedisabled) for the given name. When the given value istrue, it will be printed as "disabled=''", instead of "disabled='true'". When the given value isfalse, it will NOT be printed, instead of "disabled='false'".- Parameters:
name- the name of the boolean attribute to addvalue- the boolean value of the attribute
-
addOther
Adds the given name asdata-*attribute.- Parameters:
name- the name of thedata-*attribute to addvalue- the value of the attribute
-
addOthers
Adds the given data asdata-*attributes. Entries with keys specified in exclusions parameter or having namespace (e.g. "jcr:primaryType") will be excluded.- Parameters:
data- the map containing key/value pairs to add asdata-*attributesexclusions- the keys which must not be added asdata-*attributes
-
add
Adds attribute with the given name. The value will be added to existing attribute using space-delimited convention. e.g. class="class1 class2"- Parameters:
name- the name of the attribute to addvalue- the boolean value of the attribute
-
add
Adds attribute with the given name. The value will be added to existing attribute using space-delimited convention. e.g. class="class1 class2"- Parameters:
name- the name of the attribute to addvalue- the integer value of the attribute
-
add
Adds attribute with the given name. The value will be added to existing attribute using space-delimited convention. e.g. class="class1 class2"- Parameters:
name- the name of the attribute to addvalue- the double value of the attribute
-
add
Adds attribute with the given name. The value will be added to existing attribute using space-delimited convention. e.g. class="class1 class2"- Parameters:
name- the name of the attribute to addvalue- the string value of the attribute
-
set
Sets attribute with the given name. Existing value previously set will be replaced by the given value.- Parameters:
name- the name of the attribute to set or replace (if exists)value- the string value of the attribute
-
isEmpty
public boolean isEmpty()Returnstrueif there is no attribute in this builder,falseotherwise.- Returns:
trueif there is no attribute in this builder,falseotherwise
-
build
Builds the attributes in the form of<attr-name>='<attr-value>'*.- Returns:
- the string containing the built attributes
-
build
Builds the attributes in the form of<attr-name>='<attr-value>'**.- Parameters:
out- the writer- Throws:
IOException- in case there's an error when appending to the writer
-
toString
-