public class AttrBuilder extends Object
XSSAPI
. It will encode the value automatically. If the value is
null
, it will be ignored.Constructor and Description |
---|
AttrBuilder(HttpServletRequest req,
XSSAPI xssAPI) |
Modifier and Type | Method and Description |
---|---|
void |
add(String name,
Boolean value)
Adds attribute with the given name.
|
void |
add(String name,
Double value)
Adds attribute with the given name.
|
void |
add(String name,
Integer value)
Adds attribute with the given name.
|
void |
add(String name,
String value)
Adds attribute with the given name.
|
void |
addBoolean(String name,
boolean value)
Adds boolean attribute (behaves like
disabled ) for the given name. |
void |
addChecked(boolean checked)
Adds
checked attribute. |
void |
addClass(String value)
Adds
class attribute with the given value. |
void |
addDisabled(boolean disabled)
Adds
disabled attribute. |
void |
addHref(String name,
String value)
Adds an attribute that behave like
href attribute. |
void |
addMultiple(boolean multiple)
Adds
multiple attribute. |
void |
addOther(String name,
String value)
Adds the given name as data-* attribute.
|
void |
addOthers(Map<String,Object> data,
String... exclusions)
Adds the given data as data-* attributes.
|
void |
addRel(String value)
Adds relationship.
|
void |
addSelected(boolean selected)
Adds
selected attribute. |
String |
build()
Builds the attributes in the form of (
|
void |
build(Writer out)
Builds the attributes in the form of (
|
boolean |
isEmpty()
Returns
true if there is no attribute in this builder; false otherwise. |
void |
set(String name,
String value)
Sets attribute with the given name.
|
public void addRel(String value)
class
attribute.public void addClass(String value)
class
attribute with the given value.public void addHref(String name, String value)
href
attribute. i.e. the
value will be prepended with context path (if absolute path) and checked
using XSSAPI#getValidHref(String)
.public void addDisabled(boolean disabled)
disabled
attribute.public void addChecked(boolean checked)
checked
attribute.public void addSelected(boolean selected)
selected
attribute.public void addMultiple(boolean multiple)
multiple
attribute.public void addBoolean(String name, boolean value)
disabled
) for the given name.
When the given value is true
, it will be printed as "disabled='disabled'", instead of "disabled='true'".
When the given value is false
, it will NOT be printed, instead of "disabled='false'".public void addOthers(Map<String,Object> data, String... exclusions)
public void add(String name, Boolean value)
public void add(String name, Integer value)
public void add(String name, Double value)
public void add(String name, String value)
public void set(String name, String value)
public boolean isEmpty()
true
if there is no attribute in this builder; false
otherwise.public String build()
public void build(Writer out) throws IOException
IOException
"Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"