JythonNumberModel (FreeMarker 2.3.35 API)
Description: declaration: package: freemarker.ext.jython, class: JythonNumberModel

Package freemarker.ext.jython

# Class JythonNumberModel

java.lang.Object
freemarker.ext.jython.JythonModel
freemarker.ext.jython.JythonNumberModel

All Implemented Interfaces:
  `WrapperTemplateModel`, `AdapterTemplateModel`, `TemplateBooleanModel`, `TemplateHashModel`, `TemplateMethodModel`, `TemplateMethodModelEx`, `TemplateModel`, `TemplateNumberModel`, `TemplateScalarModel`

public class JythonNumberModel extends JythonModel implements TemplateNumberModel
Model for Jython numeric objects (`PyInteger`, `PyLong`, `PyFloat`).

- ## Field Summary

  ### Fields inherited from class freemarker.ext.jython.JythonModel

  `object, wrapper`

  ### Fields inherited from interface freemarker.template.TemplateBooleanModel

  `FALSE, TRUE`

  ### Fields inherited from interface freemarker.template.TemplateModel

  `NOTHING`

  ### Fields inherited from interface freemarker.template.TemplateScalarModel

  `EMPTY_STRING`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JythonNumberModel​(org.python.core.PyObject object, JythonWrapper wrapper)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Number`
  `getAsNumber()`
  Returns either `PyObject.__tojava__(java.lang.Class)` with `Number`.class as argument.

  ### Methods inherited from class freemarker.ext.jython.JythonModel

  `exec, get, getAdaptedObject, getAsBoolean, getAsString, getWrappedObject, isEmpty`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### JythonNumberModel

    public JythonNumberModel​(org.python.core.PyObject object, JythonWrapper wrapper)

- ## Method Details

  - ### getAsNumber

    public Number getAsNumber() throws TemplateModelException
    Returns either `PyObject.__tojava__(java.lang.Class)` with `Number`.class as argument. If that fails, returns `PyObject.__float__()`.
    Specified by:
      `getAsNumber` in interface `TemplateNumberModel`
    Returns:
      the `Number` instance associated with this number model.
    Throws:
      `TemplateModelException`