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(java.lang.String name) |
returns true if there is any attribute with key name.
|
int |
findAttribute(java.lang.String name) |
Deprecated.
since 1.2 - use
findFirst(String) instead. |
int |
findFirst(java.lang.String name) |
returns the index of the first attribute with the given name if one exists or -1 otherwise.
|
java.util.List<? extends Convertible> |
findValues(groovy.lang.Closure<java.lang.Boolean> closure) |
returns the values of all attributes for which the closure returns true.
|
java.lang.Object |
get(int index) |
returns the attribute value at the given index.
|
java.lang.Object |
get(java.lang.String name) |
Deprecated.
|
java.util.List<java.lang.Object> |
getAll(java.lang.String name) |
returns all values for the attribute name.
|
java.util.List<java.lang.String> |
getAttributeNames() |
Deprecated.
since 1.2 use #getNames() instead.
|
java.lang.Object |
getFirst(java.lang.String name) |
returns the first value of an attribute with the given name or null otherwise.
|
java.lang.String |
getKey(int index) |
returns the attribute key at the given index.
|
java.util.Map<java.lang.String,java.lang.Object> |
getMap() |
returns all attributes as a map.
|
java.util.List<java.lang.String> |
getNames() |
returns all attribute names in the proper sequence.
|
java.util.List<? extends Convertible> |
getValues() |
returns all values as a list of
Convertible . |
boolean |
isEmpty() |
returns
getAttributeNames().isEmpty() . |
int |
size() |
the number of attributes.
|
@Deprecated java.lang.Object get(java.lang.String name)
getFirst(String)
.java.lang.Object getFirst(java.lang.String name)
boolean containsKey(java.lang.String name)
java.util.List<java.lang.Object> getAll(java.lang.String name)
java.util.List<java.lang.String> getNames()
// rename attribute int i = 0; for (String name : attributes.getNames()) { if (name.equals("xy")) attributes.set(i, "xyz", attributes.get(i)); ++i; }
java.util.List<java.lang.String> getAttributeNames()
java.util.List<? extends Convertible> getValues()
Convertible
.java.util.Map<java.lang.String,java.lang.Object> getMap()
node.attributes = otherNode.attributes.map
java.lang.Object get(int index)
java.lang.IndexOutOfBoundsException
- if index is out of range, i. e. index < 0 || index >= size()
.java.lang.String getKey(int index)
java.lang.IndexOutOfBoundsException
- if index is out of range, i. e. index < 0 || index >= size()
.int findAttribute(java.lang.String name)
findFirst(String)
instead.int findFirst(java.lang.String name)
getAttributeNames()
must be used.java.util.List<? extends Convertible> findValues(groovy.lang.Closure<java.lang.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()
.