Package org.freeplane.plugin.script

# Class FreeplaneScriptBaseClass

java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Script
org.freeplane.plugin.script.FreeplaneScriptBaseClass

All Implemented Interfaces:
  `groovy.lang.GroovyObject`

public abstract class FreeplaneScriptBaseClass extends groovy.lang.Script
All methods of this class are available as "global" methods in every script. Only documented methods are meant to be used in scripts.

The following global objects are provided as shortcuts by the binding of this class:

- ui: see `UITools`
- logger: see `LogUtils`
- htmlUtils: see `HtmlUtils`
- textUtils: see `TextUtils`
- menuUtils: see `MenuUtils`
- config: see `FreeplaneScriptBaseClass.ConfigProperties`

The following classes may also be useful in scripting:

- `FreeplaneVersion`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `FreeplaneScriptBaseClass.ConfigProperties`
  Accessor for Freeplane's configuration: In scripts available as "global variable" `config`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FreeplaneScriptBaseClass()`
  `FreeplaneScriptBaseClass(groovy.lang.Binding binding)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected groovy.lang.Binding`
  `createBinding(NodeRO nodeProxy, ControllerRO controllerProxy)`
  `Object`
  `format(Object object)`
  Applies default date-time format for dates or default number format for numbers.
  `Object`
  `format(Object object, String formatString)`
  uses formatString to return a FormattedObject.
  `Object`
  `formatDate(Date date)`
  Applies default date format (instead of standard date-time) format on the given date.
  `Object`
  `getProperty(String property)`
  `Object`
  `ifNull(Object value, Object valueIfNull)`
  returns valueIfNull if value is null and value otherwise.
  `Object`
  `invokeMethod(String methodName, Object args)`
  `void`
  `loadUri(String link)`
  opens a link
  `void`
  `loadUri(URI uri)`
  opens a `URI`
  `NodeRO`
  `N(String id)`
  Shortcut for node.map.node(id) - necessary for ids to other maps.
  `Object`
  `parse(String text)`
  parses text to the proper data type, if possible, setting format to the standard.
  `Long`
  `round(Double d)`
  rounds a number to integral type.
  `Double`
  `round(Double d, int precision)`
  round to the given number of decimal places: `round(0.1234, 2) → 0.12`
  `void`
  `setBinding(groovy.lang.Binding binding)`
  `String`
  `T(String id)`
  Shortcut for node.map.node(id).text.
  `String`
  `toString()`
  `String`
  `toString(Object o)`
  formats according to the internal standard, that is the conversion will be reversible for types that are handled special by the scripting api namely Dates and Numbers.
  `Object`
  `V(String id)`
  Shortcut for node.map.node(id).value.

  ### Methods inherited from class groovy.lang.Script

  `evaluate, evaluate, getBinding, print, printf, printf, println, println, run, run, setProperty`

  ### Methods inherited from class groovy.lang.GroovyObjectSupport

  `getMetaClass, setMetaClass`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### FreeplaneScriptBaseClass

    public FreeplaneScriptBaseClass()

  - ### FreeplaneScriptBaseClass

    public FreeplaneScriptBaseClass(groovy.lang.Binding binding)

- ## Method Details

  - ### setBinding

    public void setBinding(groovy.lang.Binding binding)
    Overrides:
      `setBinding` in class `groovy.lang.Script`

  - ### createBinding

    protected groovy.lang.Binding createBinding(NodeRO nodeProxy, ControllerRO controllerProxy)

  - ### getProperty

    public Object getProperty(String property)
    Specified by:
      `getProperty` in interface `groovy.lang.GroovyObject`
    Overrides:
      `getProperty` in class `groovy.lang.Script`

  - ### invokeMethod

    public Object invokeMethod(String methodName, Object args)
    Specified by:
      `invokeMethod` in interface `groovy.lang.GroovyObject`
    Overrides:
      `invokeMethod` in class `groovy.lang.Script`

  - ### N

    public NodeRO N(String id)
    Shortcut for node.map.node(id) - necessary for ids to other maps.

  - ### T

    public String T(String id)
    Shortcut for node.map.node(id).text.

  - ### V

    public Object V(String id)
    Shortcut for node.map.node(id).value.

  - ### ifNull

    public Object ifNull(Object value, Object valueIfNull)
    returns valueIfNull if value is null and value otherwise.

  - ### round

    public Long round(Double d)
    rounds a number to integral type.

  - ### round

    public Double round(Double d, int precision)
    round to the given number of decimal places: `round(0.1234, 2) → 0.12`

  - ### parse

    public Object parse(String text)
    parses text to the proper data type, if possible, setting format to the standard. Parsing is configured via config file scanner.xml

         assert parse('2012-11-30') instanceof Date
         assert parse('1.22') instanceof Number
         // if parsing fails the original string is returned
         assert parse('2012XX11-30') == '2012XX11-30'

         def d = parse('2012-10-30')
         c.statusInfo = "${d} is ${new Date() - d} days ago"

  - ### format

    public Object format(Object object, String formatString)
    uses formatString to return a FormattedObject.

    Note: If you want to format the node core better use the format node attribute instead:

         node.object = new Date()
         node.format = 'dd/MM/yy'

    Returns:
      `IFormattedObject` if object is formattable and the unchanged object otherwise.

  - ### format

    public Object format(Object object)
    Applies default date-time format for dates or default number format for numbers. All other objects are left unchanged.
    Returns:
      `IFormattedObject` if object is formattable and the unchanged object otherwise.

  - ### formatDate

    public Object formatDate(Date date)
    Applies default date format (instead of standard date-time) format on the given date.
    Returns:
      `IFormattedObject` if object is formattable and the unchanged object otherwise.

  - ### toString

    public String toString(Object o)
    formats according to the internal standard, that is the conversion will be reversible for types that are handled special by the scripting api namely Dates and Numbers.
    See Also:
      - `Convertible.toString(Object)`

  - ### loadUri

    public void loadUri(URI uri)
    opens a `URI`

  - ### loadUri

    public void loadUri(String link)
    opens a link

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`