Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed translated content for 'zh'
Sv translation
languageen
Info

BellaDati supports all Arrays from https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html and ArrayUtils from https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/ArrayUtils.html.

Syntax: first define name of the package, then use desired method.

Example:

def int[] a = [1,2,3]
a = ArrayUtils.add(a, 0)
Arrays.sort(a)
return a[3]

 

The transformation script has built-in support for two important data types, lists and maps (Lists can be operated as arrays in Java language). Lists are used to store ordered collections of data. For example an integer list of your favorite integers might look like this:

Code Block
emptyList = []
myList = [1776, -1, 33, 99, 0, 928734928763]
return [0]

Another native data structure is called a map. A map is used to store "associative arrays" or "dictionaries". That is unordered collections of heterogeneous, named data. For example, let's say we wanted to store names with IQ scores we might have:

Code Block
emptyMap = [:]
scores = [ "Brett":100, "Pete":"Did not finish", "Andrew":86.87934 ]
return scores["Pete"]

To add data to a map, the syntax is similar to adding values to an list. For example, if Pete re-took the IQ test and got a 3, we might:

Code Block
scores["Pete"] = 3

To get the size of the collection, you can use the size() function:

Code Block
scores.size()

Looping is provided using the each() closure:

Code Block
myList.each() {
  if (it > 0) {
    return it;
  }
}

Samples

Convert bank account number to bank name

Let the column cell contains a full bank account number (eg. "54-123456789/0100") and we transform it to the bank name according to last 4 digits. The script is:

Code Block
def bankCodes = [ '0100' : 'KB', '0800' : 'CSOB'
];
code = right(value(), 4)
return bankCodescode ? bankCodescode : 'Other'
Sv translation
languageja
Info

BellaDatiが全ての配列にサポートhttps://docs.oracle.com/javase/7/docs/api/java/util/Arrays.htmlとArrayUtils からhttps://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/ArrayUtils.html.

構文:最初はパッケージの名前を定義し、目的のメソッドを使用します。

例:

def int[] a = [1,2,3]
a = ArrayUtils.add(a, 0)
Arrays.sort(a)
return a[3]

 

変換スクリプトが二つの重要なデータ型、リストとマップ向けにサポートにビルドされました(リストはJava言語で配列として動作することができます)。リストは、データの順序付けられたコレクションを格納するために使用されます。たとえば、お気に入りの整数のリストは次のようになります。

Code Block
emptyList = []
myList = [1776, -1, 33, 99, 0, 928734928763]
return [0]

別のネイティブデータ構造はマップと呼ばれます。マップは「associative arrays」または「dictionaries」を保存するために使用されます。それは指定されたデータの順序なし名前を付けたコレクションです。例えば、仮にIQ点がある名前を保存したいと言いましょう。従って以下になります。。

Code Block
emptyMap = [:]
scores = [ "Brett":100, "Pete":"Did not finish", "Andrew":86.87934 ]
return scores["Pete"]

マップにデータを追加するには、構文はリストに値を追加することと同じです。例えば、もしPete がIQテストを再受けて、3点を得た場合、以下のように設定します。

Code Block
scores["Pete"] = 3

コレクションのサイズを取得するには、size()関数を使用できます

Code Block
scores.size()

ループがeach()クロージャを使用することを提供されます

Code Block
myList.each() {
  if (it > 0) {
    return it;
  }
}

サンプル

銀行名に銀行口座番号を変換します。

カラムのセルがフル銀行口座番号("54-123456789/0100"など)が含まれて、4桁に応じて銀行名に変換します。スクリプトは次のとおりです。

Code Block
def bankCodes = [ '0100' : 'KB', '0800' : 'CSOB'
];
code = right(value(), 4)
return bankCodescode ? bankCodescode : 'Other'