Package org.freeplane.api
Interface Attributes
- All Superinterfaces:
- AttributesRO
- All Known Subinterfaces:
- Proxy.Attributes
Node's attribute table: 
node.attributes - read-write.
 Notes on attribute setters:
- All setter methods try to convert strings to dates, numbers or URIs.
- All setter methods apply a default formatting (for display) of the value for dates and numbers.
- Attributes don't have style properties so the value objects must know about the right formatting for themselves.
-  To enforce a certain formatting use format(): node['creationDate'] = format(new Date(), 'MM/yyyy') 
Examples:
   // == text
   node["attribute name"] = "a value"
   assert node["attribute name"].text == "a value"
   assert node.attributes.getFirst("attribute name") == "a value" // the same
   // == numbers and others
   // converts numbers and other stuff with toString()
   node["a number"] = 1.2
   assert node["a number"].text == "1.2"
   assert node["a number"].num == 1.2d
     *   // == dates
   def date = new Date()
   node["a date"] = date
   assert node["a date"].object.getClass().simpleName == "FormattedDate"
   assert node["a date"].date == format(date)
   // == enforce formats on attribute values
   node["another date"] = format(date, 'yyyy|MM|dd')
   assert node["another date"].date == format(date, 'yyyy|MM|dd')
   // change the date while keeping the silly format
   def index = node.attributes.findAttribute("another date")
   node.attributes.set(index, new Date(0L))
   // == URIs
   def uri = new URI("http://www.freeplane.org")
   node["uri"] = uri
   assert node["uri"].object.getClass().simpleName == "URI"
   assert node["uri"].object == uri
   // == remove an attribute
   node["removed attribute"] = "to be removed"
   assert node["removed attribute"] == "to be removed"
   node["removed attribute"] = null
   assert node.attributes.findFirst("removed attribute") == -1
 - 
Method SummaryModifier and TypeMethodDescriptionvoidadds an attribute no matter if an attribute with the given name already exists.voidadds an attribute with formatting pattern no matter if an attribute with the given name already exists.voidclear()removes all attributes.iterator()allows application of Groovy collection methods like each(), collect(), ...voidoptimize widths of attribute view columns according to contents.voidremove(int index) removes the attribute at the given index.booleanDeprecated.booleanremoves all attributes with this name.voidsets the value of the attribute at an index.voidsets name and value of the attribute at the given index.voidsets name, value and format pattern of the attribute at the given index.voidadds an attribute if there is no attribute with the given name or changes the value of the first attribute with the given name.voidsets format pattern to the attribute at the given index.stream()Returns stream of attributes represented by map entries.Methods inherited from interface org.freeplane.api.AttributesROcontainsKey, findAttribute, findFirst, findValues, get, get, getAll, getAttributeNames, getFirst, getKey, getMap, getNames, getTransformed, getValues, isEmpty, size
- 
Method Details- 
setsets the value of the attribute at an index. This method will not create new attributes.- Throws:
- IndexOutOfBoundsException- if index is out of range, i. e.- index < 0 || index >= size().
 
- 
setsets name and value of the attribute at the given index. This method will not create new attributes.- Throws:
- IndexOutOfBoundsException- if index is out of range, i. e.- index < 0 || index >= size().
 
- 
setsets name, value and format pattern of the attribute at the given index. This method will not create new attributes.- Throws:
- IndexOutOfBoundsException- if index is out of range, i. e.- index < 0 || index >= size().
 
- 
setFormatsets format pattern to the attribute at the given index.- Throws:
- IndexOutOfBoundsException- if index is out of range, i. e.- index < 0 || index >= size().
 
- 
removeDeprecated.before 1.1 - useremove(int)orremoveAll(String)instead.removes the first attribute with this name.- Returns:
- true on removal of an existing attribute and false otherwise.
 
- 
removeAllremoves all attributes with this name.- Returns:
- true on removal of an existing attribute and false otherwise.
 
- 
removevoid remove(int index) removes the attribute at the given index.- Throws:
- IndexOutOfBoundsException- if index is out of range, i. e.- index < 0 || index >= size().
 
- 
setadds an attribute if there is no attribute with the given name or changes the value of the first attribute with the given name.
- 
addadds an attribute no matter if an attribute with the given name already exists.
- 
addadds an attribute with formatting pattern no matter if an attribute with the given name already exists.
- 
clearvoid clear()removes all attributes.- Since:
- 1.2
 
- 
iteratorallows application of Groovy collection methods like each(), collect(), ...def keyList = node.attributes.collect { it.key } def values = node.attributes.collect { it.value } node.attributes.each { if (it.key =~ /.*day/) it.value += ' days' }- Since:
- 1.3.2
 
- 
streamReturns stream of attributes represented by map entries.- Since:
- 1.3.10
- See Also:
 
- 
optimizeWidthsvoid optimizeWidths()optimize widths of attribute view columns according to contents.- Since:
- 1.4
 
 
- 
remove(int)orremoveAll(String)instead.