- Builder
- Data Types in Codejig Builder
- Primitive Data Types
Primitive Data Types
Primitive data types store numbers, text, files, logical values and time data. They are built in core of Codejig Builder and are used as building blocks for composite types. There are 14 of them. Together they form Primitive type kind. Since Codejig generates a code in Java programming language during build and therefore many data types have exact matches in Java. However, it is not always a case and sometimes there are important differences.
Numeric types.
INTEGER is used for storing signed integers ranging from -263 to 263-1 for server side calculations. It corresponds to the java.lang.Long class in Java programming language. It has reduced value range on the client side: from -(253-1) to 253-1. Passing smaller or greater integer values from server to client is likely to result in loss of precision. Values from –(1015-1) to 1015-1 can be edited with GUI. 253-1 is a huge number (9007199254740992) and it should be sufficient for most of practical calculations. However, a special care should be taken when passing 64-bit integer identifiers from server to client or importing them via browser GUI. In such a case, INTEGER values should be first converted to or read as a STRING type before transporting them in either direction.
Type attributes |
|
Nullable |
If checked, allows for storing of null values. If not, null values are not allowed and variable of this type is initialized to FALSE. |
DOUBLE is used for storing of real numbers (or their approximations) using 64-bit floating point representation. It corresponds to java.lang.Double class in Java and behaves in the same way on server and client. It can accommodate a huge range of values but not all of them can be represented exactly. It is a recommended type for performing mathematical calculations involving non-integer numbers. However, one should take into account that numbers in this type are represented in binary numeral system. Some fractional numbers that can be represented exactly in decimal numeral system (say 1/5 as 0.2) will result in approximation involving rounding error in binary system. This is usually not a big deal, since round-off error is very small and not all the fractions can be represented exactly in decimal system either. If one takes 1/3 and tries to represent it with finite number of digits, it will result in an approximation like 0.333 ( 0.333 * 3 <> 1) . In general, calculations using DOUBLE are very accurate and fast. However, sometimes there are situations where one is more interested in keeping with the approximation rules and round-off errors of decimal representation than in overall precision of calculations. For example, if the price of whole cake is EUR 10 then if the customer buys exactly one/third of it she expects to be charged EUR 3.33 and not 3.3333333333333 even if the last value would be more precise representation of 1/3. The price of remaining part should be set as EUR 6.67 and not 6.66666666666667. In cases like this, the usage of DOUBLE should be avoided and DECIMAL type should be used instead.
Type attributes |
|
Nullable |
If checked, allows for storing of null values. If not, null values are not allowed and variable of this type is initialized to FALSE. |
DECIMAL is used to represent signed fractional numbers in decimal numeral system in a fixed-point format. The precision (number of fractional digits) can be chosen to be between 0 and 9. Decimal type uses 15 significant digits for its representation. Depending on the chosen precision the range of values that could be safely represented varies between -999999999999999 to 999999999999999 for precision 0 and between -999999.999999999 to 999999.999999999 for precision 9. Decimal data type is a recommended choice for storing of monetary values, provided that the amounts that developer deals with do not exceed 9999999999999.99 (precision 2). This range of values is sufficient to include the amounts most of small or medium-size businesses have to deal with. The data type behaves in the same way on server and client.
Type attributes |
|
Nullable |
If checked, allows for storing of null values. If not, null values are not allowed and variable of this type is initialized to 0. |
Precision |
Specifies number of significant digits in fractional part |
STRING data type stores the sequence of characters and corresponds to java.lang.String class in Java programming language.
STRING WITH TRANSLATIONS data type stores an instance of STRING type for each language defined in the application. It is a collection of pairs like <“en”, “Some text”>, <“de”, “Irgendein Text”>, <”ua”, “Якийсь текст“>. Which value is displayed, depends on the current language context. Please take a look at “How Builder handles text values and translations” to get a deeper insight into this topic.
Type attributes |
|
Translations |
If checked, allows for storing of translations for each language. If not, uses the same value for all the languages. |
HTML |
Specifies whether values contain html markup. If checked, markup is rendered and HTML editor is opened whenever STRING field value is edited. |
BOOLEAN data type stores one of two logical values: TRUE or FALSE. It corresponds to Boolean class in Java programming language and is used for tracking a state of condition.
Type attributes |
|
Nullable |
If checked, allows for storing of null values. If not, null values are not allowed and variable of this type is initialized to FALSE. |
BINARY is used for storage of binary files. Uploaded files are stored on server and can be displayed as image, video, document or download link.
Time tracking and representation has many different aspects and therefore it spawned a whole sub-group of primitive data types.
TIMESTAMP represents point in time as a number of seconds that has passed since 1970-01-01T00:00:00Z plus number of nano-seconds which is always in the interval 0…999,999,999. It corresponds to java.time.Instant class in Java programming language.
ZONED_DATE_TIME represents date-time with a time-zone like ‘2017-11-30T11:20:36+01:00 Europe/Paris’ and corresponds to java.time.ZonedDateTime class in Java programming language.
DURATION represents amount of time in terms of seconds and nano-seconds, like ’23.6’ seconds. It corresponds to java.time.Duration class in Java programming language.
LOCAL_DATE represents a date without time-zone, like ’2018-01-14’. It corresponds to java.time.LocalDate class in Java programming language.
LOCAL_TIME represents a time without time-zone, like ’09:20:44’. It corresponds to java.time.LocalTime class in Java programming language.
LOCAL_DATE_TIME represents a date-time without a time-zone, like ’2018-01-14T’09:20:44’. It corresponds to java.time.LocalDateTime class in Java programming language.
DAY_OF_WEEK represents a day of week such as ’Monday’. It corresponds to java.time.DayOfWeek enumeration in Java programming language.
MONTH represents a month of year such as ’March’. It corresponds to java.time.Month enumeration in Java programming language.
MONTH_DAY represents a combination of month and day such as ’-11-27’. It corresponds to java.time.MonthDay class in Java programming language.
YEAR represents a year such as ’2018’. It corresponds to java.time.Year class in Java programming language.
YEAR_MONTH represents a combination of year and month such as ’2018-02’. It corresponds to java.time.YearMonth class in Java programming language.
ZONE_OFFSET represents a time-zone offset from Greenwich/UTC such as ’+03:00’. It corresponds to java.time.ZoneOffset class in Java programming language.