Package org.freeplane.api

# Interface Convertible

All Known Implementing Classes:
  `Convertible`

public interface Convertible
Utility wrapper class around a String that is used to convert node texts to different types. It's especially important for Formulas.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`asBoolean()`
For implicit conversion to boolean: true if the text is not empty.
`int`
`compareTo(Object string)`
`int`
`compareTo(Convertible convertible)`
`boolean`
`getBool()`
parses the text (case insensitive) as boolean via `Boolean.parseBoolean(String)`.
`Calendar`
`getCalendar()`
Converts to Calendar if possible.
`Date`
`getDate()`
Converts to Date if possible.
`Number`
`getNum()`
Convert to Number.
`Number`
`getNum0()`
Safe variant of `getNum()`, throws nothing - on any error (long) 0 is returned.
`Object`
`getObject()`
Uses the following priority ranking to determine the type of the text: null Long Double Date String
`String`
`getPlain()`
Removes HTML markup if necessary.
`Object`
`getRaw()`
Returns original object
`String`
`getString()`
No conversion.
`String`
`getText()`
No conversion.
`URI`
`getUri()`
Converts to URI if possible.
`boolean`
`isDate()`
Type check.
`boolean`
`isNum()`
Type check.

## Method Details

### getNum

Number getNum() throws ConversionException
Convert to Number. All Java number literals are allowed as described by `Long.decode(String)`

Returns:
  a Long or a Double, whatever fits best.
Throws:
  `ConversionException` - if text is not a number.

### getNum0

Number getNum0()
Safe variant of `getNum()`, 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

String getString()
No conversion.

Returns:
  The original string.

### getText

String getText()
No conversion.

Returns:
  The original string.

### getPlain

String getPlain()
Removes HTML markup if necessary.

Returns:
  The result of `HtmlUtils.htmlToPlain(String)`

### getDate

Date getDate() throws ConversionException
Converts 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

Calendar getCalendar() throws ConversionException
Converts to Calendar if possible. See `getDate()` for recognized patterns.

Returns:
  a Calendar for the parsed text.
Throws:
  `ConversionException` - if the text is not convertible to a Date.

### getUri

URI getUri() throws ConversionException
Converts to URI if possible.

Returns:
  a URI
Throws:
  `ConversionException` - if the text is not convertible to a URI.

### getObject

Object getObject()
Uses the following priority ranking to determine the type of the text:

1. null
2. Long
3. Double
4. Date
5. String

Returns:
  Object - the type that fits best.

### getRaw

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(Object string)

### compareTo

int compareTo(Convertible convertible)

### getBool

boolean getBool()
parses the text (case insensitive) as boolean via `Boolean.parseBoolean(String)`.

Returns:
  boolean

### asBoolean

boolean asBoolean()
For implicit conversion to boolean: true if the text is not empty.

Returns:
  boolean