Datatype DSL
Contents
Purpose
The Datatype DSL is, beside the Entity DSL, one of the most basic DSL for the Software Factory. It provides you with the most common used basic (atomic) datatypes by mapping them. It also allows you to define new simple and complex datatypes, to be used in all your projects. You will find here a couple of informations to help you understand how to use it.
Overview
The main semantic elements of the Compex Datatype DSL are the following:
- "Import" declarations - used to import external Java classes.
- "Package" - the root element that contains all the other elements. A model can contain multiple packages.
- "Datatype" declarations - the way to define datatypes that can be used in entities and beans.
- "Enum" declarations - the abstraction for Java enums.
The Datatype DSL as such is working under the hood of your application's entity model by providing acces to datatypes (Number, String, Boolean...). The figure below represents straightforward how the grammar was designed in order to make it possible for you to use and also create your own datatypes. This is the structural foundation, on which the Datatype DSL model is based on.
Datatypes Model Files
Datatype DSL model files end with the .datatype extension. Datatype models may be split into several .datatype files, as long as they have the same package declaration.
Reserved Keywords
In the following we will dive deeper into the description and the usage of datatype related and reserved keywords.
package
Datatype model files must start with a package declaration. Packages are the root element of the Datatype DSL grammar. Everything is contained in a package: Datatypes and Enums have to be defined inside the Package definition. One document can contain multiple packages with unique names.
import importStatement; package name { datatype datatypeDefinition enums enumDefinition }
import
Although Import-Statements are located above the package declaration, they are optional as you may not necessarely need to reference any external Java Classes to extend the your datatype definitions. Using an import statement is a way to make these elements available in the current namespace without having to address them by their fully qualified name.
Import statements allow the use of the '*' wildcard.
import importStatement
datatype
The Datatype DSL allows the definition of datatypes. These are translated by the inferrer into their standard Java representation. The behavior of the generator can be controlled by the datatype definitions. Datatypes defined in an .datatype file are local to that file.
There are three types of datatype definitions:
jvmType
Datatype definitons that map types to jvmType take the basic syntax of
datatype <name> jvmType <type> asPrimitive
Specifying datatypes in this manner uses an appropriate wrapper class in the generated Java code; adding the keywords asPrimitive
enforces the use of primitive datatypes where applicable:
datatype foo jvmType Integer
compiles to an Integer
whereas
datatype foo jvmType Integer asPrimitive
results in int
.
dateType
The datatypes for handling temporal information can be defined by the following statement:
datatype <name> dateType {date|time|timestamp} [options]*
Datatypes that have been defined in this manner can be used as property variables in entities and beans.
Example 1:
datatype MyDate dateType date
Example 2:
datatype MyDate dateType time
Example 3:
datatype MyDate dateType timestamp
You can also extend or constraint the datetype definition by adding one or more of the following options:
[options]: <isPast> specifies that every object of this datetype can only accept value prior its creation. <isFuture> specifies that every object of this datetype can only accept value after its creation. <isNull> specifies that any object of this datetype can have the value null. <isNotNull> specifies that the every object of this datetype can not have the value null. <'['severity = {error|info|warn} ']'> sets the severity level of a non valid value, which will be display in the UI on the corresponding field by showing either a red exclamation point(error) or a small yellow triangle(info), or blue triangle(info).
asBlob
Binary blobs can be handled by defining a datatype with the asBlob
keywords. The Java implementation of such a blob is a byte array. Appropriate persistence annotations are automatically added.
datatype <name> asBlob
After datatype definitions, the content of the .datatype file can be extended with enum
definitions.
enum
Enumerations can be handled by defining a slightly different datatype with the enum
keywords. The Java implementation of such a enum is exactly the same.
enum <name> { <Value1> [, <Value2>]* }
Custom Datatypes
In this section you will find some informations about the available custom datatypes (OSBEE).
BlobMapping
This datatype allows the use of big data as a blob.
Disclaimer / Notice
A small notice/disclaimer about the how it is used in other DSLs...
How to use existing and newly created Datatypes? => The same way it is used in the Entity DSL, Entitymock DSL and the Function Library DSL with the import keyword.
Copyright Notice
All rights are reserved by Compex Systemhaus GmbH. In particular, duplications, translations, microfilming, saving and processing in electronic systems are protected by copyright. Use of this manual is only authorized with the permission of Compex Systemhaus GmbH. Infringements of the law shall be punished in accordance with civil and penal laws. We have taken utmost care in putting together texts and images. Nevertheless, the possibility of errors cannot be completely ruled out. The Figures and information in this manual are only given as approximations unless expressly indicated as binding. Amendments to the manual due to amendments to the standard software remain reserved. Please note that the latest amendments to the manual can be accessed through our helpdesk at any time. The contractually agreed regulations of the licensing and maintenance of the standard software shall apply with regard to liability for any errors in the documentation. Guarantees, particularly guarantees of quality or durability can only be assumed for the manual insofar as its quality or durability are expressly stipulated as guaranteed. If you would like to make a suggestion, the Compex Team would be very pleased to hear from you.
(c) 2016-2024 Compex Systemhaus GmbH