Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WBRIDGE and version 24.0
Info

This page explains the Flat File Adapter in Bridge context. If you were looking for the same information regarding the PAS Designer, refer to Flat File Adapter in the Designer guide.

After having defined the structure of the flat file, you can parse such file by invoking a <<FlatFileAdapter>> action as shown in the example below.

Panel
titleOn this Page:
Table of Contents
Panel
titleRelated Pages:

Otp
Floatingfalse

rp

This action will read the complete file dvd_list.txt into an object of having the myFile structure.

Adding a Flat File Adapter with the xUML Action Wizard

To define a <<FlatFileAdapter>> action, draw an empty action node and invoke the xUML Action Wizard from the context menu (or press Alt+W).

The xUML Action Wizard Dialog opens.

Assign a meaningful name and select stereotype FlatFileAdapter.

Click Next.

The Flat File Adapter supports two actions: parse for reading flat files, and compose for creating flat files.
Select action parse.

The file name and the directory where the file is located is defined in the component diagram by a file alias or a file resource. Select an existing file alias, create a new one by clicking New, or provide a file resoure.

Click Next.

The output of of the Flat File Adapter parse action is provided by an any object having stereotype <<FlatFile>>.

You can select additional parameters, as there are

  • data, to parse a file given by a Blob object (see Blob Output below)
  • encoding, to specify a divergent file encoding (see File Encoding below)
  • locale, to set a divergent number formatting
  • name, to set the file name dynamically (see Dynamic Usage of Flat Files below).

Click Next.

The Action Wizard displays a summary of your settings.

Click Finish to create the parse action.

Dynamic Usage of Flat Files

Besides the static definition of the file name and path in the component diagram, it is possible to set the filename dynamically within your activity diagram. In this case, an object name of type String has to be an input to the Flat File Adapter. For dynamic usage, the Flat File Adapter does not require an alias or a resource.

Multiexcerpt include
MultiExcerptNameparameters_parse
PageWithExcerptFlat File Adapter Reference

IO Objects of the Flat File Adapter

<<FlatFile>> Root Class

The flat file structure definition always has a <<FlatFile>> root class. An instance of this class has to be input or output of the <<FlatFileAdapter>> action: as an output object if the action parses a file, as an input object if the action composes a file.

File Encoding

The Flat File Adapter uses ISO-8859-1 encoding as a default. For any divergent charset definitions of the file, use the encoding parameter of type String and provide the charset (e.g. UTF-8). For more information on how to add the encoding parameter, refer to Adding a Flat File Adapter with the xUML Action Wizard above.

Note
iconfalse

An encoding input parameter will override any definitions made in the component diagram.

Blob Output

The Flat File Adapter can also handle Blob inputs to the parse action and provide Blob outputs of the compose action by adding a data parameter. This can be useful, if the file to parse is provided as blob, resp. the file should not be written by the compose action. One use case could be that the file should be parsed/composed line by line (read/write done with the File System Adapter).

For more information on how to add the data parameter, refer to Adding a Flat File Adapter with the xUML Action Wizard above.

Number Formatting

The parse and compose functionality is influenced by locales. Parameter locale of type NumbersLocale can be used to influence the formatting of numbers.

Info

locale is only considered for fields that have a formatPattern assigned.

For more information on number formatting refer to Number Formatting, for more information on how to add the locale parameter refer to Adding a Flat File Adapter with the xUML Action Wizard above.