Online Help TEDIDataObjectGroup

Unit JclEDI

Types

TEDIDataObjectGroup

   The TEDIDataObjectGroup class is the base class for all EDI Data classes that need to manage collections of other EDI data objects.

 Function and Property

function InternalCreateEDIDataObject: TEDIDataObject; virtual; abstract;
property CreateObjectType: TEDIDataObjectType read FCreateObjectType;

   Descendent objects must override InternalCreateEDIDataObject in order to create the proper TEDIDataObject type or types needed. The CreateObjectType property is used to control the object type that is created in InternalCreateEDIDataObject.

   In JclEDI_ANSIX12.pas: CreateObjectType is used by TEDITransactionSetLoop.

   In JclEDI_UNEDIFACT.pas: CreateObjectType is used by TEDISegment, TEDIMessageLoop, and TEDIInterchangeControl.

 Function

function InternalAssignDelimiters: TEDIDelimiters; virtual; abstract;

   Descendent objects must override this function to determine how a reference to the TEDIDelimiter object will be acquired from the parent TEDIDataObject type object.

 Function

function IndexIsValid(Index: Integer): Boolean;

   This function can be used to determine if a specified item index is valid.

 Functions and Procedures

function AddEDIDataObject: Integer;
function AppendEDIDataObject(EDIDataObject: TEDIDataObject): Integer;
function InsertEDIDataObject(InsertIndex: Integer): Integer; overload;
function InsertEDIDataObject(InsertIndex: Integer; EDIDataObject:
  TEDIDataObject): Integer; overload;
procedure DeleteEDIDataObject(Index: Integer); overload;
procedure DeleteEDIDataObject(EDIDataObject: TEDIDataObject); overload;
function AddEDIDataObjects(Count: Integer): Integer;
function AppendEDIDataObjects(EDIDataObjectArray: TEDIDataObjectArray): Integer;
function InsertEDIDataObjects(InsertIndex, Count: Integer): Integer; overload;
function InsertEDIDataObjects(InsertIndex: Integer;
  EDIDataObjectArray: TEDIDataObjectArray): Integer; overload;
procedure DeleteEDIDataObjects; overload;
procedure DeleteEDIDataObjects(Index, Count: Integer); overload;

   Item management functions and procedures.

 Function

function GetIndexPositionFromParent: Integer; virtual;

   Call this function to get the index position from the parent. If the parent is a TEDIDataObjectGroup type then a valid index will be returned.

 Property

property EDIDataObjects: TEDIDataObjectList read FEDIDataObjects;

   The property that exposes the TEDIDataObjectList object that manages the list of TEDIDataObject type objects.

 Property

property EDIDataObject[Index: Integer]: TEDIDataObject read GetEDIDataObject
  write SetEDIDataObject; default;

   This property allows direct and easy access to the TEDIDataObject objects managed by the TEDIDataObjectList object.

 Field

protected
  FGroupIsParent: Boolean;

   This protected field is used to determine if the TEDIDataObjectGroup object is allowed to assign itself as the parent of a TEDIDataObject that is created or assigned to it. By default the value is True.

   In JclEDI_ANSIX12.pas: In TEDITransactionSetLoop this value is False.

   In JclEDI_UNEDIFACT.pas: In TEDIMessageLoop this value is False.

Usage

Notes & Examples

   If the descendent object needs to maintain different types of EDI data objects be sure to set the protected FCreateObjectType field to the proper setting prior to calling any method that creates EDIDataObject types. Also InternalCreateEDIDataObject must be overridden and implemented to create different types of TEDIDataObjects.

 Example from JclEDI_UNEDIFACT.pas

function TEDISegment.AddElement: Integer;
begin
  FCreateObjectType := ediElement;
  Result := AddEDIDataObject;
end;

function TEDISegment.AddCompositeElement: Integer;
begin
  FCreateObjectType := ediCompositeElement;
  Result := AddEDIDataObject;
end;

function TEDISegment.InternalCreateEDIDataObject: TEDIDataObject;
begin
  case FCreateObjectType of
    ediElement: Result := TEDIElement.Create(Self);
    ediCompositeElement: Result := TEDICompositeElement.Create(Self);
  else
    Result := nil;
end;

   The source code in JclEDI, JclEDI_ANSIX12, and JclEDI_UNEDIFACT units demonstrate how to descend objects from this base class.