groovy.lang.GroovyObject
public class Convertible
extends groovy.lang.GroovyObjectSupport
Constructor | Description |
---|---|
Convertible(java.lang.Object text) |
Use
toString(Object) to convert to String, i.e. |
Convertible(java.lang.String text) |
Use the
text unchanged, i. |
Modifier and Type | Method | Description |
---|---|---|
boolean |
asBoolean() |
For implicit conversion to boolean: true if the text is not empty.
|
int |
compareTo(java.lang.Object string) |
|
int |
compareTo(Convertible convertible) |
|
boolean |
equals(java.lang.Object obj) |
note: if obj is a String the result is true if String.equals(text).
|
boolean |
getBool() |
parses the text (case insensitive) as boolean via
Boolean.parseBoolean(String) . |
java.util.Calendar |
getCalendar() |
Converts to Calendar if possible.
|
java.util.Date |
getDate() |
Converts to Date if possible.
|
java.lang.Number |
getNum() |
Convert to Number.
|
java.lang.Number |
getNum0() |
Safe variant of
getNum() , throws nothing - on any error (long) 0 is returned. |
java.lang.Object |
getObject() |
Uses the following priority ranking to determine the type of the text:
null
Long
Double
Date
String
|
java.lang.String |
getPlain() |
Removes HTML markup if necessary.
|
java.lang.Object |
getProperty(java.lang.String property) |
pretend we are a String if we don't provide a property for ourselves.
|
java.lang.String |
getString() |
No conversion.
|
java.lang.String |
getText() |
No conversion.
|
Convertible |
getTo() |
Allow statements like this:
node['attr_name'].to.num . |
java.net.URI |
getUri() |
Converts to URI if possible.
|
int |
hashCode() |
since equals handles Strings special we have to stick to that here too since
equal objects have to have the same hasCode.
|
java.lang.Object |
invokeMethod(java.lang.String name,
java.lang.Object args) |
pretend we are a String if we don't provide a method for ourselves.
|
boolean |
isDate() |
Type check.
|
boolean |
isNum() |
Type check.
|
void |
setProperty(java.lang.String property,
java.lang.Object newValue) |
|
java.lang.String |
toString() |
|
static java.lang.String |
toString(java.lang.Object value) |
has special conversions for
Date and Calendar are converted by
org.apache.commons.lang.time.DateFormatUtils.format(date, "yyyy-MM-dd'T'HH:mm:ss.SSSZ"), i.e.
|
public Convertible(java.lang.String text)
text
unchanged, i. e. oesn't evaluate formulas since this would require
a calculation rule or NodeModel.text
- the String to convert.public Convertible(java.lang.Object text)
toString(Object)
to convert to String, i.e. conversion is done properly.text
- the Object to convertpublic java.lang.Number getNum() throws org.freeplane.plugin.script.proxy.ConversionException
Long.decode(String)
org.freeplane.plugin.script.proxy.ConversionException
- if text is not a number.public java.lang.Number getNum0()
getNum()
, throws nothing - on any error (long) 0 is returned.public java.lang.String getString()
public java.lang.String getText()
public java.lang.String getPlain()
HtmlUtils.htmlToPlain(String)
public java.util.Date getDate() throws org.freeplane.plugin.script.proxy.ConversionException
org.freeplane.plugin.script.proxy.ConversionException
- if the text is not convertible to a Date.public java.util.Calendar getCalendar() throws org.freeplane.plugin.script.proxy.ConversionException
getDate()
for recognized patterns.org.freeplane.plugin.script.proxy.ConversionException
- if the text is not convertible to a Date.public java.net.URI getUri() throws org.freeplane.plugin.script.proxy.ConversionException
org.freeplane.plugin.script.proxy.ConversionException
- if the text is not convertible to a URI.public java.lang.Object getObject()
public Convertible getTo()
node['attr_name'].to.num
.public boolean isNum()
public boolean isDate()
public java.lang.Object getProperty(java.lang.String property)
getProperty
in interface groovy.lang.GroovyObject
getProperty
in class groovy.lang.GroovyObjectSupport
property
- a property of String
, e. g. "bytes".public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
invokeMethod
in interface groovy.lang.GroovyObject
invokeMethod
in class groovy.lang.GroovyObjectSupport
name
- method nameargs
- method argspublic static java.lang.String toString(java.lang.Object value)
value
- the object to convertpublic int compareTo(java.lang.Object string)
public int compareTo(Convertible convertible)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public void setProperty(java.lang.String property, java.lang.Object newValue)
setProperty
in interface groovy.lang.GroovyObject
setProperty
in class groovy.lang.GroovyObjectSupport
public boolean getBool()
Boolean.parseBoolean(String)
.public boolean asBoolean()