Proxy.Attributes
public static interface Proxy.AttributesRO
node.attributes
- read-only.
Attributes are name - value pairs assigned to a node. A node may have multiple attributes with the same name.
Modifier and Type | Method | Description |
---|---|---|
boolean |
containsKey(String name) |
returns true if there is any attribute with key name.
|
int |
findAttribute(String name) |
Deprecated.
since 1.2 - use
findFirst(String) instead. |
int |
findFirst(String name) |
returns the index of the first attribute with the given name if one exists or -1 otherwise.
|
List<? extends Convertible> |
findValues(groovy.lang.Closure<Boolean> closure) |
returns the values of all attributes for which the closure returns true.
|
Object |
get(int index) |
returns the attribute value at the given index.
|
Object |
get(String name) |
Deprecated.
|
List<Object> |
getAll(String name) |
returns all values for the attribute name.
|
List<String> |
getAttributeNames() |
Deprecated.
since 1.2 use #getNames() instead.
|
Object |
getFirst(String name) |
returns the first value of an attribute with the given name or null otherwise.
|
String |
getKey(int index) |
returns the attribute key at the given index.
|
Map<String,Object> |
getMap() |
returns all attributes as a map.
|
List<String> |
getNames() |
returns all attribute names in the proper sequence.
|
List<? extends Convertible> |
getValues() |
returns all values as a list of
Convertible . |
boolean |
isEmpty() |
returns
getAttributeNames().isEmpty() . |
int |
size() |
the number of attributes.
|
@Deprecated Object get(String name)
getFirst(String)
.Object getFirst(String name)
boolean containsKey(String name)
List<String> getNames()
// rename attribute int i = 0; for (String name : attributes.getNames()) { if (name.equals("xy")) attributes.set(i, "xyz", attributes.get(i)); ++i; }
List<? extends Convertible> getValues()
Convertible
.Map<String,Object> getMap()
node.attributes = otherNode.attributes.map
Object get(int index)
IndexOutOfBoundsException
- if index is out of range, i. e. index < 0 || index >= size()
.String getKey(int index)
IndexOutOfBoundsException
- if index is out of range, i. e. index < 0 || index >= size()
.int findAttribute(String name)
findFirst(String)
instead.int findFirst(String name)
getAttributeNames()
must be used.List<? extends Convertible> findValues(groovy.lang.Closure<Boolean> closure)
Convertible
enables conversion. The following formula sums all attributes
whose names are not equal to 'TOTAL':
= attributes.findValues{key, val -> key != 'TOTAL'}.sum(0){it.num0}
closure
- A closure that accepts two arguments (String key, Object value) and returns boolean/Boolean.int size()
size() == getAttributeNames().size()
.boolean isEmpty()
getAttributeNames().isEmpty()
.