Package org.freeplane.api
Interface Convertible
-
- All Known Implementing Classes:
Convertible
public interface ConvertibleUtility wrapper class around a String that is used to convert node texts to different types. It's especially important for Formulas.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanasBoolean()For implicit conversion to boolean: true if the text is not empty.intcompareTo(java.lang.Object string)intcompareTo(Convertible convertible)booleangetBool()parses the text (case insensitive) as boolean viaBoolean.parseBoolean(String).java.util.CalendargetCalendar()Converts to Calendar if possible.java.util.DategetDate()Converts to Date if possible.java.lang.NumbergetNum()Convert to Number.java.lang.NumbergetNum0()Safe variant ofgetNum(), throws nothing - on any error (long) 0 is returned.java.lang.ObjectgetObject()Uses the following priority ranking to determine the type of the text: null Long Double Date Stringjava.lang.StringgetPlain()Removes HTML markup if necessary.java.lang.ObjectgetRaw()Returns original objectjava.lang.StringgetString()No conversion.java.lang.StringgetText()No conversion.java.net.URIgetUri()Converts to URI if possible.booleanisDate()Type check.booleanisNum()Type check.
-
-
-
Method Detail
-
getNum
java.lang.Number getNum() throws ConversionExceptionConvert to Number. All Java number literals are allowed as described byLong.decode(String)- Returns:
- a Long or a Double, whatever fits best.
- Throws:
ConversionException- if text is not a number.
-
getNum0
java.lang.Number getNum0()
Safe variant ofgetNum(), throws nothing - on any error (long) 0 is returned.- Returns:
- a Long or a Double if text is convertible to it or 0 otherwise (even if text is null).
-
getString
java.lang.String getString()
No conversion.- Returns:
- The original string.
-
getText
java.lang.String getText()
No conversion.- Returns:
- The original string.
-
getPlain
java.lang.String getPlain()
Removes HTML markup if necessary.- Returns:
- The result of
HtmlUtils.htmlToPlain(String)
-
getDate
java.util.Date getDate() throws ConversionExceptionConverts to Date if possible. The valid date patterns are "yyyy-MM-dd HH:dd:ss.SSSZ" with optional '-', ':'. ' ' may be replaced by 'T'.- Returns:
- a Date for the parsed text
- Throws:
ConversionException- if the text is not convertible to a Date.
-
getCalendar
java.util.Calendar getCalendar() throws ConversionExceptionConverts to Calendar if possible. SeegetDate()for recognized patterns.- Returns:
- a Calendar for the parsed text.
- Throws:
ConversionException- if the text is not convertible to a Date.
-
getUri
java.net.URI getUri() throws ConversionExceptionConverts to URI if possible.- Returns:
- a URI
- Throws:
ConversionException- if the text is not convertible to a URI.
-
getObject
java.lang.Object getObject()
Uses the following priority ranking to determine the type of the text:- null
- Long
- Double
- Date
- String
- Returns:
- Object - the type that fits best.
-
getRaw
java.lang.Object getRaw()
Returns original object- Returns:
- the original object
- Since:
- 1.7.4
-
isNum
boolean isNum()
Type check.- Returns:
- true if the text is convertible to number.
-
isDate
boolean isDate()
Type check.- Returns:
- true if the text is convertible to date.
-
compareTo
int compareTo(java.lang.Object string)
-
compareTo
int compareTo(Convertible convertible)
-
getBool
boolean getBool()
parses the text (case insensitive) as boolean viaBoolean.parseBoolean(String).- Returns:
- boolean
-
asBoolean
boolean asBoolean()
For implicit conversion to boolean: true if the text is not empty.- Returns:
- boolean
-
-