Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Declaring data"

(Values of simple value types)
(Values of simple value types)
Line 30: Line 30:
 
<source lang="java">
 
<source lang="java">
 
/* Character value types. */
 
/* Character value types. */
/* Note:  String (without parameter) will be a reference type in EDT 1.0. */
+
/* Note:  String without parameter will be a reference type in EDT 1.0. */
  
 
// defaults to "".
 
// defaults to "".
Line 36: Line 36:
  
 
// defaults to null.           
 
// defaults to null.           
firstName String?;  
+
secondName String?;  
  
 
// initializes value to "John".         
 
// initializes value to "John".         
firstName String = "John";   
+
thirdName String = "John";   
  
  
Line 48: Line 48:
  
 
// defaults to null.
 
// defaults to null.
someVal Int?;       
+
otherVal SmallInt?;       
  
 
// initializes the value to 15 and allows a future value to be null.         
 
// initializes the value to 15 and allows a future value to be null.         
someVal Int? = 15;   
+
newerVal BigInt? = 15;   
  
 
// initializes the value, which is unchangeable.
 
// initializes the value, which is unchangeable.
Line 63: Line 63:
 
amount Decimal(5,2);         
 
amount Decimal(5,2);         
  
/* date and time  
+
/* Date-and-time value types. */
  
 
// defaults to today's date.
 
// defaults to today's date.
dob Date;     
+
today Date;     
 
+
 
+
 
+
 
+
 
+
 
+
 
+
  
 +
// defaults to now. the second declaration uses the default pattern.
 +
now TIMESTAMP("ddHHmmssffffff");
 +
later TIMESTAMP("yyyyMMddHHmmss");
  
 +
/* Boolean type */
  
 
// defaults to false         
 
// defaults to false         
 
toggle Boolean;             
 
toggle Boolean;             
  
 
 
// defaults to the current timestamp.
 
ts Timestamp?;
 
  
 
// value can be set to any value (simple value, object, and so on). See the casting examples later.
 
// value can be set to any value (simple value, object, and so on). See the casting examples later.

Revision as of 13:11, 8 February 2012


EGL native types are in three categories:

Simple value types:
BigInt, Bytes(n), Date, Decimal(n), Decimal(n, p),
Float, Int, SmallFloat, SmallInt, Timestamp(pattern)
Simple reference types:
Bytes, Decimal, Number, String (now a value type),
String(n), Timestamp (now a value type)
Other reference types:
Any, Dictionary, List


Your custom types are based on these EGL classifiers:

Delegate, Enumeration, ExternalType, Handler,
Interface, Library, Program, Record, Service



Values of simple value types

/* Character value types. */
/* Note:  String without parameter will be a reference type in EDT 1.0. */
 
// defaults to "".
firstName String;
 
// defaults to null.           
secondName String?; 
 
// initializes value to "John".         
thirdName String = "John";  
 
 
/* Numeric value types. */ 
 
// defaults to 0.
someVal Int;                
 
// defaults to null.
otherVal SmallInt?;      
 
// initializes the value to 15 and allows a future value to be null.        
newerVal BigInt? = 15;  
 
// initializes the value, which is unchangeable.
const NUMBEROFDAYS Int = 7;        
 
// defaults to 0.0.
coord Float;       
 
// defaults to 000.00.
// can hold 5 digits total, with 2 after the decimal point.             
amount Decimal(5,2);        
 
/* Date-and-time value types. */
 
// defaults to today's date.
today Date;    
 
// defaults to now. the second declaration uses the default pattern.
now TIMESTAMP("ddHHmmssffffff");
later TIMESTAMP("yyyyMMddHHmmss");
 
/* Boolean type */
 
// defaults to false         
toggle Boolean;             
 
 
// value can be set to any value (simple value, object, and so on). See the casting examples later.
x Any?;

Values of simple reference types



Values of other reference types

Values of type Any

Values of type Dictionary

Values of type List

// new dynamic array of size 0
vals Int[];               
 
// dynamic list, but not instantiated (vals must be instantiated before it can be accessed)
vals Int[]?;
 
// new dynamic array of size 4; all values set to their default value (0 in this example)               
vals Int[] = new Int[4];   
 
// dynamic array, initialized with 4 values
names String[] = [ "Paul", "John", "George", "Ringo" ];   
 
// assigns the first index in the array to "Bob"
names[1] = "Bob";                               
 
// assigns the last index in the array to "Ken"          
names[names.getSize()] = "Ken";                 
 
// new dynamic array of size 0
cities String[];              
 
// appends a new value to the end of the array             
cities.appendElement("Delta");     
 
// appends two new values to the end of the list cities.
cities.appendAll([ "Denver", "Pueblo" ]);  
 
// removes the second value in the array 
removeElement(2);                   
 
// removes all values from the array
cities.removeAll();


Constants

// The value is not changeable.
const NUMBEROFDAYS Int = 7;
 
// The element values are changeable, but the name cannot refer to another list.
const MINIMUMNUMBERS INT[] = [1,2,3,4,5];





Back to the top