Package org.freeplane.api
Interface AttributesRO
- All Known Subinterfaces:
Attributes
,Proxy.Attributes
,Proxy.AttributesRO
public interface AttributesRO
Node's attribute table:
node.attributes
- read-only.
Attributes are name - value pairs assigned to a node. A node may have multiple attributes with the same name.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(String name) int
findAttribute
(String name) Deprecated.int
returns the index of the first attribute with the given name if one exists or -1 otherwise.List<? extends Convertible>
findValues
(AttributeCondition condition) returns the values of all attributes for which the closure returns true.get
(int index) returns the attribute value at the given index.Deprecated.Deprecated.since 1.2 use #getNames() instead.returns the first value of an attribute with the given name or null otherwise.getKey
(int index) returns the attribute key at the given index.getMap()
returns all attributes as a map.getNames()
returns all attribute names in the proper sequence.List<? extends Convertible>
returns all values as a list ofConvertible
.boolean
isEmpty()
returnsgetAttributeNames().isEmpty()
.int
size()
the number of attributes.
-
Method Details
-
get
Deprecated.alias forgetFirst(String)
. -
getFirst
returns the first value of an attribute with the given name or null otherwise.- Since:
- 1.2
-
containsKey
- Returns:
- true if there is any attribute with key name.
- Since:
- 1.4
-
getAll
- Returns:
- all values for the attribute name.
-
getNames
returns all attribute names in the proper sequence. The number of names returned is equal to the number of attributes.// rename attribute int i = 0; for (String name : attributes.getNames()) { if (name.equals("xy")) attributes.set(i, "xyz", attributes.get(i)); ++i; }
-
getAttributeNames
Deprecated.since 1.2 use #getNames() instead. -
getValues
List<? extends Convertible> getValues()returns all values as a list ofConvertible
.- Since:
- 1.2
-
getMap
returns all attributes as a map. Note that this will erase duplicate keys.node.attributes = otherNode.attributes.map
- Since:
- 1.2
-
get
returns the attribute value at the given index.- Throws:
IndexOutOfBoundsException
- if index is out of range, i. e.index < 0 || index >= size()
.
-
getKey
returns the attribute key at the given index.- Throws:
IndexOutOfBoundsException
- if index is out of range, i. e.index < 0 || index >= size()
.
-
findAttribute
Deprecated.since 1.2 - usefindFirst(String)
instead. -
findFirst
returns the index of the first attribute with the given name if one exists or -1 otherwise. For searches for all attributes with a given namegetAttributeNames()
must be used.- Since:
- 1.2
-
findValues
returns the values of all attributes for which the closure returns true. The fact that the values are returned as a list ofConvertible
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}
- Parameters:
condition
- A closure that accepts two arguments (String key, Object value) and returns boolean/Boolean.- Since:
- 1.2
-
size
int size()the number of attributes. It issize() == getAttributeNames().size()
. -
isEmpty
boolean isEmpty()returnsgetAttributeNames().isEmpty()
.- Since:
- 1.2
-
getTransformed
Attributes getTransformed()- Since:
- 1.7.1
-
findFirst(String)
instead.