Convertible

org.freeplane.plugin.script.proxy

## クラス Convertible

- java.lang.Object
- - groovy.lang.GroovyObjectSupport
  - - org.freeplane.plugin.script.proxy.Convertible

- すべての実装されたインタフェース:
    groovy.lang.GroovyObject

      public class Convertible
      extends groovy.lang.GroovyObjectSupport

  Utility class that is used to convert node texts to different types. It's especially important for Formulas.

- - ### コンストラクタの概要

    コンストラクタ
    コンストラクタと説明
    `Convertible(java.lang.Object text)` same as toString(text), i.e. conversion is done properly.
    `Convertible(java.lang.String text)` doesn't evaluate formulas since this would require a calculation rule or NodeModel.

  - ### メソッドの概要

    メソッド
    修飾子とタイプ | メソッドと説明
    --- | ---
    `boolean` | `asBoolean()` For implicit conversion to boolean: true if the text is not empty.
    `int` | `compareTo(Convertible convertible)`
    `int` | `compareTo(java.lang.Object string)`
    `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()` returns a Calendar for the parsed text.
    `java.util.Date` | `getDate()` returns a Date for the parsed text.
    `java.lang.Number` | `getNum()` returns a Long or a Double, whatever fits best.
    `java.lang.Number` | `getNum0()` "Safe" variant of getNum(): returns a Long or a Double if text is convertible to it or 0 otherwise (even if text is null).
    `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()`
    `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()`
    `java.lang.String` | `getText()`
    `Convertible` | `getTo()` Allow statements like this: `node['attr_name'].to.num`.
    `java.net.URI` | `getUri()`
    `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()` returns true if the text is convertible to date.
    `boolean` | `isNum()` returns true if the text is convertible to number.
    `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. to GMT timestamps, e.g.: "2010-08-16T22:31:55.123+0000".

    - ### クラスから継承されたメソッド groovy.lang.GroovyObjectSupport

      `getMetaClass, setMetaClass`

    - ### クラスから継承されたメソッド java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### コンストラクタの詳細

    - #### Convertible

          public Convertible(java.lang.String text)

      doesn't evaluate formulas since this would require a calculation rule or NodeModel.

    - #### Convertible

          public Convertible(java.lang.Object text)

      same as toString(text), i.e. conversion is done properly.

  - ### メソッドの詳細

    - #### getNum

          public java.lang.Number getNum()
                                  throws org.freeplane.plugin.script.proxy.ConversionException

      returns a Long or a Double, whatever fits best. All Java number literals are allowed as described by `Long.decode(String)`
      例外:
        `ConversionException` - if text is not a number.

    - #### getNum0

          public java.lang.Number getNum0()

      "Safe" variant of getNum(): returns a Long or a Double if text is convertible to it or 0 otherwise (even if text is null).
      例外:
        `nothing` - - on any error (long) 0 is returned.

    - #### getString

          public java.lang.String getString()

    - #### getText

          public java.lang.String getText()

    - #### getPlain

          public java.lang.String getPlain()

    - #### getDate

          public java.util.Date getDate()
                                 throws org.freeplane.plugin.script.proxy.ConversionException

      returns a Date for the parsed text. The valid date patterns are "yyyy-MM-dd HH:dd:ss.SSSZ" with optional '-', ':'. ' ' may be replaced by 'T'.
      例外:
        `ConversionException` - if the text is not convertible to a date.

    - #### getCalendar

          public java.util.Calendar getCalendar()
                                         throws org.freeplane.plugin.script.proxy.ConversionException

      returns a Calendar for the parsed text.
      例外:
        `ConversionException` - if the text is not convertible to a date.

    - #### getUri

          public java.net.URI getUri()
                              throws org.freeplane.plugin.script.proxy.ConversionException

      例外:
        `org.freeplane.plugin.script.proxy.ConversionException`

    - #### getObject

          public java.lang.Object getObject()

      Uses the following priority ranking to determine the type of the text:
      1. null
      2. Long
      3. Double
      4. Date
      5. String
      戻り値:
        Object - the type that fits best.

    - #### getTo

          public Convertible getTo()

      Allow statements like this: `node['attr_name'].to.num`.

    - #### isNum

          public boolean isNum()

      returns true if the text is convertible to number.

    - #### isDate

          public boolean isDate()

      returns true if the text is convertible to date.

    - #### getProperty

          public java.lang.Object getProperty(java.lang.String property)

      pretend we are a String if we don't provide a property for ourselves.
      定義:
        `getProperty` インタフェース内 `groovy.lang.GroovyObject`
      オーバーライド:
        `getProperty` クラス内 `groovy.lang.GroovyObjectSupport`

    - #### invokeMethod

          public 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.
      定義:
        `invokeMethod` インタフェース内 `groovy.lang.GroovyObject`
      オーバーライド:
        `invokeMethod` クラス内 `groovy.lang.GroovyObjectSupport`

    - #### toString

          public 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. to GMT timestamps, e.g.: "2010-08-16T22:31:55.123+0000".
      - null is "converted" to null
      All other types are converted via value.toString().

    - #### compareTo

          public int compareTo(java.lang.Object string)

    - #### compareTo

          public int compareTo(Convertible convertible)

    - #### hashCode

          public int hashCode()

      since equals handles Strings special we have to stick to that here too since equal objects have to have the same hasCode.
      オーバーライド:
        `hashCode` クラス内 `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object obj)

      note: if obj is a String the result is true if String.equals(text).
      オーバーライド:
        `equals` クラス内 `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      オーバーライド:
        `toString` クラス内 `java.lang.Object`

    - #### setProperty

          public void setProperty(java.lang.String property,
                         java.lang.Object newValue)

      定義:
        `setProperty` インタフェース内 `groovy.lang.GroovyObject`
      オーバーライド:
        `setProperty` クラス内 `groovy.lang.GroovyObjectSupport`

    - #### getBool

          public boolean getBool()

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

    - #### asBoolean

          public boolean asBoolean()

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