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"

(Removing all content from page)
 
(47 intermediate revisions by the same user not shown)
Line 1: Line 1:
<br>
 
  
EGL native types are in three categories:
 
 
:[[Declaring data#Values_of_simple_value_types|Simple value types]]:
 
 
::BigInt, Bytes(''n''), Date, Decimal(''n''), Decimal(''n'', ''p''),
 
 
::Float, Int, SmallFloat, SmallInt, Timestamp(''pattern'')
 
 
:[[Declaring data#Values_of_simple_reference_types|Simple reference types]]:
 
 
::Bytes, Decimal, Number, String (now a value type),
 
 
::String(''n''), Timestamp (now a value type)
 
 
:[[Declaring data#Values_of_other_reference_types|Other reference types]]:
 
 
::Any, Dictionary, List
 
 
<br>Your custom types are based on these EGL classifiers:
 
 
:Delegate, Enumeration, ExternalType, Handler,
 
:Interface, Library, Program, Record, Service
 
 
<br>
 
 
= <br> '''Values of simple value types'''  =
 
 
<source lang="java">
 
// defaults to 0
 
someVal Int;               
 
 
// defaults to null.
 
someVal Int?;     
 
 
// initializes value to 15 (future value can be null).       
 
someVal Int? = 15;         
 
 
// initializes value to 23.
 
someVal Int = 23;         
 
 
// defaults to "".
 
firstName String;
 
 
// defaults to null.         
 
firstName String?;
 
 
// initializes value to "John".       
 
firstName String = "John"; 
 
 
// number with 5 total digits (2 after the decimal point). Defaults to 000.00.           
 
amount Decimal(5,2);       
 
 
// defaults to 0.0.
 
coord Float;     
 
 
// defaults to false       
 
toggle Boolean;           
 
 
// defaults to today's date.
 
dob Date;   
 
 
// defaults to the current timestamp.
 
ts Timestamp?;
 
 
// value can be set to any value (primitive, object, etc). See the casting examples later.
 
x Any?;                   
 
</source>
 
 
= Values of simple reference types  =
 
 
<br>
 
 
<br>
 
 
= Values of other reference types  =
 
 
== Values of type Any  ==
 
 
== Values of type Dictionary  ==
 
 
== Values of type List  ==
 
 
'''Lists'''
 
 
<source lang="java">
 
 
vals Int[];                // 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 Int[4];  // new dynamic array of size 4; all values set to their default value (0 in this example)
 
 
names String[] = [ "Paul", "John", "George", "Ringo" ];  // dynamic array, initialized with 4 values
 
names[1] = "Bob";                                        // assigns the first index in the array to "Bob"
 
names[names.getSize()] = "Ken";                          // assigns the last index in the array to "Ken"
 
 
cities String[];                          // new dynamic array of size 0
 
cities.appendElement("Delta");            // appends a new value to the end of the array
 
cities.appendAll([ "Denver", "Pueblo" ]);  // appends two new values to the end of the list cities.removeElement(2);                  // removes the second value in the array
 
cities.removeAll();                        // removes all values from the array
 
 
</source>
 
 
<br> '''Constants'''
 
 
<source lang="java">
 
// 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];
 
</source>
 
 
<br>
 
 
<br> <br>
 
 
<br>
 

Latest revision as of 11:54, 10 February 2012

Back to the top