Versions Compared

Key

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

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.

Figure: <<FlatFileAdapter>> Action

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

E2E

xUML Action Wizard

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

The E2E xUML Action Wizard Dialog opens.

Image Modified

Assign a meaningful name and select stereotype FlatFileAdapter.

Click Next.

Image Modified

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.

Image Modified

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.

Image Modified

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.

Figure: Providing a File Name Dynamically

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.

Figure: Flat File Structure Root Class

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 E2E xUML Action Wizard above.

Note
iconfalse

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

Figure: Flat File Adapter IO Object encoding

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 E2E xUML Action Wizard above.

Figure: Blob Output of the Flat File Adapter

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. 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 E2E xUML Action Wizard above.

Figure: Usage of NumbersLocale