Defining a Flat File Adapter Action
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.
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. 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
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.
Name | Type | Direction | Mandatory | Description | Allowed Values | Example | |
---|---|---|---|---|---|---|---|
data | Blob | in | () | Provide the flat file data to be parsed. Alternatively, you can specify a path to a flat file in the file system (see parameter name). Note, that the name parameter takes priority over data. | |||
name | String | in | () | Specify a full path to the flat file to be parsed. Alternatively, you can parse the flat file from a Blob object (see parameter data). Note, that the name parameter takes priority over data. | tmp/myFile.txt | ||
encoding | String | in | Provide the encoding of the file to be parsed as specified in the Charset Definitions appendix. | any valid encoding (see Charset Definitions) | UTF-8 | ||
default | ISO-8859-1 (Latin1) | ||||||
locale | NumbersLocale | in | Specify how number values will be treated, when parsed from the flat file (decimal point, currency symbol, ...). You can overwrite the system locales here, if the file was written with divergent locales. Refer to Number Formatting for more information. | ||||
<any> | <<FlatFile>> class | out | The adapter returns a parsed flat file object. The class defining the type of this object should have stereotype <<FlatFile>> and should depict the structure of the file. |
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.
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.
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.
Related Pages: