painless.asciidoc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. [[modules-scripting-painless]]
  2. === Painless Scripting Language
  3. experimental[The Painless scripting language is new and is still marked as experimental. The syntax or API may be changed in the future in non-backwards compatible ways if required.]
  4. _Painless_ is a simple, secure scripting language available in Elasticsearch
  5. by default. It is designed specifically for use with Elasticsearch and can
  6. safely be used with `inline` and `stored` scripting, which is enabled by
  7. default.
  8. A Painless script is essentially a single function. Painless does not provide support
  9. for defining multiple functions within a script. The Painless syntax is similar to
  10. http://groovy-lang.org/index.html[Groovy].
  11. You can use Painless anywhere a script can be used in Elasticsearch--simply set the `lang` parameter
  12. to `painless`.
  13. [[painless-features]]
  14. [float]
  15. == Painless Features
  16. * Control flow: `for` loops, `while` loops, `do/while` loops, `if/else`
  17. * Fully Typed: all available types/methods described in <<painless-api, Painless API>>
  18. * Arithmetic operators: multiplication `*`, division `/`, addition `+`, subtraction `-`, precedence `( )`
  19. * Comparison operators: less than `<`, less than or equal to `<=`, greater than `>`, greater than or equal to `>=`, equal to `==`, and not equal to `!=`, reference equals `===`, reference not equals `!==`
  20. * Boolean operators: not `!`, and `&&`, or `||`
  21. * Bitwise operators: shift left `<<`, shift right `>>`, unsigned shift `>>>`, and `&`, or `|`, xor `^`, not `~`
  22. * Shortcuts for list, map access using the dot `.` operator
  23. * Native support for regular expressions with `/pattern/`, `=~`, and `==~`
  24. [[painless-examples]]
  25. [float]
  26. == Painless Examples
  27. To illustrate how Painless works, let's load some hockey stats into an Elasticsearch index:
  28. [source,js]
  29. ----------------------------------------------------------------
  30. PUT hockey/player/_bulk?refresh
  31. {"index":{"_id":1}}
  32. {"first":"johnny","last":"gaudreau","goals":[9,27,1],"assists":[17,46,0],"gp":[26,82,1]}
  33. {"index":{"_id":2}}
  34. {"first":"sean","last":"monohan","goals":[7,54,26],"assists":[11,26,13],"gp":[26,82,82]}
  35. {"index":{"_id":3}}
  36. {"first":"jiri","last":"hudler","goals":[5,34,36],"assists":[11,62,42],"gp":[24,80,79]}
  37. {"index":{"_id":4}}
  38. {"first":"micheal","last":"frolik","goals":[4,6,15],"assists":[8,23,15],"gp":[26,82,82]}
  39. {"index":{"_id":5}}
  40. {"first":"sam","last":"bennett","goals":[5,0,0],"assists":[8,1,0],"gp":[26,1,0]}
  41. {"index":{"_id":6}}
  42. {"first":"dennis","last":"wideman","goals":[0,26,15],"assists":[11,30,24],"gp":[26,81,82]}
  43. {"index":{"_id":7}}
  44. {"first":"david","last":"jones","goals":[7,19,5],"assists":[3,17,4],"gp":[26,45,34]}
  45. {"index":{"_id":8}}
  46. {"first":"tj","last":"brodie","goals":[2,14,7],"assists":[8,42,30],"gp":[26,82,82]}
  47. {"index":{"_id":39}}
  48. {"first":"mark","last":"giordano","goals":[6,30,15],"assists":[3,30,24],"gp":[26,60,63]}
  49. {"index":{"_id":10}}
  50. {"first":"mikael","last":"backlund","goals":[3,15,13],"assists":[6,24,18],"gp":[26,82,82]}
  51. {"index":{"_id":11}}
  52. {"first":"joe","last":"colborne","goals":[3,18,13],"assists":[6,20,24],"gp":[26,67,82]}
  53. ----------------------------------------------------------------
  54. // CONSOLE
  55. // TESTSETUP
  56. [float]
  57. === Accessing Doc Values from Painless
  58. Document values can be accessed from a `Map<String,def>` named `doc`.
  59. For example, the following script calculates a player's total goals. This example uses a strongly typed `int` and a `for` loop.
  60. [source,js]
  61. ----------------------------------------------------------------
  62. GET hockey/_search
  63. {
  64. "query": {
  65. "function_score": {
  66. "script_score": {
  67. "script": {
  68. "lang": "painless",
  69. "inline": "int total = 0; for (int i = 0; i < doc['goals'].length; ++i) { total += doc['goals'][i]; } return total;"
  70. }
  71. }
  72. }
  73. }
  74. }
  75. ----------------------------------------------------------------
  76. // CONSOLE
  77. Alternatively, you could do the same thing using a script field instead of a function score:
  78. [source,js]
  79. ----------------------------------------------------------------
  80. GET hockey/_search
  81. {
  82. "query": {
  83. "match_all": {}
  84. },
  85. "script_fields": {
  86. "total_goals": {
  87. "script": {
  88. "lang": "painless",
  89. "inline": "int total = 0; for (int i = 0; i < doc['goals'].length; ++i) { total += doc['goals'][i]; } return total;"
  90. }
  91. }
  92. }
  93. }
  94. ----------------------------------------------------------------
  95. // CONSOLE
  96. The following example uses a Painless script to sort the players by their combined first and last names. The names are accessed using
  97. `doc['first'].value` and `doc['last'].value`.
  98. [source,js]
  99. ----------------------------------------------------------------
  100. GET hockey/_search
  101. {
  102. "query": {
  103. "match_all": {}
  104. },
  105. "sort": {
  106. "_script": {
  107. "type": "string",
  108. "order": "asc",
  109. "script": {
  110. "lang": "painless",
  111. "inline": "doc['first'].value + ' ' + doc['last'].value"
  112. }
  113. }
  114. }
  115. }
  116. ----------------------------------------------------------------
  117. // CONSOLE
  118. [float]
  119. === Updating Fields with Painless
  120. You can also easily update fields. You access the original source for a field as `ctx._source.<field-name>`.
  121. First, let's look at the source data for a player by submitting the following request:
  122. [source,js]
  123. ----------------------------------------------------------------
  124. GET hockey/_search
  125. {
  126. "fields": [
  127. "_id",
  128. "_source"
  129. ],
  130. "query": {
  131. "term": {
  132. "_id": 1
  133. }
  134. }
  135. }
  136. ----------------------------------------------------------------
  137. // CONSOLE
  138. To change player 1's last name to `hockey`, simply set `ctx._source.last` to the new value:
  139. [source,js]
  140. ----------------------------------------------------------------
  141. POST hockey/player/1/_update
  142. {
  143. "script": {
  144. "lang": "painless",
  145. "inline": "ctx._source.last = params.last",
  146. "params": {
  147. "last": "hockey"
  148. }
  149. }
  150. }
  151. ----------------------------------------------------------------
  152. // CONSOLE
  153. You can also add fields to a document. For example, this script adds a new field that contains
  154. the player's nickname, _hockey_.
  155. [source,js]
  156. ----------------------------------------------------------------
  157. POST hockey/player/1/_update
  158. {
  159. "script": {
  160. "lang": "painless",
  161. "inline": "ctx._source.last = params.last; ctx._source.nick = params.nick",
  162. "params": {
  163. "last": "gaudreau",
  164. "nick": "hockey"
  165. }
  166. }
  167. }
  168. ----------------------------------------------------------------
  169. // CONSOLE
  170. [float]
  171. === Regular expressions
  172. Painless's native support for regular expressions has syntax constructs:
  173. * `/pattern/`: Pattern literals create patterns. This is the only way to create
  174. a pattern in painless.
  175. * `=~`: The find operator return a `boolean`, `true` if a subsequence of the
  176. text matches, `false` otherwise.
  177. * `==~`: The match operator returns a `boolean`, `true` if the text matches,
  178. `false` if it doesn't.
  179. Using the find operator (`=~`) you can update all hockey players with "b" in
  180. their last name:
  181. [source,js]
  182. ----------------------------------------------------------------
  183. POST hockey/player/_update_by_query
  184. {
  185. "script": {
  186. "lang": "painless",
  187. "inline": "if (ctx._source.last =~ /b/) {ctx._source.last += \"matched\"} else {ctx.op = 'noop'}"
  188. }
  189. }
  190. ----------------------------------------------------------------
  191. // CONSOLE
  192. Using the match operator (`==~`) you can update all the hockey players who's
  193. names start with a consonant and end with a vowel:
  194. [source,js]
  195. ----------------------------------------------------------------
  196. POST hockey/player/_update_by_query
  197. {
  198. "script": {
  199. "lang": "painless",
  200. "inline": "if (ctx._source.last ==~ /[^aeiou].*[aeiou]/) {ctx._source.last += \"matched\"} else {ctx.op = 'noop'}"
  201. }
  202. }
  203. ----------------------------------------------------------------
  204. // CONSOLE
  205. Or you can use the `Pattern.matcher` directory to get a `Matcher` instance and
  206. remove all of the vowels in all of their names:
  207. [source,js]
  208. ----------------------------------------------------------------
  209. POST hockey/player/_update_by_query
  210. {
  211. "script": {
  212. "lang": "painless",
  213. "inline": "ctx._source.last = /[aeiou]/.matcher(ctx._source.last).replaceAll('')"
  214. }
  215. }
  216. ----------------------------------------------------------------
  217. // CONSOLE
  218. Note: all of the `_update_by_query` examples above could really do with a
  219. `query` to limit the data that they pull back. While you *could* use a
  220. <<query-dsl-script-query>> it wouldn't be as efficient as using any other query
  221. because script queries aren't able to use the inverted index to limit the
  222. documents that they have to check.
  223. The pattern syntax is just
  224. http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html[Java regular expressions].
  225. We intentionally don't allow scripts to call `Pattern.compile` to get a new
  226. pattern on the fly because building a `Pattern` is (comparatively) slow.
  227. Pattern literals (`/apattern/`) have fancy constant extraction so no matter
  228. where they show up in the painless script they are built only when the script
  229. is first used. It is fairly similar to how `String` literals work in Java.
  230. [[painless-api]]
  231. [float]
  232. == Painless API
  233. The following types are available for use in the Painless language. Most types and methods map directly to their Java equivalents--for more information, see the corresponding https://docs.oracle.com/javase/8/docs/api/java/lang/package-summary.html[Javadoc].
  234. [float]
  235. === Dynamic Types
  236. * `def` (This type can be used to represent any other type.)
  237. [float]
  238. === Basic Types
  239. * `void`
  240. * `boolean`
  241. * `short`
  242. * `char`
  243. * `int`
  244. * `long`
  245. * `float`
  246. * `double`
  247. [float]
  248. === Complex Types
  249. Non-static methods/members in superclasses are available to subclasses.
  250. Generic types with unspecified generic parameters are parameters of type `def`.
  251. -----
  252. ArithmeticException extends Exception
  253. <init>()
  254. -----
  255. -----
  256. ArrayList extends List
  257. <init>()
  258. -----
  259. -----
  260. ArrayList<Object> extends List<Object>
  261. <init>()
  262. -----
  263. -----
  264. ArrayList<String> extends List<String>
  265. <init>()
  266. -----
  267. -----
  268. Boolean extends Object
  269. <init>(boolean)
  270. static Boolean valueOf(boolean)
  271. boolean booleanValue()
  272. -----
  273. -----
  274. Character extends Object
  275. <init>(char)
  276. static Character valueOf(char)
  277. char charValue()
  278. static char MIN_VALUE
  279. static char MAX_VALUE
  280. -----
  281. -----
  282. CharSequence extends Object
  283. char charAt(int)
  284. int length()
  285. -----
  286. -----
  287. Collection extends Object
  288. boolean add(def)
  289. void clear()
  290. boolean contains(def)
  291. boolean isEmpty()
  292. Iterator iterator()
  293. boolean remove(def)
  294. int size()
  295. -----
  296. -----
  297. Collection<Object> extends Object
  298. boolean add(Object)
  299. void clear()
  300. boolean contains(Object)
  301. boolean isEmpty()
  302. Iterator iterator()
  303. boolean remove(Object)
  304. int size()
  305. -----
  306. -----
  307. Collection<String> extends Object
  308. boolean add(String)
  309. void clear()
  310. boolean contains(String)
  311. boolean isEmpty()
  312. Iterator iterator()
  313. boolean remove(String)
  314. int size()
  315. -----
  316. -----
  317. Double extends Number
  318. <init>(double)
  319. static Double valueOf(double)
  320. static double MIN_VALUE
  321. static double MAX_VALUE
  322. -----
  323. -----
  324. Exception extends Object
  325. String getMessage()
  326. -----
  327. -----
  328. Float extends Number
  329. <init>(float)
  330. static Float valueOf(float)
  331. static float MIN_VALUE
  332. static float MAX_VALUE
  333. -----
  334. -----
  335. HashMap extends Map
  336. <init>()
  337. -----
  338. -----
  339. HashMap<Object,Object> extends Map<Object,Object>
  340. <init>()
  341. -----
  342. -----
  343. HashMap<String,def> extends Map<String,def>
  344. <init>()
  345. -----
  346. -----
  347. HashMap<String,Object> extends Map<String,Object>
  348. <init>()
  349. -----
  350. -----
  351. IllegalArgument extends Exception
  352. <init>()
  353. -----
  354. -----
  355. IllegalState extends Exception
  356. <init>()
  357. -----
  358. -----
  359. Integer extends Number
  360. <init>(int)
  361. static Integer valueOf(int)
  362. static int MIN_VALUE
  363. static int MAX_VALUE
  364. -----
  365. -----
  366. Iterator extends Object
  367. boolean hasNext()
  368. def next()
  369. void remove()
  370. -----
  371. -----
  372. Iterator<String> extends Object
  373. boolean hasNext()
  374. String next()
  375. void remove()
  376. -----
  377. -----
  378. List extends Collection
  379. def set(int, def)
  380. def get(int)
  381. def remove(int)
  382. -----
  383. -----
  384. List<Object> extends Collection
  385. Object set(int, Object)
  386. Object get(int)
  387. Object remove(int)
  388. -----
  389. -----
  390. List<String> extends Collection
  391. String set(int, String)
  392. String get(int)
  393. String remove(int)
  394. -----
  395. -----
  396. Long extends Number
  397. <init>(long)
  398. static Long valueOf(long)
  399. static long MIN_VALUE
  400. static long MAX_VALUE
  401. -----
  402. -----
  403. Map extends Object
  404. def put (def, def)
  405. def get (def)
  406. def remove (def)
  407. boolean isEmpty()
  408. int size()
  409. boolean containsKey(def)
  410. boolean containsValue(def)
  411. Set keySet()
  412. Collection values()
  413. -----
  414. -----
  415. Map<Object,Object> extends Object
  416. Object put (Object, Object)
  417. Object get (Object)
  418. Object remove (Object)
  419. boolean isEmpty()
  420. int size()
  421. boolean containsKey(Object)
  422. boolean containsValue(Object)
  423. Set keySet()
  424. Collection values()
  425. -----
  426. -----
  427. Map<String,def> extends Object
  428. def put (String, def)
  429. def get (String)
  430. def remove (String)
  431. boolean isEmpty()
  432. int size()
  433. boolean containsKey(String)
  434. boolean containsValue(def)
  435. Set<String> keySet()
  436. Collection values()
  437. -----
  438. -----
  439. Map<String,Object> extends Object
  440. Object put (String, Object)
  441. Object get (String)
  442. Object remove (String)
  443. boolean isEmpty()
  444. int size()
  445. boolean containsKey(String)
  446. boolean containsValue(Object)
  447. Set<String> keySet()
  448. Collection values()
  449. -----
  450. -----
  451. Number extends Object
  452. short shortValue()
  453. short shortValue()
  454. int intValue()
  455. long longValue()
  456. float floatValue()
  457. double doubleValue()
  458. -----
  459. -----
  460. Object
  461. String toString()
  462. boolean equals(Object)
  463. int hashCode()
  464. -----
  465. -----
  466. Set extends Collection
  467. -----
  468. -----
  469. Set<Object> extends Collection<Object>
  470. -----
  471. -----
  472. Set<String> extends Collection<String>
  473. -----
  474. -----
  475. Short extends Number
  476. <init>(short)
  477. static Short valueOf(short)
  478. static short MIN_VALUE
  479. static short MAX_VALUE
  480. -----
  481. -----
  482. String extends CharSequence
  483. <init>(String)
  484. int codePointAt(int)
  485. int compareTo(String)
  486. String concat(String)
  487. boolean endsWith(String)
  488. int indexOf(String, int)
  489. boolean isEmpty()
  490. String replace(CharSequence, CharSequence)
  491. boolean startsWith(String)
  492. String substring(int, int)
  493. char[] toCharArray()
  494. String trim()
  495. -----
  496. -----
  497. NumberFormatException extends Exception
  498. <init>()
  499. -----
  500. -----
  501. Void extends Object
  502. -----
  503. [float]
  504. ==== Utility Classes
  505. -----
  506. Math
  507. static double abs(double)
  508. static float fabs(float)
  509. static long labs(long)
  510. static int iabs(int)
  511. static double acos(double)
  512. static double asin(double)
  513. static double atan(double)
  514. static double atan2(double)
  515. static double cbrt(double)
  516. static double ceil(double)
  517. static double cos(double)
  518. static double cosh(double)
  519. static double exp(double)
  520. static double expm1(double)
  521. static double floor(double)
  522. static double hypt(double, double)
  523. static double abs(double)
  524. static double log(double)
  525. static double log10(double)
  526. static double log1p(double)
  527. static double max(double, double)
  528. static float fmax(float, float)
  529. static long lmax(long, long)
  530. static int imax(int, int)
  531. static double min(double, double)
  532. static float fmin(float, float)
  533. static long lmin(long, long)
  534. static int imin(int, int)
  535. static double pow(double, double)
  536. static double random()
  537. static double rint(double)
  538. static long round(double)
  539. static double sin(double)
  540. static double sinh(double)
  541. static double sqrt(double)
  542. static double tan(double)
  543. static double tanh(double)
  544. static double toDegrees(double)
  545. static double toRadians(double)
  546. -----
  547. -----
  548. Utility
  549. static boolean NumberToboolean(Number)
  550. static char NumberTochar(Number)
  551. static Boolean NumberToBoolean(Number)
  552. static Short NumberToShort(Number)
  553. static Character NumberToCharacter(Number)
  554. static Integer NumberToInteger(Number)
  555. static Long NumberToLong(Number)
  556. static Float NumberToFloat(Number)
  557. static Double NumberToDouble(Number)
  558. static byte booleanTobyte(boolean)
  559. static short booleanToshort(boolean)
  560. static char booleanTochar(boolean)
  561. static int booleanToint(boolean)
  562. static long booleanTolong(boolean)
  563. static float booleanTofloat(boolean)
  564. static double booleanTodouble(boolean)
  565. static Integer booleanToInteger(boolean)
  566. static byte BooleanTobyte(Boolean)
  567. static short BooleanToshort(Boolean)
  568. static char BooleanTochar(Boolean)
  569. static int BooleanToint(Boolean)
  570. static long BooleanTolong(Boolean)
  571. static float BooleanTofloat(Boolean)
  572. static double BooleanTodouble(Boolean)
  573. static Byte BooleanToByte(Boolean)
  574. static Short BooleanToShort(Boolean)
  575. static Character BooleanToCharacter(Boolean)
  576. static Integer BooleanToInteger(Boolean)
  577. static Long BooleanToLong(Boolean)
  578. static Float BooleanToFloat(Boolean)
  579. static Double BooleanToDouble(Boolean)
  580. static boolean byteToboolean(byte)
  581. static Short byteToShort(byte)
  582. static Character byteToCharacter(byte)
  583. static Integer byteToInteger(byte)
  584. static Long byteToLong(byte)
  585. static Float byteToFloat(byte)
  586. static Double byteToDouble(byte)
  587. static boolean ByteToboolean(Byte)
  588. static char ByteTochar(Byte)
  589. static boolean shortToboolean(short)
  590. static Byte shortToByte(short)
  591. static Character shortToCharacter(short)
  592. static Integer shortToInteger(short)
  593. static Long shortToLong(short)
  594. static Float shortToFloat(short)
  595. static Double shortToDouble(short)
  596. static boolean ShortToboolean(Short)
  597. static char ShortTochar(Short)
  598. static boolean charToboolean(char)
  599. static Byte charToByte(char)
  600. static Short charToShort(char)
  601. static Integer charToInteger(char)
  602. static Long charToLong(char)
  603. static Float charToFloat(char)
  604. static Double charToDouble(char)
  605. static boolean CharacterToboolean(Character)
  606. static byte CharacterTobyte(Character)
  607. static short CharacterToshort(Character)
  608. static int CharacterToint(Character)
  609. static long CharacterTolong(Character)
  610. static float CharacterTofloat(Character)
  611. static double CharacterTodouble(Character)
  612. static Boolean CharacterToBoolean(Character)
  613. static Byte CharacterToByte(Character)
  614. static Short CharacterToShort(Character)
  615. static Integer CharacterToInteger(Character)
  616. static Long CharacterToLong(Character)
  617. static Float CharacterToFloat(Character)
  618. static Double CharacterToDouble(Character)
  619. static boolean intToboolean(int)
  620. static Byte intToByte(int)
  621. static Short intToShort(int)
  622. static Character intToCharacter(int)
  623. static Long intToLong(int)
  624. static Float intToFloat(int)
  625. static Double intToDouble(int)
  626. static boolean IntegerToboolean(Integer)
  627. static char IntegerTochar(Integer)
  628. static boolean longToboolean(long)
  629. static Byte longToByte(long)
  630. static Short longToShort(long)
  631. static Character longToCharacter(long)
  632. static Integer longToInteger(long)
  633. static Float longToFloat(long)
  634. static Double longToDouble(long)
  635. static boolean LongToboolean(Long)
  636. static char LongTochar(Long)
  637. static boolean floatToboolean(float)
  638. static Byte floatToByte(float)
  639. static Short floatToShort(float)
  640. static Character floatToCharacter(float)
  641. static Integer floatToInteger(float)
  642. static Long floatToLong(float)
  643. static Double floatToDouble(float)
  644. static boolean FloatToboolean(Float)
  645. static char FloatTochar(Float)
  646. static boolean doubleToboolean(double)
  647. static Byte doubleToByte(double)
  648. static Short doubleToShort(double)
  649. static Character doubleToCharacter(double)
  650. static Integer doubleToInteger(double)
  651. static Long doubleToLong(double)
  652. static Float doubleToFloat(double)
  653. static boolean DoubleToboolean(Double)
  654. static char DoubleTochar(Double)
  655. -----
  656. -----
  657. Def
  658. static boolean defToboolean(def)
  659. static byte defTobyte(def)
  660. static short defToshort(def)
  661. static char defTochar(def)
  662. static int defToint(def)
  663. static long defTolong(def)
  664. static float defTofloat(def)
  665. static double defTodouble(def)
  666. static Boolean defToBoolean(def)
  667. static Byte defToByte(def)
  668. static Character defToCharacter(def)
  669. static Integer defToInteger(def)
  670. static Long defToLong(def)
  671. static Float defToFloat(def)
  672. static Double defToDouble(def)
  673. -----