Skip to main content
Version: 2025.2

util

Methods​

createConfigForScaleImage​

createConfigForScaleImage(): ScaleImageConfig

Creates a configuration object that is used for scaling images.

Returns​

a new ScaleImageConfig object


decodeBase64String​

decodeBase64String(pText, pCharset?): string

Decodes a Base64-encoded string and returns it as plain text. For this, the text is first converted to a byte[].

Parameters​

pText
string | number | boolean

The text to be decoded, base64 encoded.

pCharset?
string | number | boolean

The character set of the text.

Returns​

string

The text as a plain string.

Throws​

May throw an exception.

Example​

var cs="US-ASCII";
var text = "This is some new text. This is some more text. This is the rest of the text.";
var textEnc = util.encodeBase64String(text);
question.showMessage(textEnc);

var textDec = util.decodeBase64String(textEnc, cs);
question.showMessage(textDec);

encodeBase64String​

encodeBase64String(pText, pCharset?): string

This method encodes a text, converting it into a Base64-encoded value. For this, the text is first converted to a byte[].

Parameters​

pText
string | number | boolean

The text to be encoded.

pCharset?
string | number | boolean

The character set of the text.

Returns​

string

The text, Base64-encoded.

Throws​

May throw an exception.

Example​

var cs="US-ASCII";
var plainText = "Think different";
var encodedText = util.encodeBase64String(plainText, cs);

executeExternal​

executeExternal(pProgramName, pArguments, pWait): string

Runs a process on the server.

Only processes that do not require any user interaction can be executed.

Otherwise, util.executeExternal() corresponds to the swing.doClientIntermediate() command with the swing.CLIENTCMD_EXECUTE detail.

If the command is run in a client context, it is also possible to open processes that require user interaction.

Parameters​

pProgramName
string | number | boolean

Name of the program to be executed.

pArguments
string[]

Command line arguments for the program.

pWait
boolean

If set to 'true', the JDito process will be interrupted until the program has terminated.

Returns​

string

The return value from the program.

Throws​

May throw an exception.

Example​

util.executeExternal("c:\temp\temp.exe", ["c:\temp\test.txt"], false);

getMimeType​

getMimeType(pFileName): string

Returns the Mime type of a file on the server.

Parameters​

pFileName
string | number | boolean

The name of the file to be evaluated, including its path.

Returns​

string

The Mime type, as a string.

Throws​

May throw an exception.

Example​

var fname = question.askQuestion("Where?", question.QUESTION_FILECHOOSER, "");
question.showMessage(util.getMimeType(fname));

getMimeTypeByContent​

getMimeTypeByContent(pContent): string

Returns the Mime type of a file. Here we explicitly use the content of the file, not the filename.

Parameters​

pContent
string | number | boolean

The content of the file encoded as a Base64 String.

Returns​

string

The Mime type, as a string.

Throws​

May throw an exception.

Throws​

AditoBase64Exception


getNewUUID​

getNewUUID(): string

Creates a new, globally unique UUID.

Returns​

string

The created UUID.

Example​

var uid = util.getNewUUID();
question.showMessage(uid); // A string with 36 characters.

getRandom​

getRandom(pNumBytes): string

Returns a random string.

Parameters​

pNumBytes
number

Length of the random number in bytes.

Returns​

string

The random number.

Throws​

May throw an exception.

Example​

var random_value = util.getRandom(42);

getVMProperty​

getVMProperty(pKey): string

Returns a VM property of the server.

Parameters​

pKey
string | number | boolean

The parameter.

Returns​

string

The value of the VM parameter.

Throws​

May throw an exception.

Example​

var key = "user.timezone";
var property = util.getVMProperty(key);

scaleImage​

scaleImage(pImage, pConfig): string

Returns an scaled instance of the given image.

Parameters​

pImage
string | number | boolean

the image that will be scaled, in base64.

pConfig

all scaling parameters, see util.createConfigForScaleImage

Returns​

string

the scaled image, in base64

Throws​

May throw an exception.


sleep​

sleep(pTime): void

Interrupts the execution on the server for the specified period.

Parameters​

pTime
number

Period during which the execution on the server is to be interrupted, specified in milliseconds.

Returns​

void

Throws​

May throw an exception.

Example​

util.sleep(60000);

toJsonArray​

toJsonArray(pMultiStringTranscoded): string

Returns a multistring encoded array as a JSON array.

Parameters​

pMultiStringTranscoded
string | number | boolean

The multistring encoded array.

Returns​

string

The JSON array.

Throws​

May throw an exception.

Example​

var multiString = "; Hans Meier; Franz Müller; Sepp Huber; Marianne Miller; Anna-Maria Maier; Beate Bauer;";
var json = util.toJsonArray(multiString);

toMultistringArray​

toMultistringArray(pJson): string

Returns a JSON array as a multistring encoded array.

Parameters​

pJson
string | number | boolean

The JSON array.

Returns​

string

The multistring encoded array.

Throws​

May throw an exception.

Example​

var arr = ["Eins", "Zwei", "Drei"];
var multi = text.encodeMS(arr);

Properties​

AUDIT_CONDITION_JDITO​

number

Audit log typ: Condition is "JDito code" for CHANGE/TRANSFER


AUDIT_CONDITION_PLAIN​

number

Audit log typ: Condition is "Plain" for CHANGE/TRANSFER


AUDIT_LOGTYPE_BLOB​

number

Audit log typ: Value is "BLOB" for INSERT/UPDATE


AUDIT_LOGTYPE_CLOB​

number

Audit log typ: Value is "CLOB" for INSERT/UPDATE


AUDIT_LOGTYPE_STRING​

number

Audit log typ: Value is "String"


DATA_BINARY​

number

data format: Binary data, Base64-encoded


DATA_TEXT​

number

data format: text


ESCAPEMODE_CHANGE​

number

Escape mode: Changes the characters.


ESCAPEMODE_DOUBLE​

number

Escape mode: Duplicates the existing characters.


ESCAPEMODE_ESCAPE​

number

Escape mode: Precedes the string with an escape character.


ESCAPEMODE_NOTHING​

number

Escape mode: No escape mode.


EXITCODE_AUTHFAILED​

string

Cause for the exit: login error


EXITCODE_DENIED​

string

Cause for the exit: denied, e.g. by autostart


EXITCODE_ERROR​

string

Cause for the exit: error


EXITCODE_EXTERN​

string

Cause for the exit: external, e.g. server shutdown, critical server error,...


EXITCODE_MANAGER​

string

Cause for the exit: request from the manager


EXITCODE_OK​

string

Cause for the exit: everything okay


EXITCODE_TIMEOUT​

string

Cause for the exit: timeout


EXPORT_ABORT​

number

Mode for the export handling if a file exists: Aborts the current export.


EXPORT_APPEND​

number

Mode for the export handling if a file exists: Appends data to the current file.


EXPORT_OVERWRITE​

number

Mode for the export handling if a file exists: Overwrites the current file.