NB5 Docs► Reference Section► Binding Functions▼ conversion functions 🖺

Conversion functions simply allow values of one type to be converted to another type in an obvious way.

ByteBufferSizedHashed

Create a ByteBuffer from a long input based on a provided size function. As a 'Sized' function, the first argument is a function which determines the size of the resulting ByteBuffer. As a 'Hashed' function, the input value is hashed again before being used as value.

ByteBufferToHex

Convert the contents of the input ByteBuffer to a String as hexadecimal. This function is retained to avoid breaking previous workload definitions, but you should use {@link ToHexString} instead.

DecimalFormat

Formats a floating point value to a string using the java.text.DecimalFormat

DigestToByteBuffer

Computes the digest of the ByteBuffer on input and stores it in the output ByteBuffer. The digestTypes available are: MD2 MD5 SHA-1 SHA-224 SHA-256 SHA-384 SHA-512 SHA3-224 SHA3-256 SHA3-384 SHA3-512

DoubleToFloat

Convert the input double value to the closest float value.

EscapeJSON

Escape all special characters which are required to be escaped when found within JSON content according to the JSON spec

{@code
\b  Backspace (ascii code 08)
\f  Form feed (ascii code 0C)
\n  New line
\r  Carriage return
\t  Tab
\"  Double quote
\\  Backslash character
\/  Forward slash
}

Flow

Combine functions into one.

This function allows you to combine multiple other functions into one. This is often useful for constructing more sophisticated recipes, when you don't have the ability to use control flow or non-functional forms.

The functions will be stitched together using the same logic that VirtData uses when combining flows outside functions. That said, if the functions selected are not the right ones, then it is possible to end up with the wrong data type at the end. To remedy this, be sure to add input and output qualifiers, like long-> or ->String where appropriate, to ensure that VirtData selects the right functions within the flow.

Format

Apply the Java String.format method to an incoming object. @see Java 8 String.format(...) javadoc Note: This function can often be quite slow, so more direct methods are generally preferrable.

HTMLEntityDecode

encode HTML Entities

HTMLEntityEncode

encode HTML Entities

LongToByte

Convert the input long value to a byte, with negative values masked away.

LongToShort

Convert the input value from long to short.

ModuloToBigDecimal

Return a {@code BigDecimal} value as the result of modulo division with the specified divisor.

ModuloToBigInt

Return a {@code BigInteger} value as the result of modulo division with the specified divisor.

ModuloToBoolean

Return a boolean value as the result of modulo division with the specified divisor.

ModuloToByte

Return a byte value as the result of modulo division with the specified divisor.

ModuloToShort

Return a boolean value as the result of modulo division with the specified divisor.

SnappyComp

Compress the input using snappy compression

StringDateWrapper

This function wraps an epoch time in milliseconds into a String as specified in the format. The valid formatters are documented at @see DateTimeFormat API Docs

ToBase64String

Computes the Base64 representation of the byte image of the input long.

ToBigDecimal

Convert values to BigDecimals at configurable scale or precision.

ToBigDecimal(...) functions which take whole-numbered inputs may have a scale parameter or a custom MathContext, but not both. The scale parameter is not supported for String or Double input forms.

ToBigInt

Convert the input value to a {@code BigInteger}

ToBoolean

Convert the input value to a {@code boolean}

ToByte

Convert the input value to a {@code Byte}.

ToByteBuffer

Convert the input value to a {@code ByteBuffer}

ToCharBuffer

Convert the input string to a character buffer

ToCqlDurationNanos

Convert the input value into a {@link CqlDuration} by reading the input as total nanoseconds, assuming 30-month days.

ToDouble

Convert the input value to a double.

ToFloat

Convert the input value into a float.

ToHexString

Converts the input ByteBuffer to a hexadecimal String.

ToInetAddress

Convert the input value to a {@code InetAddress}

ToInt

Convert the input value to an int with long modulus remainder. If the scale is chosen, then the value is wrapped at this value. Otherwise, {@link Integer#MAX_VALUE} is used.

ToJSON

Convert the input object to a JSON string with Gson.

ToJSONPretty

Convert the input object to a JSON string with Gson, with pretty printing enabled.

ToLong

Convert the input value to a long.

ToMD5ByteBuffer

Converts the byte image of the input long to a MD5 digest in ByteBuffer form. Deprecated usage due to unsafe MD5 digest. Replaced with DigestToByteBuffer with MD5 when absolutely needed for existing NB tests. However, stronger encryption algorithms (e.g. SHA-256) are recommended due to MD5's limitations.

ToShort

Convert the input value to a short.

ToString

Converts the input to the most obvious string representation with String.valueOf(...). Forms which accept a function will evaluate that function first and then apply String.valueOf() to the result.

ToUUID

This function creates a non-random UUID in the type 4 version (Random). It always puts the same value in the MSB position of the UUID format. The input value is put in the LSB position. This function is suitable for deterministic testing of scenarios which depend on type 4 UUIDs, but without the mandated randomness that makes testing difficult. Just be aware that the MSB will always contain value 0x0123456789ABCDEFL unless you specify a different long value to pre-fill it with.

URLDecode

URLDecode string data

@param charset A valid character set name from {@link Charset}

URLEncode

URLEncode string data

@param charset A valid character set name from {@link Charset}

Back to top