Presentation is loading. Please wait.

Presentation is loading. Please wait.

What’s New in the ABL in OpenEdge 11.6 Fernando Souza Software Architect June 2016.

Similar presentations


Presentation on theme: "What’s New in the ABL in OpenEdge 11.6 Fernando Souza Software Architect June 2016."— Presentation transcript:

1 What’s New in the ABL in OpenEdge 11.6 Fernando Souza Software Architect June 2016

2 2 Agenda  Single-line Comments  XREF  ABL Enums  Object Serialization  Reflection  RadForm Subclasses

3 3 Single-line Comments  Starts with //  Any text after the // is ignored //This is a comment def var vch1 as char. // This is another comment def var vch2 // Simple comment as char format "x(30)“. // RUN myproc.p.

4 4 Agenda  Single-line Comments  XREF  ABL Enums  Object Serialization  Reflection  RadForm Subclasses

5 5 XREF  Option in the COMPILER statement  Index information for queries via SEARCH entry  Prior to 11.6, only database tables or shared temp-tables  In 11.6, it includes queries on non-shared temp-tables (“local”) SEARCH tt1 ixnum TEMPTABLE WHOLE-INDEX

6 6 Agenda  Single-line Comments  XREF  ABL Enums  Object Serialization  Reflection  RadForm Subclasses

7 7 ABL Enums  Defined set of named values For example, directions: North, South, East, West  Defined in a.cls file  Enforced by the compiler  Each named value has a numeric value associated with it  Cannot be extended, implement interfaces or inherit from anything explicitly  Serializable (can be passed between ABL clients and AppServer)

8 8 Defining an ABL Enum Type  Direction.cls ENUM Direction: DEFINE ENUMNorth South East West. END ENUM. Direction Progress.Lang.Enum Progress.Lang.Object

9 9 Defining an ABL Enum Type (Cont’d)  Colors.cls ENUM Colors: DEFINE ENUMOrange Red White Gray Grey = Gray. END ENUM.

10 10 Defining Values for Enum Members  Can explicitly assign numeric values for one or more members  INT64 value ENUM Colors: DEFINE ENUM Red = 2 Blue = 4 Gray = 6 Grey = Gray. END ENUM.

11 11 Accessing Enums  Use type-name syntax def var eDirection as Direction. def var myObj as myClass. … eDirection = Direction:North. RUN validateDirection (INPUT eDirection). myObj:redirect (INPUT-OUTPUT eDirection).

12 12 ABL Enums - CASE Statement  Enum type for CASE and WHEN option(s) must match PROCEDURE validateDirection: def input parameter peDir as Direction. case peDir: when Direction:South then … when Direction:North then.. when Direction:East then …. when Direction:West then … end case. END PROCEDURE.

13 13 ABL Enums - Comparisons  Enum types for operands in comparison operators must match. def var eColor as Colors. if eColor eq Colors:White or eColor eq Colors:Red then... else if eColor ne Colors:Black then …

14 14 ABL Enums – Comparisons (Cont’d)  Comparing equivalent named values def var eColor as Colors. eColor = Colors:Grey. // This resolves to TRUE as Grey and Gray are defined // as equivalent by the enum type if eColor eq Colors:Gray then.

15 15 Methods for ABL Enums  Implicitly inherits from Progress.Lang.Enum  Methods: -GetValue() -ToString() -CompareTo() -Equals()

16 16 ABL Enums - GetValue and ToString def var eColor as Colors. eColor = Colors:Red. tblName.intField = eColor:GetValue(). // or INT(eColor) tblName.charField = eColor:ToString(). // or STRING(eColor)

17 17 Getting Enum Instance from Name/Value  All ABL enums have a GetEnum method which is strongly-typed GetEnum(member-name as char) GetEnum(numeric-value as int64) def var eColor as Colors. eColor = Colors:GetEnum(tblName.intField). eColor = Colors:GetEnum(tblName.charField).

18 18 Defining an ABL Flag Enum Type  Permissions.cls ENUM Permissions FLAGS: DEFINE ENUM None = 0 Read Write ReadWrite = Read,Write Create Delete. END ENUM. Permission Progress.Lang.FlagsEnum Progress.Lang.Enum Progress.Lang.Object

19 19 Methods for ABL Flag Enums  Implicitly inherits from Progress.Lang.FlagsEnum  Method: -IsFlagSet()  All ABL flag enum types contains the following strongly-typed methods: -SetFlag() -UnsetFlag() -ToggleFlag()  ToString() may return a comma-separated list of flags set

20 20 ABL Flag Enums : Setting Flag  Set one or more flags for a flag enum type in one of two ways: SetFlag() method Bitwise OR operator def var ePerm as Permissions. ePerm = Permissions:Read. ePerm = ePerm:SetFlag(Permissions:Write). ePerm = ePerm OR Permissions:Delete.

21 21 ABL Flag Enums: Check if Flag is Set  Check if one or more flags are set for a flag enum type in one of two ways: IsFlagSet() method Bitwise AND operator def var ePerm as Permissions. if ePerm:IsFlagSet(Permissions:Read) then... if (ePerm AND Permissions:Read) eq Permissions:Read then...

22 22 ABL Flag Enums: Other operations  Unset one or more flags for a flag enum type in one of two ways: UnsetFlag() method Bitwise NOT operator  Toggle one or more flags for a flag enum type in one of two ways: ToggleFlag() method Bitwise XOR operator

23 23 ABL Flag Enums: Dynamic Access  DYNAMIC-ENUM  ToObject() static method in Progress.Lang.Enum DYNAMIC-ENUM ( enum-type-name, member-name-or-value) ToObject(enum-type-name, member-name) ToObject(enum-type-name, numeric-value)

24 24 ABL Enums: Reflection  Progress.Lang.Class provides additional methods -Get comma-separated list of enum member names -Get comma-separated list of enum values GetEnumNames() GetEnumValues()

25 25.NET Enums  Support for.NET enums enhanced to provide: -Logical operators (EQ, NE, LT, LE, GT, GE) -Bitwise operators (OR, AND, XOR and NOT) -CASE statement -DYNAMIC-ENUM -Reflection support  NOTE: Progress.Util.EnumHelper class is not necessary anymore.

26 26 Agenda  Single-line Comments  XREF  ABL Enums  Object Serialization  Reflection  RadForm Subclasses

27 27 Object Serialization  11.4 introduced object serialization via parameter passing between ABL client and AppServer  Serialization and deserialization can now be done programmatically  Formats supported : binary and JSON  Class must be marked as SERIALIZABLE  Object graph is serialized

28 28 Object Serialization Flow Object Instance Serializer Stream Storage

29 29 Stream Classes for Supporting Serialization  For serialization support: -Progress.IO.OutputStream (abstract) -Progress.IO.FileOutputStream Write( mData as memptr, offset as int64, len as int64) FileOutputStream(fileName as char) FileOutputStream(fileName as char, appendMode as logical)

30 30 Stream Classes for Supporting Serialization (Cont’d)  For deserialization support: -Progress.IO.InputStream (abstract) -Progress.IO.FileInputStream Read( mData as memptr, offset as int64, len as int64) FileInputStream(fileName as char)

31 31 Binary Serialization  Same rules defined for parameter passing to / from AppServer  With a few exceptions, all public, protected and private data members are serialized  Class API must match during deserialization  More efficient but may be less flexible

32 32 Serializing Object - Binary Format  Progress.IO.BinarySerializer -Provides binary serialization and deserialization -Serialize() calls Write() method on class that inherits from OutputStream class passing serialized data Serialize(objectRef as Progress.Lang.Object, oStream as Progress.IO.OutputStream)

33 33 Deserializing Object - Binary Format  Progress.IO.BinarySerializer -Deserialize() calls Read() method on class that inherits from InputStream class to get the deserialized data Deserialize(inStream as Progress.IO.InputStream)

34 34 Binary Serialization Example using Progress.IO.*. def var oCustBE as CustomerBE. def var binSerializer as BinarySerializer. def var oStream as FileOutputStream. binSerializer = new BinarySerializer(). oStream = new FileOutputStream("oCust.bin"). binSerializer:Serialize(oCustBE, oStream).

35 35 Binary Deserialization Example binSerializer = new BinarySerializer(). inStream = new FileInputStream("oCust.bin"). oCustBE = CAST(binSerializer:Deserialize(inStream), CustomerBE).

36 36 JSON Serialization  By default only public data members are serialized  Can specify one or more non-public data members to be serialized via new syntax  Deserialization less strict – API doesn’t have to exactly match  Common use case is to interact with external systems  Less efficient but more flexible

37 37 Serialization of Non-Public Data Members  SERIALIZABLE keyword added to: -DEFINE VARIABLE -DEFINE PROPERTY -DEFINE TEMP-TABLE -DEFINE DATASET DEFINE [ PRIVATE | PROTECTED | PUBLIC ] [ STATIC | ABSTRACT ] [ OVERRIDE ] [ SERIALIZABLE ] PROPERTY property-name

38 38 Serializing Object - JSON Format  Progress.IO.JsonSerializer -Provides serialization and deserialization in JSON format -Serialize() and Deserialize() methods JsonSerializer (input formatted as logical)

39 39 JSON Serialization Example using Progress.IO.*. def var oCustBE as CustomerBE. def var jSerializer as JsonSerializer. def var oStream as FileOutputStream. jSerializer = new JsonSerializer(yes). oStream = new FileOutputStream("oCust.json"). jSerializer:Serialize(oCustBE, oStream).

40 40 JSON Deserialization Example jSerializer = new JsonSerializer(false). inStream = new FileInputStream("oCust.json"). oCustBE = CAST(jSerializer:Deserialize(inStream), CustomerBE).

41 41 JSON Example { "prods:version" : 1, "prods:objId" : 1, “CustomerBE": { “CustNum": 1000, “CustName": “Test", "prods:datasets": { “DsetDetails": { “TTDetails": [ { “favColor": “orange” } ] }

42 42 Agenda  Single-line Comments  XREF  ABL Enums  Object Serialization  Reflection  RadForm Subclasses

43 43 Reflection  Used for inspecting and making decisions about execution at runtime  Progress.Lang.Class provided limited support  Release 11.6 introduces: -Support for accessing information about the elements of a class -New built-in classes for Reflection

44 44 Progress.Lang.Class methods MethodsReturn GetConstructor GetConstructors Progress.Reflect.Constructor GetMethod GetMethods Progress.Reflect.Method GetProperty GetProperties Progress.Reflect.Property GetVariable GetVariables Progress.Reflect.Variable GetEvent GetEvents Progress.Reflect.Event GetInterfacesProgress.Lang.Class

45 45 GetMethods  Returns array with information about methods of a class  Public non-static GetMethods()

46 46 GetMethods with Flags  Returns information about a method of a class based on flags  New built-in flag enum Progress.Reflect.Flags GetMethods(flags as Progress.Reflect.Flags) Access ModeScopeClass level PublicStaticDeclaredOnly ProtectedInstance Private

47 47 GetMethods Example USING Progress.Reflect.*. def var pclObj as Progress.Lang.Class. def var methFlags as Flags. def var methObjArray as Method extent. plcObj = Progress.Lang.Class:GetClass("myCls"). methFlags = Flags:Public OR Flags:Static. methObjArray = plcObj:GetMethods(methFlags).

48 48 GetMethod  Returns information about a method of a class  Public non-static GetMethod( name as char, params as Progress.Lang.ParameterList) plcObj = Progress.Lang.Class:GetClass("myCls"). paramObj = new ParameterList(0). methObj = plcObj:GetMethod("ProcessInfo", paramObj).

49 49 GetMethod with Flags  Returns information about a method of a class based on flags GetMethod( name as char, flags as Progress.Reflect.Flags, params as Progress.Lang.ParameterList)

50 50 GetMethod with Flags - Example  Return public static method “ProcessInfo” with a single logical input parameter plcObj = Progress.Lang.Class:GetClass("myCls"). paramObj = new ParameterList(1). paramObj:SetParameter(1, “logical”, “input”, NO). methFlags = Flags:Public OR Flags:Static. methObj = plcObj:GetMethod("ProcessInfo", methFlags, paramObj).

51 51 Progress.Reflect.Method PropertiesMethods Name NumParameters ReturnType ReturnTypeName ReturnExtent AccessMode IsStatic GetParameters Invoke ToString

52 52 Other Progress.Reflect Classes  Similar functionality for other types of members  Progress.Reflect.Property and Progress.Reflect.Variable -Get() and Set()  Progress.Reflect.Constructor -Invoke() - instantiate object

53 53 Agenda  Single-line Comments  XREF  ABL Enums  Object Serialization  Reflection  RadForm Subclasses

54 54 RadForm Subclasses  Telerik's UI for WinForms includes three form classes: -RadForm -RadRibbonForm -ShapedForm

55 55 RadForm Subclasses (Cont’d)  We provide subclasses that extend Telerik’s forms: -Progress.Windows.OERadForm -Progress.Windows.OERadRibbonForm -Progress.Windows.OEShapedForm -Progress.Windows.MDIChildRadForm -Progress.Windows.MDIChildRadRibbonForm -Progress.Windows.MDIChildShapedForm

56


Download ppt "What’s New in the ABL in OpenEdge 11.6 Fernando Souza Software Architect June 2016."

Similar presentations


Ads by Google