Utils
Methods Summary
Type | Name | Summary |
---|---|---|
Return the byte array representation of the Base64 value. | ||
Return the String representation of the Base64 value. | ||
Return the Base64 value representation of the byteArray. | ||
. | ||
Return the string conversion of the byteArray. | ||
Format a date object to a text representation.. | ||
Format a date object to a text representation using the format and timezone given.. | ||
Format a date object to a text representation.. | ||
Format a date object to a text representation using the format, timezone, language and country given.. | ||
Returns a string containing the character for the unicode number.. | ||
Returns true if the (related)foundset exists and has records.. | ||
Returns true if the (related)foundset exists and has records.. | ||
. | ||
. | ||
Returns true when Monday is the first day of the week for your current locale setting.. | ||
Format a number to have a defined fraction.. | ||
Format a number to have a defined fraction.. | ||
Format a number to specification.. | ||
Format a number to specification.. | ||
Parse a string to a date object.. | ||
Parse a string to a date object.. | ||
Parse a string to a date object.. | ||
Parse a string to a date object.. | ||
Returns the escaped markup text (HTML/XML).. | ||
Returns the escaped markup text (HTML/XML).. | ||
Returns the escaped markup text (HTML/XML).. | ||
Formats a string according to format specifiers and arguments.. | ||
Format a string using mask.. | ||
Replaces a portion of a string with replacement text from a specified index.. | ||
Returns all words starting with capital chars.. | ||
Returns a string with the requested number of characters, starting from the left.. | ||
Returns the number of words, starting from the left.. | ||
Returns the md5 hash (encoded as base16) for specified text.. | ||
Returns the md5 hash (encoded as base64) for specified text.. | ||
Returns a substring from the original string.. | ||
Returns a substring from the original string.. | ||
Returns the PBKDF2 hash for specified text.. | ||
Returns the PBKDF2 hash for specified text.. | ||
Returns the number of times searchString appears in textString.. | ||
Returns the position of the string to search for, from a certain start position and occurrence.. | ||
Replaces a portion of a string with replacement text.. | ||
Returns the text with %%tags%% replaced, based on provided record or foundset or form.. | ||
Returns a string with the requested number of characters, starting from the right.. | ||
Returns the number of words, starting from the right.. | ||
Return the Base64 representation of the string. | ||
Return the byte array representation of the string. | ||
. | ||
Filters characters out of from a string and leaves digits, returns the number.. | ||
Filters characters out of from a string and leaves digits, returns the number.. | ||
Returns the string without leading or trailing spaces.. | ||
Returns the number of words in the text string.. | ||
Returns a datestamp from the timestamp (sets hours,minutes,seconds and milliseconds to 0).. | ||
Validates the given password against the given hash.. |
Methods Details
base64ToBytes(base64String:)
Return the byte array representation of the Base64 value
Parameters Object base64String: the Base64 encoded string to convert to byte array
Returns Array byteArray representation of the base64 string using UTF-8 charset for conversion
Sample
base64ToString(base64String:)
Return the String representation of the Base64 value
Parameters Object base64String: the Base64 value to convert to String
Returns String String decoded representation of the Base64 value using UTF-8 charset for conversion
Sample
bytesToBase64(byteArray:)
Return the Base64 value representation of the byteArray
Parameters Object byteArray: the byte array to convert to Base64 value
Returns String Base64 representation of the byte array using UTF-8 charset for conversion
Sample
bytesToHex(bytearray)
Parameters Array bytearray the byte array to convert to hex encoded string
Returns String returns hex encoded string from bytearray
Sample
bytesToString(byteArray:)
Return the string conversion of the byteArray
Parameters Object byteArray: the byte array to convert to
Returns String string representation of the byte array using UTF-8 charset for conversion
Sample
dateFormat(date, format)
Format a date object to a text representation. This will format with the system timezone for the webclient For NGClient it will use the timezone of the client, the same goes for the Smartclient (but that is the system timezone) see #dateFormat(Date,String,String) for using the actual clients timezone.
Format can be a string like: 'dd-MM-yyyy' , 'dd-MM-yyyy HH:mm' , 'MM/dd/yyyy', 'MM/dd/yyyy hh:mm aa', 'dd.MM.yyyy'. Symbols meaning is: G era designator y year Y week year M month in year d day in month h hour in am/pm (112) H hour in day (023) m minute in hour s second in minute S millisecond E day in week D day in year F day of week in month w week in year W week in month a am/pm marker z time zone k hour in day (124) K hour in am/pm (011)
Parameters Date date the date String format the format to output
Returns String the date as text
Sample
dateFormat(date, format, timezone)
Format a date object to a text representation using the format and timezone given. If the timezone is not given the timezone of the client itself will be used. see i18n.getAvailableTimeZoneIDs() to get a timezone string that can be used.
Format can be a string like: 'dd-MM-yyyy' , 'dd-MM-yyyy HH:mm' , 'MM/dd/yyyy', 'MM/dd/yyyy hh:mm aa', 'dd.MM.yyyy' Symbols meaning is: G era designator y year Y week year M month in year d day in month h hour in am/pm (112) H hour in day (023) m minute in hour s second in minute S millisecond E day in week D day in year F day of week in month w week in year W week in month a am/pm marker z time zone k hour in day (124) K hour in am/pm (011)
Parameters Date date the date String format the format to output String timezone The timezone string to use to parse the date (like GMT+3), if null then the timezone of the current client is used.
Returns String the date as text
Sample
dateFormat(date, format, language, country)
Format a date object to a text representation. This will format with the system timezone for the webclient With language and/or country the locale will be created. For NGClient it will use the timezone of the client, the same goes for the Smartclient (but that is the system timezone) see #dateFormat(Date,String,String) for using the actual clients timezone.
Format can be a string like: 'dd-MM-yyyy' , 'dd-MM-yyyy HH:mm' , 'MM/dd/yyyy', 'MM/dd/yyyy hh:mm aa', 'dd.MM.yyyy'. Symbols meaning is: G era designator y year Y week year M month in year d day in month h hour in am/pm (112) H hour in day (023) m minute in hour s second in minute S millisecond E day in week D day in year F day of week in month w week in year W week in month a am/pm marker z time zone k hour in day (124) K hour in am/pm (011)
Parameters Date date the date String format the format to output String language language used to create locale String country country used along side language to create the locale
Returns String the date as text
Sample
dateFormat(date, format, timezone, language, country)
Format a date object to a text representation using the format, timezone, language and country given. With the language and country given, the locale will be created. If the timezone is not given the timezone of the client itself will be used. see i18n.getAvailableTimeZoneIDs() to get a timezone string that can be used.
Format can be a string like: 'dd-MM-yyyy' , 'dd-MM-yyyy HH:mm' , 'MM/dd/yyyy', 'MM/dd/yyyy hh:mm aa', 'dd.MM.yyyy' Symbols meaning is: G era designator y year Y week year M month in year d day in month h hour in am/pm (112) H hour in day (023) m minute in hour s second in minute S millisecond E day in week D day in year F day of week in month w week in year W week in month a am/pm marker z time zone k hour in day (124) K hour in am/pm (011)
Parameters Date date the date String format the format to output String timezone the timezone to use the format, if null then current client timezone is used. String language language used to create locale String country country used along side language to create the locale
Returns String the date as text
Sample
getUnicodeCharacter(unicodeCharacterNumber)
Returns a string containing the character for the unicode number.
Parameters Number unicodeCharacterNumber the number indicating the unicode character
Returns String a string containing the unicode character
Sample
hasRecords(foundset)
Returns true if the (related)foundset exists and has records. Another use is, to pass a record and qualified relations string to test multiple relations/foundset at once
Parameters JSFoundSet foundset the foundset to be tested
Returns Boolean true if exists
Sample
hasRecords(record, relationString)
Returns true if the (related)foundset exists and has records. Another use is, to pass a record and qualified relations string to test multiple relations/foundset at once
Parameters JSRecord record A JSRecord to test. String relationString The relation name.
Returns Boolean true if the foundset/relation has records.
Sample
hexToBytes(hex)
Parameters String hex hex encoded string to be decoded into a byte array.
Returns Array a byte array from hex encoded string
Sample
hexToString(hex)
Parameters String hex ;
Returns String returns decoded string from hex
Sample
isMondayFirstDayOfWeek()
Returns true when Monday is the first day of the week for your current locale setting.
Returns Boolean true if Monday is first day of the week in current locale
Sample
numberFormat(number, digits)
Format a number to have a defined fraction.
Parameters Number number the number to format Number digits nr of digits
Returns String the resulting number in text
Sample
numberFormat(number, digits, language, country)
Format a number to have a defined fraction.
Parameters Number number the number to format Number digits nr of digits String language language used to create locale String country country used along side language to create the locale
Returns String the resulting number in text
Sample
numberFormat(number, format)
Format a number to specification.
Parameters Number number the number to format String format the format
Returns String the resulting number in text
Sample
numberFormat(number, format, language, country)
Format a number to specification.
Parameters Number number the number to format String format the format String language language used to create locale String country country used along side language to create the locale
Returns String the resulting number in text
Sample
parseDate(date, format)
Parse a string to a date object. This parses the date using the TimeZone of the server Format can be a string like: 'dd-MM-yyyy' , 'dd-MM-yyyy HH:mm' , 'MM/dd/yyyy', 'MM/dd/yyyy hh:mm aa', 'dd.MM.yyyy'
Parameters String date the date as text String format the format to parse the date
Returns Date the date as date object
Sample
parseDate(date, format, timezone)
Parse a string to a date object. Using the timezone that is given, if null then it formats it with the clients timezone.
see i18n.getAvailableTimeZoneIDs() to get a timezone string that can be used.
Format can be a string like: 'dd-MM-yyyy' , 'dd-MM-yyyy HH:mm' , 'MM/dd/yyyy', 'MM/dd/yyyy hh:mm aa', 'dd.MM.yyyy'
Parameters String date the date as text String format the format to parse the date String timezone The timezone string to use to parse the date (like GMT+3)
Returns Date the date as date object
Sample
parseDate(date, format, language, country)
Parse a string to a date object. Using language and country that are given, if null then it formats it with the locale of the client
Format can be a string like: 'dd-MM-yyyy' , 'dd-MM-yyyy HH:mm' , 'MM/dd/yyyy', 'MM/dd/yyyy hh:mm aa', 'dd.MM.yyyy'
Parameters String date the date as text String format the format to parse the date String language language used to create locale String country country used along side language to create the locale
Returns Date the date as date object
Sample
parseDate(date, format, timezone, language, country)
Parse a string to a date object. Using the timezone, language and country that are given, if null then it formats it with the timezone and locale of the client
see i18n.getAvailableTimeZoneIDs() to get a timezone string that can be used.
Format can be a string like: 'dd-MM-yyyy' , 'dd-MM-yyyy HH:mm' , 'MM/dd/yyyy', 'MM/dd/yyyy hh:mm aa', 'dd.MM.yyyy'
Parameters String date the date as text String format the format to parse the date String timezone The timezone string to use to parse the date (like GMT+3) String language language used to create locale String country country used along side language to create the locale
Returns Date the date as date object
Sample
stringEscapeMarkup(textString)
Returns the escaped markup text (HTML/XML).
Parameters String textString the text to process
Returns String the escaped text
Sample
stringEscapeMarkup(textString, escapeSpaces)
Returns the escaped markup text (HTML/XML).
Parameters String textString the text to process Boolean escapeSpaces indicating to escape spaces
Returns String the escaped text
Sample
stringEscapeMarkup(textString, escapeSpaces, convertToHtmlUnicodeEscapes)
Returns the escaped markup text (HTML/XML).
Parameters String textString the text to process Boolean escapeSpaces indicating to escape spaces Boolean convertToHtmlUnicodeEscapes indicating to use unicode escapes
Returns String the escaped text
Sample
stringFormat(text_to_format, parameters)
Formats a string according to format specifiers and arguments.
Parameters String text_to_format the text to format Array parameters the array with parameters
Returns String the formatted text
Sample
stringFormat(text, format)
Format a string using mask.
Parameters String text the string to format Object format the format
Returns String the resulting text
Sample
stringIndexReplace(text, i_start, i_size, replacement_text)
Replaces a portion of a string with replacement text from a specified index.
Parameters String text the text to process Number i_start the start index to work from Number i_size the size of the text to replace String replacement_text the replacement text
Returns String the changed text string
Sample
stringInitCap(text)
Returns all words starting with capital chars.
Parameters String text the text to process
Returns String the changed text
Sample
stringLeft(text, i_size)
Returns a string with the requested number of characters, starting from the left.
Parameters String text the text to process Number i_size the size of the text to return
Returns String the result text string
Sample
stringLeftWords(text, numberof_words)
Returns the number of words, starting from the left.
Parameters String text to process Number numberof_words to return
Returns String the string with number of words form the left
Sample
stringMD5HashBase16(textString)
Returns the md5 hash (encoded as base16) for specified text.
NOTE: MD5 (Message-Digest Algorythm 5) is a hash function with a 128-bit hash value, for more info see: http://en.wikipedia.org/wiki/MD5
Parameters String textString the text to process
Returns String the resulting hashString
Sample
stringMD5HashBase64(textString)
Returns the md5 hash (encoded as base64) for specified text.
NOTE: MD5 (Message-Digest Algorythm 5) is a hash function with a 128-bit hash value, for more info see: http://en.wikipedia.org/wiki/MD5
Parameters String textString the text to process
Returns String the resulting hashString
Sample
stringMiddle(text, i_start, i_size)
Returns a substring from the original string.
Parameters String text the text to process Number i_start the start index to work from Number i_size the size of the text to return
Returns String the result text string
Sample
stringMiddleWords(text, i_start, numberof_words)
Returns a substring from the original string.
Parameters String text to process Number i_start start word index Number numberof_words the word count to return
Returns String the string with number of words form the left and
Sample
stringPBKDF2Hash(textString)
Returns the PBKDF2 hash for specified text. This method is preferred above the old MD5 hash for enhanced security. It uses a default of 9999 iterations. The string that is returned can only be used in the utils.validatePBKDF2Hash(password,thisReturnValue) to check if this hash is a result of that password. This will always be false: utils.stringPBKDF2Hash("test") == utils.stringPBKDF2Hash("test"). Because for the same string in multiply calls it will not generate the same hash. So you can only check it like this: utils.validatePBKDF2Hash("test",utils.stringPBKDF2Hash("test"))
NOTE: PBKDF2 is the key hash function for the PKCS (Public-Key Cryptography) standard, for more info see: http://en.wikipedia.org/wiki/PBKDF2
Parameters String textString the text to process
Returns String the resulting hashString
Sample
stringPBKDF2Hash(textString, iterations)
Returns the PBKDF2 hash for specified text. This method is preferred above the old MD5 hash for enhanced security.
NOTE: PBKDF2 is the key hash function for the PKCS (Public-Key Cryptography) standard, for more info see: http://en.wikipedia.org/wiki/PBKDF2
Parameters String textString the text to process Number iterations how many hash iterations should be done, minimum should be 1000 or higher.
Returns String the resulting hashString
Sample
stringPatternCount(text, toSearchFor)
Returns the number of times searchString appears in textString.
Parameters String text the text to process String toSearchFor the string to search for
Returns Number the occurrenceCount that the search string is found in the text
Sample
stringPosition(textString, toSearchFor, i_start, i_occurrence)
Returns the position of the string to search for, from a certain start position and occurrence.
Parameters String textString the text to process String toSearchFor the string to search Number i_start the start index to search from Number i_occurrence the occurrence
Returns Number the position
Sample
stringReplace(text, search_text, replacement_text)
Replaces a portion of a string with replacement text.
Parameters String text the text to process String search_text the string to search String replacement_text the replacement text
Returns String the changed text string
Sample
stringReplaceTags(text, scriptable)
Returns the text with %%tags%% replaced, based on provided record or foundset or form.
Parameters String text the text tags to work with Object scriptable the javascript object or foundset,record,form to be used to fill in the tags
Returns String the text with replaced tags
Sample
stringRight(text, i_size)
Returns a string with the requested number of characters, starting from the right.
Parameters String text the text to process Number i_size the size of the text to return
Returns String the result text string
Sample
stringRightWords(text, numberof_words)
Returns the number of words, starting from the right.
Parameters String text to process Number numberof_words to return
Returns String the string with number of words form the right
Sample
stringToBase64(string:)
Return the Base64 representation of the string
Parameters Object string: the string to convert to Base64
Returns String Base64 encoded representation of the string using UTF-8 charset for conversion
Sample
stringToBytes(string:)
Return the byte array representation of the string
Parameters Object string: the string to convert to bytes
Returns Array byte array representation of the string using UTF-8 charset for conversion
Sample
stringToHex(string)
Parameters String string String to be encoded into hex
Returns String returns hex encoded string
Sample
stringToNumber(textString)
Filters characters out of from a string and leaves digits, returns the number. Uses locale decimal separator.
Parameters String textString the text to process
Returns Number the resulting number
Sample
stringToNumber(textString, decimalSeparator)
Filters characters out of from a string and leaves digits, returns the number. Decimal separator is specified as parameter.
Parameters String textString the text to process String decimalSeparator decimal separator
Returns Number the resulting number
Sample
stringTrim(textString)
Returns the string without leading or trailing spaces.
Parameters String textString the text to process
Returns String the resulting trimmed string
Sample
stringWordCount(text)
Returns the number of words in the text string.
Parameters String text the text to process
Returns Number the word count
Sample
timestampToDate(date)
Returns a datestamp from the timestamp (sets hours,minutes,seconds and milliseconds to 0).
Parameters Date date object to be stripped from its time elements
Returns Date the stripped date object
Sample
validatePBKDF2Hash(password, hash)
Validates the given password against the given hash. The hash should be generated by one of the stringPBKDF2Hash(password [,iteration]) functions. If hash is null or empty string the method will return false.
NOTE: PBKDF2 is the key hash function for the PKCS (Public-Key Cryptography) standard, for more info see: http://en.wikipedia.org/wiki/PBKDF2
Parameters String password the password to test against String hash the hash the password needs to validate to.
Returns Boolean true if his hash is valid for that password
Sample
Last updated