B2Win Suite Documentation (Under Construction)
5.4
5.4
  • B2Win Suite Documentation
  • Scripting
    • B2Win Suite Scripting Overview
    • Scripting in B2Data
      • Custom Script Nodes
        • Custom Script
        • Source Script Node (File)
        • Source Script Node (Table)
        • Source Script Node (Object)
        • If-Else Condition
        • Condition Node
      • In DataPrep
      • Properties
      • Workflow Applications
        • Workflow #1
        • Workflow #2
    • Getting Started
    • Language Basics
    • Types & Objects
      • Primitives
      • Objects
        • Instant
        • LocalDateTime
        • LocalDate
        • LocalTime
        • JsonNode
        • ObjectNode
        • File
        • SuiteTable
        • Duration
      • Arrays & Maps
      • Row, Column, StringColumn
    • Utilities
      • Date & Time
        • InstantUtil
        • GeneralDateUtil
        • LocalDateTimeUtil
        • LocalDateUtil
        • LocalTimeUtil
        • Formatting
        • Timezones
      • Math
      • StrictMath
      • NumericUtil
      • DbUtil
      • DbExecutor
      • StateUtil
      • FileUtil
      • JsonUtil
      • HttpUtil
      • NodeInputReader
      • RandomUtil
      • HashingUtil
      • CompressionUtil
      • Logging
    • Properties
    • Context and System
      • Context
      • System
    • Configurations
      • Workflow Configuration
    • Tutorial
    • Feedback
  • B2Data
    • Workflow Settings
      • General Settings
      • Global/All Properties
      • Execution Configuration
        • General
        • Runtime
        • Compiler
        • Storage
        • Clean Up
      • Permissions
    • Nodes
      • Scheduler
    • Services Configuration
      • Power BI
Powered by GitBook
On this page
  • Arrays
  • Maps
  1. Scripting
  2. Types & Objects

Arrays & Maps

ArrayUtil & MapUtil

Arrays

An ArrayUtil is a dynamic array-like data structure that can store elements of any type. Conceptually, it behaves like an array but with additional functionalities and flexibility.

Methods

  • ArrayUtils.empty(<T>) -> Array<T>: Returns new empty array of type T.

  • add(value: T): Adds a value to the array.

  • set(index: Integer, value: T): Sets the value of the element at the given index.

  • remove(index: Integer): Removes the value in the array at index.

  • size() -> Integer: returns the size of the array.

  • clear(): Clears the array removing all it's values.

Usage

var array = ArrayUtils.empty(String);

array.add("N");
array.add("B");
array.add("C");

if (array.get(0) == "N") {
    array.set(0, "A");
}

array.add("D");
array.remove(3);

array.clear();
if (array.size() == 0) {
    return true;
}

Maps

A map represented as HashMap<Object, Object>, is a collection that associates unique keys with corresponding values, facilitating efficient retrieval and modification of data based on key references.

Syntax

A { followed by zero or more sets of key : value pairs separated by , and ending with }, e.g. { "one" : 1, "two" : 2, "three" : 3, "more": "many more" }

This syntax creates a HashMap<Object,Object>.

Empty map literal can be specified as {:}

Methods

  • create(); Map

Creates an empty map and returns it.

  • add(Map<String, Object> map, String key, Object value): void

adds a key-value pair to map. Returns nothing

  • size(); Integer

Returns number of key-value pairs in map.

  • isEmpty: Boolean

Returns true of map is empty, otherwise returns false.

  • cotainsKey(Object key): Boolean

Returns true if map contains specified key, otherwise returns false.

  • containsValue(Object value): Boolean

Returns true if map contains specified value, otherwise returns false.

  • remove(String key): Object

Removes key from Map and returns the remove value object.

  • keySet(); and values();

Return the keys and values of the map, respectively.

Usage

var map = MapUtil.create();

MapUtil.add(map, "name", "steve");
MapUtil.add(map, "age", 40);
MapUtil.add(map, "birthday", LocalDate.now());

map.values(); // returns 2023-11-22,steve,40
map.keySet(); // returns birthday,name,age
map.remove("age"); // remove, age from map and returns 40

return map; 

Or you can define map Manually:

var map = {
    "name": "steve",
    "age": 40,
    "birthday": LocalDate.now()
}
PreviousDurationNextRow, Column, StringColumn

Last updated 1 year ago

HashMaps are especially useful for defining a row in

SuiteTable