Value Library

Contents

Value Library

Functions to pass java-types in JSON, typically usage is to type e.g a Geo-point value when creating nodes in node-lib.

Usage

Add the following into your build.gradle file:

dependencies {
  include 'com.enonic.xp:lib-value:${xpVersion}
}

In your JavaScript controller, add a require statement:

var valueLib = require('/lib/xp/value');

You are now free to use the library functionality.

Functions

binary

Creates a BinaryAttachment java-type.

Parameters

Name Type Description

name

string

The binary name

stream

The binary stream

Returns

object : BinaryAttachment java-type

geoPoint

Creates a GeoPoint java-type.

Parameters

Name Type Description

lat

number

Latitude

lon

number

Longitude

Returns

object : GeoPoint java-type

geoPointString

Creates a GeoPoint java-type.

Parameters

Name Type Description

value

string

Comma-separated latitude and longitude

Returns

object : GeoPoint java-type

instant

Creates a Instant java-type.

Parameters

Name Type Description

value

string | Date

An ISO-8601-formatted instant (e.g '2011-12-03T10:15:30Z') or a Date object

Returns

object : Instant java-type

localDate

Creates a LocalDate java-type.

Parameters

Name Type Description

value

string | Date

A ISO local date-time string (e.g '2011-12-03') or a Date object

Returns

object : LocalDate java-type

localDateTime

Creates a LocalDateTime java-type.

Parameters

Name Type Description

value

string | Date

A local date-time string (e.g '2007-12-03T10:15:30') or a Date object

Returns

object : LocalDateTime java-type

localTime

Creates a LocalTime java-type.

Parameters

Name Type Description

value

string | Date

A ISO local date-time string (e.g '10:15:30') or a Date object

Returns

object : LocalTime java-type

reference

Creates a Reference java-type.

Parameters

Name Type Description

value

string

A nodeId as string (e.g '1234-5678-91011')

Returns

object : Reference java-type

Contents