NextRecord() public method

Returns the next record as a list of objects.
   
public NextRecord ( ) : List
return List
Esempio n. 1
0
        public void EbcdicTestsTestReader()
        {
            FileFormat fileFormat = CopybookLoader.LoadCopybook(Copybook + "/Test.fileformat");
            using (BufferedStream inputStream = new BufferedStream(new MemoryStream(Bytes)))
            {
                EbcdicReader reader = new EbcdicReader(inputStream, fileFormat, false);
                List<object> record = reader.NextRecord();
                Assert.AreEqual(Objects.Length, record.ToArray().Length);
                Assert.AreEqual(Objects.GetType(), record.ToArray().GetType());

                //NOTE : CollectionAssert does not support nested collection handling ...
                int index = 0;
                foreach (var rec in record.ToArray())
                {
                    var array = rec as Array;
                    if (array != null)
                    {
                        CollectionAssert.AreEqual((Array)Objects[index], array);
                    }
                    else
                    {
                        Assert.AreEqual(Objects[index], rec);
                    }
                    index++;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// @see AbstractItemCountingItemStreamItemReader#DoRead
        /// </summary>
        /// <returns></returns>
        protected override T DoRead()
        {
            T             record = null;
            List <object> fields;

            try
            {
                fields = _reader.NextRecord();
            }
            catch (EbcdicException e)
            {
                throw new EbcdicParseException("Error while parsing item number " + _nbRead, e);
            }
            if (fields != null)
            {
                record = EbcdicReaderMapper.Map(fields, _nbRead);
                if (_logger.IsTraceEnabled)
                {
                    //NOTE : WARNING - THIS MIGHT EXPOSE SENSITIVE INFORMATION TO THE VIEW --
                    //PLEASE PROCEED WITH CAUTION WHEN SETTING LOG LEVEL TO DEBUG.
                    _logger.Trace("Read record #{0} from ebcdic file : \n {1}", _nbRead + 1, record);
                }
                _nbRead++;
            }
            return(record);
        }
Esempio n. 3
0
        private void Test(String name, byte[] newLine, bool useRdw = false)
        {
            //BeforeClass();
            string input = Inputs +"/"+ name + ".txt";
            string output = Outputs + "/" + name + ".txt";
            string copybook = Copybook + "/" + name + ".fileformat";
            FileFormat fileFormat = CopybookLoader.LoadCopybook(copybook);
            using (BufferedStream inputStream = new BufferedStream(GetInputStream(input)))
            using (BufferedStream outputStream = new BufferedStream(new FileStream(output, FileMode.OpenOrCreate)))
            {
                EbcdicReader reader = new EbcdicReader(inputStream, fileFormat, useRdw);
                EbcdicWriter writer = new EbcdicWriter(outputStream, fileFormat.Charset, useRdw, EbcdicEncoder.DefaultValue.LowValue)
                {
                    RecordFormatMap = new RecordFormatMap(fileFormat)
                };


                List<Object> record = reader.NextRecord();
                while (record != null)
                {
                    writer.WriteRecord(record);
                    outputStream.Write(newLine);
                    record = reader.NextRecord();
                }
            }

            Assert.IsTrue(TestHelper.TestHelper.ContentEquals(GetInputStream(output), GetInputStream(input)));
        }