Data Types
Data Types used in Template Engine
This article describes all the data types used in the JuniperBot Template Engine.
Some methods may have an invoke quota. Quota means how many times this method can be invoked per single template. Attempts to invoke that exceed the specified quota will be ignored and will not take any action.
literals#
Literals are the most basic expressions, check the table below:
Name | Example |
---|---|
Float | -1.5 , 5.7 , 1.0 |
Integer | -10 , 56 , 0 |
Null Reference | null |
Boolean | true или false |
String | "string in double brackets" 'apostrophe string' |
Character | 'g' |
Lists#
There are two ways to specify a list in Template Engine. It can be either by enumeration or by comprehension. To specify a list by enumeration, you need to provide every single element of the list, as shown below:
[1, 2, 3]
To specify a list by comprehension, you just need to specify both the beginning and the ending elements of the list:
[1..3]
Both examples produce the same output.
Methods#
Method | Parameters | Returns | Description |
---|---|---|---|
add(Element) |
Number String Boolean |
Boolean | Appends the specified element to the end of list. Returns true if element has been added. |
addAll(List) |
List | Boolean | Appends all of the elements in the specified collection to the end of this list. Returns true if list has changed in result. |
replace(Index, Element) |
Index: Number Element: Number String Boolean |
Number String Boolean |
Replaces the element at the specified position in this list with the specified element. Returns the element previously at the specified position. |
remove(Element) |
Number String Boolean |
Boolean | Removes the first occurrence of the specified element from this list, if it is present. Returns true if this list contained the specified element. |
removeAll(List) |
List | Boolean | Removes all elements that are contained in the specified list. Returns true if at least one element has been removed. |
removeAt(Index) |
Number | Number String Boolean |
Removes the element at the specified position in this list. Returns the element that was removed from the list. |
contains(Element) |
Number String Boolean |
Boolean | Returns true if list contains the specified element. |
containsAll(List) |
List | Boolean | Returns true if list contains all of the elements in the specified list. |
containsAny(List) |
List | Boolean | Returns true if list contains any of the elements in the specified list. |
indexOf(Element) |
Number String Boolean |
Number | Returns the index of the first occurrence of the specified element, or -1 if this list does not contain the element. |
countOf(Element) |
Number String Boolean |
Number | Returns the amount of occurrences of the specified element. |
clear() |
- | - | Removes all of the elements from this list. |
Warning
Modifying methods are only available for lists created by enumeration like the example above.
Maps#
It is also possible to represent collections of key and value pairs, so-called maps, where keys can either be Identifiers or Strings and values can take form of any kind of expression:
{ key1: 'value1', 'key 2': 'value2' }
Keep in mind that identifiers used to represent the key elements are not used as variable placeholders, instead, they are converted to their String representation. For example, the identifier key1
shown above will be converted to the String value "key1"
.
Methods#
Following methods are only available for lists created manually like the example above.
Method | Parameters | Returns | Description |
---|---|---|---|
put(Key, Value) |
Key: String Value: Number String Boolean |
Number String Boolean |
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value. Returns the previous value associated with key, or null if there was no mapping for key. |
putAll(Map) |
Map | - | Copies all of the mappings from the specified map to this map. |
putIfAbsent(Key, Value) |
Key: String Value: Number String Boolean |
Number String Boolean |
If the specified key is not already associated with a value, associates it with the given value and returns null , otherwise returns the current value. |
remove(Key) |
String | Number String Boolean |
Removes the specified key and its corresponding value from this map. Returns the previous value associated with the key, or null if the key was not present in the map. |
remove(Key, Value) |
Key: String Value: Number String Boolean |
Boolean | Removes the entry for the specified key only if it is mapped to the specified value. Returns true if entry was removed |
containsKey(Key) |
String | Boolean | Returns true if the map contains the specified key. |
containsValue(Value) |
Number String Boolean |
Boolean | Returns true if the map has at least one key associated with the specified value. |
clear() |
- | - | Removes all of the mappings from this map |
DateTime#
This data type represents date and time and allows to manipulate them.
Properties#
Property | Type | Description |
---|---|---|
millis |
Number | Milliseconds |
millisOfDay |
Number | Millis of day |
millisOfSecond |
Number | Millis of second |
secondOfDay |
Number | Second of day |
secondOfMinute |
Number | Second of minute |
minuteOfDay |
Number | Minute of day |
minuteOfHour |
Number | Minute of hour |
hourOfDay |
Number | Hour of day |
dayOfMonth |
Number | Day of month |
dayOfWeek |
Number | Day of week |
dayOfYear |
Number | Day of year |
weekOfWeekyear |
Number | Week of weekyear |
weekyear |
Number | Week year1 |
monthOfYear |
Number | Month of year |
year |
Number | Year |
yearOfCentury |
Number | Year of century |
yearOfEra |
Number | Year of era |
centuryOfEra |
Number | Century of era |
era |
Number | Era |
zoneOffset |
Number | Timezone offset in milliseconds |
isAfterNow |
Boolean | true if this date is in future |
isBeforeNow |
Boolean | true if this date is in past |
Methods#
The methods below do not modify the current instance, but return a new one.
Method | Parameters | Returns | Description |
---|---|---|---|
plusMillis(Amount) |
Number | DateTime | Returns a copy of this datetime plus the specified number of millis. |
plusSeconds(Amount) |
Number | DateTime | Returns a copy of this datetime plus the specified number of seconds. |
plusMinutes(Amount) |
Number | DateTime | Returns a copy of this datetime plus the specified number of minutes. |
plusHours(Amount) |
Number | DateTime | Returns a copy of this datetime plus the specified number of hours. |
plusDays(Amount) |
Number | DateTime | Returns a copy of this datetime plus the specified number of days. |
plusWeeks(Amount) |
Number | DateTime | Returns a copy of this datetime plus the specified number of weeks. |
plusMonths(Amount) |
Number | DateTime | Returns a copy of this datetime plus the specified number of months |
plusYears(Amount) |
Number | DateTime | Returns a copy of this datetime plus the specified number of years. |
minusMillis(Amount) |
Number | DateTime | Returns a copy of this datetime minus the specified number of millis. |
minusSeconds(Amount) |
Number | DateTime | Returns a copy of this datetime minus the specified number of seconds. |
minusMinutes(Amount) |
Number | DateTime | Returns a copy of this datetime minus the specified number of minutes. |
minusHours(Amount) |
Number | DateTime | Returns a copy of this datetime minus the specified number of hours. |
minusDays(Amount) |
Number | DateTime | Returns a copy of this datetime minus the specified number of days. |
minusWeeks(Amount) |
Number | DateTime | Returns a copy of this datetime minus the specified number of weeks. |
minusMonths(Amount) |
Number | DateTime | Returns a copy of this datetime minus the specified number of months. |
minusYears(Amount) |
Number | DateTime | Returns a copy of this datetime minus the specified number of years. |
isAfter(Date) |
DateTime | Boolean | Is this date strictly after the specified date. |
isBefore(Date) |
DateTime | Boolean | Is this date strictly before the specified date. |
-
Because the first day of the first week does not always fall on the first day of the year, sometimes the week-year will differ from the month year.
For example, in the US, the week that contains Jan 1 is always the first week. In the US, weeks also start on Sunday. If Jan 1 was a Monday, Dec 31 would belong to the same week as Jan 1, and thus the same week-year as Jan 1. Dec 30 would have a different week-year than Dec 31. ↩