Apama Documentation : Connecting Apama Applications to External Components : Standard IAF Plug-ins : The File IAF Adapter (JMultiFileTransport) : Opening fixed width files
Opening fixed width files
An example of defining an OpenFileForReading event that opens a fixed width file so that each field is automatically parsed appears below. The additional data required by the Fixed Width codec is stored in the payload dictionary.
com.apama.file.OpenFileForReading openFixedFileRead :=
new com.apama.file.OpenFileForReading;
 
//matches transport in IAF instance
openFixedFileRead.transportName := JMultiFileTransport;
 
//the request id to use
openFixedFileRead.requestId := integer.getUnique();
 
//read using CSV Codec
openFixedFileRead.codec := "JFixedWidthCodec";
 
//file to read
openFixedFileRead.filename := "/usr/home/formby/stocktick.txt";
//additional data required to interpret fixed width data
 
//sequence of field lengths
openFixedFileRead.payload["fieldLengths"] := "[6,4,9,9,9]";
 
//it is left aligned
openFixedFileRead.payload["isLeftAligned"] := "true";
 
//the pad character
openFixedFileRead.payload["padCharacter"] := "_";
 
//emit event to channel in config.
emit openFixedFileRead to "FILE";
Subsequently, when the File adapter receives FileLine events, the adapter stores each field in the data sequence in order. You can access the ones you are interested in.
For details about using the Fixed Width codec, see The Fixed Width codec IAF plug-in.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback