Package nexj.core.meta.integration.format.fixed

Examples of nexj.core.meta.integration.format.fixed.FixedMessagePartMapping


      CompositeMessagePart rootPart = message.getRoot();
      CompositeMessagePart recordPart = (CompositeMessagePart)rootPart.getPart(0);

      m_writer = out.getWriter();

      FixedMessagePartMapping rootMapping = (FixedMessagePartMapping)rootPart.getMapping();

      try
      {
         m_writer.write(rootMapping.getPrefix());

         Object toFormat = tobj.findValue(recordPart.getName());

         if (toFormat instanceof List)
         {
            formatRecords((List)toFormat, recordPart);
         }
         else
         {
            throw new IntegrationException("err.integration.invalidRowCollection",
               new Object[]{(toFormat != null) ? toFormat.getClass().getName() : null});
         }

         m_writer.write(rootMapping.getSuffix());
      }
      catch (IOException innerEx)
      {
         throw new IntegrationException("err.integration.format",
            new Object[]{message.getName()}, innerEx);
View Full Code Here


    * @param recordPart the message part for the records node
    * @throws IOException
    */
   private void formatRecords(List recordList, CompositeMessagePart recordPart) throws IOException, IntegrationException
   {
      FixedMessagePartMapping recordMapping = (FixedMessagePartMapping)recordPart.getMapping();

      ensureTemplateSize(recordMapping.getWidth());

      for (int nRowIndex = 0; nRowIndex < recordList.size(); nRowIndex++)
      {
         formatRecord((TransferObject)recordList.get(nRowIndex), recordPart);
      }
View Full Code Here

    * @param recordPart the message part for the record node
    * @throws IOException
    */
   private void formatRecord(TransferObject recordTO, CompositeMessagePart recordPart) throws IOException, IntegrationException
   {
      FixedMessagePartMapping recordMapping = (FixedMessagePartMapping)recordPart.getMapping();

      recordMapping.fillRecordTemplate(m_achTemplate);

      int nOffset = 0;

      for (int i = 0; i < recordPart.getPartCount(); i++)
      {
         PrimitiveMessagePart fieldPart = (PrimitiveMessagePart)recordPart.getPart(i);
         FixedMessagePartMapping fieldMapping = (FixedMessagePartMapping)fieldPart.getMapping();
         Object fieldValue = recordTO.findValue(fieldPart.getName());

         if (fieldValue != null)
         {
            String sFieldValue = formatField(fieldMapping, fieldValue, fieldPart);
            int nFieldOffset = nOffset;

            if (fieldMapping.isLeftAligned())
            {
               nFieldOffset += fieldMapping.getPrefix().length();
            }
            else
            {
               nFieldOffset += fieldMapping.getWidth() - fieldMapping.getSuffix().length() - sFieldValue.length();
            }

            sFieldValue.getChars(0, sFieldValue.length(), m_achTemplate, nFieldOffset);
         }
         else
         {
            if (fieldPart.isRequired())
            {
               throw new IntegrationException("err.integration.minPartCount",
                  new Object[]{fieldPart.getFullPath()});
            }
         }

         nOffset += fieldMapping.getWidth();
      }

      m_writer.write(m_achTemplate, 0, recordMapping.getWidth());
   }
View Full Code Here

      m_reader = in.getReader();
      m_bEOF = false;

      // parse message
      CompositeMessagePart recordPart = (CompositeMessagePart)rootPart.getPart(0);
      FixedMessagePartMapping recordMapping = (FixedMessagePartMapping)recordPart.getMapping();

      if (m_chRecord == null)
      {
         m_chRecord = new char[recordMapping.getWidth()];
      }

      TransferObject result = null;
      List listResult;

      try
      {
         FixedMessagePartMapping rootMapping = (FixedMessagePartMapping)rootPart.getMapping();

         if (rootMapping != null)
         {
            m_reader.skip(rootMapping.getPrefix().length());
         }

         listResult = parseRecords(recordMapping);
      }
      catch (IOException innerEx)
View Full Code Here

      for (int i = 0; i < recordPart.getPartCount(); i++)
      {
         PrimitiveMessagePart fieldPart = (PrimitiveMessagePart)recordPart.getPart(i);
         Object datum = sRawRecordArray[i];
         FixedMessagePartMapping mapping = (FixedMessagePartMapping)fieldPart.getMapping();

         if (mapping.getFormat() == null)
         {
            datum = fieldPart.convertValue(datum);
         }
         else
         {
View Full Code Here

    * @throws IOException If an I/O error occurs.
    * @throws IntegrationException If the parsed data does not match field requirements
    */
   protected String readField(PrimitiveMessagePart fieldPart) throws IOException, IntegrationException
   {
      FixedMessagePartMapping fieldMapping = (FixedMessagePartMapping)fieldPart.getMapping();
      int nReadLen = readNumChars(m_reader, m_chRecord, fieldMapping.getWidth());

      if (nReadLen < fieldMapping.getWidth())
      {
         m_bEOF = true;

         if (nReadLen == 0)
         {
            return null;
         }

         Arrays.fill(m_chRecord, nReadLen, m_chRecord.length, fieldMapping.getPadding());
      }

      String sField = trimToNull(m_chRecord, fieldMapping.getPadding(), fieldMapping.getPrefix().length(), (nReadLen - fieldMapping.getSuffix().length()));

      if (StringUtil.isEmpty(sField))
      {
         if (fieldPart.isRequired())
         {
View Full Code Here

TOP

Related Classes of nexj.core.meta.integration.format.fixed.FixedMessagePartMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.