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.ScriptAll 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:
The following classes may also be useful in scripting:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFreeplaneScriptBaseClass.ConfigPropertiesAccessor for Freeplane's configuration: In scripts available as "global variable"config.
-
Constructor Summary
Constructors Constructor Description FreeplaneScriptBaseClass()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectformat(java.lang.Object object)Applies default date-time format for dates or default number format for numbers.java.lang.Objectformat(java.lang.Object object, java.lang.String formatString)uses formatString to return a FormattedObject.java.lang.ObjectformatDate(java.util.Date date)Applies default date format (instead of standard date-time) format on the given date.java.lang.ObjectgetProperty(java.lang.String property)java.lang.ObjectifNull(java.lang.Object value, java.lang.Object valueIfNull)returns valueIfNull if value is null and value otherwise.java.lang.ObjectinvokeMethod(java.lang.String methodName, java.lang.Object args)voidloadUri(java.net.URI uri)opens aURINodeRON(java.lang.String id)Shortcut for node.map.node(id) - necessary for ids to other maps.java.lang.Objectparse(java.lang.String text)parses text to the proper data type, if possible, setting format to the standard.java.lang.Longround(java.lang.Double d)rounds a number to integral type.java.lang.Doubleround(java.lang.Double d, int precision)round to the given number of decimal places:round(0.1234, 2) → 0.12voidsetBinding(groovy.lang.Binding binding)java.lang.StringT(java.lang.String id)Shortcut for node.map.node(id).text.java.lang.StringtoString()java.lang.StringtoString(java.lang.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.java.lang.ObjectV(java.lang.String id)Shortcut for node.map.node(id).value.
-
-
-
Method Detail
-
setBinding
public void setBinding(groovy.lang.Binding binding)
- Overrides:
setBindingin classgroovy.lang.Script
-
getProperty
public java.lang.Object getProperty(java.lang.String property)
- Specified by:
getPropertyin interfacegroovy.lang.GroovyObject- Overrides:
getPropertyin classgroovy.lang.Script
-
invokeMethod
public java.lang.Object invokeMethod(java.lang.String methodName, java.lang.Object args)- Specified by:
invokeMethodin interfacegroovy.lang.GroovyObject- Overrides:
invokeMethodin classgroovy.lang.Script
-
N
public NodeRO N(java.lang.String id)
Shortcut for node.map.node(id) - necessary for ids to other maps.
-
T
public java.lang.String T(java.lang.String id)
Shortcut for node.map.node(id).text.
-
V
public java.lang.Object V(java.lang.String id)
Shortcut for node.map.node(id).value.
-
ifNull
public java.lang.Object ifNull(java.lang.Object value, java.lang.Object valueIfNull)returns valueIfNull if value is null and value otherwise.
-
round
public java.lang.Long round(java.lang.Double d)
rounds a number to integral type.
-
round
public java.lang.Double round(java.lang.Double d, int precision)round to the given number of decimal places:round(0.1234, 2) → 0.12
-
parse
public java.lang.Object parse(java.lang.String text)
parses text to the proper data type, if possible, setting format to the standard. Parsing is configured via config file scanner.xmlassert 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 java.lang.Object format(java.lang.Object object, java.lang.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:
IFormattedObjectif object is formattable and the unchanged object otherwise.
-
format
public java.lang.Object format(java.lang.Object object)
Applies default date-time format for dates or default number format for numbers. All other objects are left unchanged.- Returns:
IFormattedObjectif object is formattable and the unchanged object otherwise.
-
formatDate
public java.lang.Object formatDate(java.util.Date date)
Applies default date format (instead of standard date-time) format on the given date.- Returns:
IFormattedObjectif object is formattable and the unchanged object otherwise.
-
toString
public java.lang.String toString(java.lang.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(java.net.URI uri)
opens aURI
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-