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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description boolean
containsKey(String name)
int
findAttribute(String name)
Deprecated.since 1.2 - usefindFirst(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(AttributeCondition condition)
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)
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.Attributes
getTransformed()
List<? extends Convertible>
getValues()
returns all values as a list ofConvertible
.boolean
isEmpty()
returnsgetAttributeNames().isEmpty()
.int
size()
the number of attributes.
-
-
-
Method Detail
-
get
@Deprecated Object get(String name)
Deprecated.alias forgetFirst(String)
.
-
getFirst
Object getFirst(String name)
returns the first value of an attribute with the given name or null otherwise.- Since:
- 1.2
-
containsKey
boolean containsKey(String name)
- Returns:
- true if there is any attribute with key name.
- Since:
- 1.4
-
getNames
List<String> 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 List<String> getAttributeNames()
Deprecated.since 1.2 use #getNames() instead.
-
getValues
List<? extends Convertible> getValues()
returns all values as a list ofConvertible
.- Since:
- 1.2
-
getMap
Map<String,Object> getMap()
returns all attributes as a map. Note that this will erase duplicate keys.node.attributes = otherNode.attributes.map
- Since:
- 1.2
-
get
Object get(int index)
returns the attribute value at the given index.- Throws:
IndexOutOfBoundsException
- if index is out of range, i. e.index < 0 || index >= size()
.
-
getKey
String getKey(int index)
returns the attribute key at the given index.- Throws:
IndexOutOfBoundsException
- if index is out of range, i. e.index < 0 || index >= size()
.
-
findAttribute
@Deprecated int findAttribute(String name)
Deprecated.since 1.2 - usefindFirst(String)
instead.
-
findFirst
int findFirst(String name)
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
List<? extends Convertible> findValues(AttributeCondition condition)
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
-
-