AttributesRO (Freeplane API 1.11.7)
Description: declaration: package: org.freeplane.api, interface: AttributesRO

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 Type
  Method
  Description
  `boolean`
  `containsKey(String 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(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.
  before 1.1 - use `get(int)`, `getFirst(String)` or `getAll(String)` instead.
  `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 of `Convertible`.
  `boolean`
  `isEmpty()`
  returns `getAttributeNames().isEmpty()`.
  `int`
  `size()`
  the number of attributes.

- ## Method Details

  - ### get

    @Deprecated Object get(String name)
    Deprecated.
    before 1.1 - use `get(int)`, `getFirst(String)` or `getAll(String)` instead.
    alias for `getFirst(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

  - ### getAll

    List<Object> getAll(String name)
    Returns:
      all values for the attribute name.

  - ### 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 of `Convertible`.
    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 - use `findFirst(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 name `getAttributeNames()` 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 of `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}

    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 is `size() == getAttributeNames().size()`.

  - ### isEmpty

    boolean isEmpty()
    returns `getAttributeNames().isEmpty()`.
    Since:
      1.2

  - ### getTransformed

    Attributes getTransformed()
    Since:
      1.7.1