Package org.praxislive.ide.pxr.api
Interface Attributes
public interface Attributes
Implementations of Attributes can be requested from component proxy lookup to
store key/value data for individual components.
In earlier versions of PraxisLIVE, attributes were stored as script comments.
They are now backed by the ComponentProtocol.META property. This API
still provides an easier way to merge and retrieve attributes. To listen for
changes, use a property listener on the meta property.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear(ComponentProxy cmp, String key) Clear the attribute on the given component.static <T extends org.praxislive.core.Value>
Tget(ComponentProxy cmp, Class<T> type, String key, T def) Get an attribute of a specific Value type from the given component.static Stringget(ComponentProxy cmp, String key, String def) Get a String attribute from the given component.getAttribute(String key) Get an attribute.default <T extends org.praxislive.core.Value>
TgetAttributeValue(Class<T> type, String key) Get an attribute as the specified Value type.static voidset(ComponentProxy cmp, String key, String value) Set an attribute on the given component.static voidset(ComponentProxy cmp, String key, org.praxislive.core.Value value) Set an attribute on the given component.voidsetAttribute(String key, String value) Set an attribute.default voidsetAttributeValue(String key, org.praxislive.core.Value value) Set an attribute as aValue, or clear the attribute if the value isnullor empty (seeValue.isEmpty()).
-
Method Details
-
setAttribute
Set an attribute. Anullor empty value will clear the attribute.- Parameters:
key- attribute keyvalue- attribute value
-
getAttribute
Get an attribute. If not set thennullis returned.- Parameters:
key- attribute key- Returns:
- attribute value or null
-
setAttributeValue
Set an attribute as aValue, or clear the attribute if the value isnullor empty (seeValue.isEmpty()).- Parameters:
key- attribute keyvalue- attribute value
-
getAttributeValue
Get an attribute as the specified Value type. If the attribute is not set or cannot be converted to the given type this method will returnnull.- Type Parameters:
T- value type- Parameters:
type- value type as classkey- attribute key- Returns:
- attribute as value type or null
-
clear
Clear the attribute on the given component. If the component does not support Attributes, the instruction is ignored.- Parameters:
cmp- component on which to clear attributekey- attribute key
-
get
Get a String attribute from the given component. If the component does not support attributes or the attribute is not present, the provided default value is returned.- Parameters:
cmp- component from which to get attributekey- attribute keydef- default fallback value (null allowed)- Returns:
- attribute value as String, or default
-
get
static <T extends org.praxislive.core.Value> T get(ComponentProxy cmp, Class<T> type, String key, T def) Get an attribute of a specific Value type from the given component. If the component does not support attributes, the attribute is not present, or the attribute cannot be converted to the given type, then the provided default value is returned.- Type Parameters:
T- value type- Parameters:
cmp- component from which to get attributetype- value type classkey- attribute keydef- default fallback value (null allowed)- Returns:
- attribute value as requested type, or default
-
set
Set an attribute on the given component. A null or empty value will clear the attribute. If the component does not support Attributes, the instruction is ignored.- Parameters:
cmp- component on which to set attributekey- attribute keyvalue- attribute string value or null
-
set
Set an attribute on the given component. A null or empty value will clear the attribute. If the component does not support Attributes, the instruction is ignored.- Parameters:
cmp- component on which to set attributekey- attribute keyvalue- attribute value or null
-