Package com.vaadin.ui.declarative
Class DesignAttributeHandler
- java.lang.Object
-
- com.vaadin.ui.declarative.DesignAttributeHandler
-
- All Implemented Interfaces:
Serializable
public class DesignAttributeHandler extends Object implements Serializable
Default attribute handler implementation used when parsing designs to component trees. Handles all the component attributes that do not require custom handling.- Since:
- 7.4
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DesignAttributeHandler()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
assignValue(Object target, String attribute, String value)
Assigns the specified design attribute to the given component.static void
clearElement(org.jsoup.nodes.Element design)
Clears the children and attributes of the given elementstatic DesignFormatter
getFormatter()
Returns the currently used formatter.static Collection<String>
getSupportedAttributes(Class<?> clazz)
Searches for supported setter and getter types from the specified class and returns the list of corresponding design attributesstatic Alignment
readAlignment(org.jsoup.nodes.Attributes attr)
Read the alignment from the given child component attributes.static <T> T
readAttribute(String attribute, org.jsoup.nodes.Attributes attributes, Class<T> outputType)
Reads the given attribute from a set of attributes.static <T> T
readAttribute(String attribute, org.jsoup.nodes.Attributes attributes, T defaultValue, Class<T> outputType)
Reads the given attribute from a set of attributes.static void
writeAlignment(org.jsoup.nodes.Element childElement, Alignment alignment)
Writes the alignment to the given child element attributes.static void
writeAttribute(Object component, String attribute, org.jsoup.nodes.Attributes attr, Object defaultInstance)
Writes the specified attribute to the design if it differs from the default value got from thedefaultInstance
static <T> void
writeAttribute(String attribute, org.jsoup.nodes.Attributes attributes, T value, T defaultValue, Class<T> inputType)
Writes the given attribute value to a set of attributes if it differs from the default attribute value.
-
-
-
Method Detail
-
getFormatter
public static DesignFormatter getFormatter()
Returns the currently used formatter. All primitive types and all types needed by Vaadin components are handled by that formatter.- Returns:
- An instance of the formatter.
-
clearElement
public static void clearElement(org.jsoup.nodes.Element design)
Clears the children and attributes of the given element- Parameters:
design
- the element to be cleared
-
assignValue
public static boolean assignValue(Object target, String attribute, String value)
Assigns the specified design attribute to the given component.- Parameters:
target
- the target to which the attribute should be setattribute
- the name of the attribute to be setvalue
- the string value of the attribute- Returns:
- true on success
-
getSupportedAttributes
public static Collection<String> getSupportedAttributes(Class<?> clazz)
Searches for supported setter and getter types from the specified class and returns the list of corresponding design attributes- Parameters:
clazz
- the class scanned for setters- Returns:
- the list of supported design attributes
-
writeAttribute
public static void writeAttribute(Object component, String attribute, org.jsoup.nodes.Attributes attr, Object defaultInstance)
Writes the specified attribute to the design if it differs from the default value got from thedefaultInstance
- Parameters:
component
- the component used to get the attribute valueattribute
- the key for the attributeattr
- the attribute list where the attribute will be writtendefaultInstance
- the default instance for comparing default values
-
writeAttribute
public static <T> void writeAttribute(String attribute, org.jsoup.nodes.Attributes attributes, T value, T defaultValue, Class<T> inputType)
Writes the given attribute value to a set of attributes if it differs from the default attribute value.- Parameters:
attribute
- the attribute keyattributes
- the set of attributes where the new attribute is writtenvalue
- the attribute valuedefaultValue
- the default attribute valueinputType
- the type of the input value
-
readAttribute
public static <T> T readAttribute(String attribute, org.jsoup.nodes.Attributes attributes, T defaultValue, Class<T> outputType)
Reads the given attribute from a set of attributes. If attribute does not exist return a given default value.- Parameters:
attribute
- the attribute keyattributes
- the set of attributes to read fromdefaultValue
- the default value to return if attribute does not existoutputType
- the output type for the attribute- Returns:
- the attribute value or the default value if the attribute is not found
-
readAttribute
public static <T> T readAttribute(String attribute, org.jsoup.nodes.Attributes attributes, Class<T> outputType)
Reads the given attribute from a set of attributes.- Parameters:
attribute
- the attribute keyattributes
- the set of attributes to read fromoutputType
- the output type for the attribute- Returns:
- the attribute value or null
-
readAlignment
public static Alignment readAlignment(org.jsoup.nodes.Attributes attr)
Read the alignment from the given child component attributes.- Parameters:
attr
- the child component attributes- Returns:
- the component alignment
- Since:
- 7.6.4
-
writeAlignment
public static void writeAlignment(org.jsoup.nodes.Element childElement, Alignment alignment)
Writes the alignment to the given child element attributes.- Parameters:
childElement
- the child elementalignment
- the component alignment- Since:
- 7.6.4
-
-