Package nexj.core.meta.integration.format.csv

Examples of nexj.core.meta.integration.format.csv.CSVMessagePartMapping


    * @see nexj.core.integration.MessageFormatter#format(nexj.core.rpc.TransferObject, nexj.core.meta.integration.Message, nexj.core.integration.Output)
    */
   public void format(TransferObject tobj, Message message, Output out) throws IntegrationException
  
      CompositeMessagePart rootPart = message.getRoot();
      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)rootPart.getMapping();
     
      CompositeMessagePart rowPart = (CompositeMessagePart)rootPart.getPart(0);
     
      //Get the MessageParts in the order specified by their ordinal tags.
      PrimitiveMessagePart[] partsInOrder = rootMapping.getPartsInOrder();
     
      try
      {
         m_writer = out.getWriter();
        
         //First line should be the column headers.
         if (rootMapping.isHeader())
         {
            formatHeader(rootMapping);
         }
        
         //The one and only sub-datum will be a List of TransferObjects if there
View Full Code Here


         {
            nDelimiterAccumulator += 1;
            continue;
         }
        
         CSVMessagePartMapping partMapping = (CSVMessagePartMapping)part.getMapping();
        
         //Get the transfer object for this part's datum.
         String[] dataKeyPath = partMapping.getDataKeyPath();
         Object datum = rowTransferObj;

         for (int nKeyPathIndex=0; nKeyPathIndex < dataKeyPath.length; nKeyPathIndex++)
         {
            datum = ((TransferObject)datum).findValue(dataKeyPath[nKeyPathIndex], Undefined.VALUE);
View Full Code Here

    * @see nexj.core.integration.MessageParser#parse(nexj.core.integration.Input, nexj.core.meta.integration.Message)
    */
   public TransferObject parse(Input in, Message msg) throws IntegrationException
   {
      CompositeMessagePart rootPart = msg.getRoot();
      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)rootPart.getMapping();

      initializeParse(in, rootMapping);

      return parseMessage(msg, null);
   }
View Full Code Here

      Object[] rawRow = null;
      Message detectedMessage = null;

      Message longestMessage = parserTable.getMessageWithMostFields();
      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)longestMessage.getRoot().getMapping();
      CompositeMessagePart rowPart = (CompositeMessagePart)longestMessage.getRoot().getPart(0);
      CSVMessagePartMapping rowMapping = (CSVMessagePartMapping)rowPart.getMapping();

      initializeParse(in, rootMapping);

      //Count the number of fields in the first row of input, and use this number
      //to guess the message.
View Full Code Here

    *         the CSV file.
    */
   protected TransferObject parseMessage(Message msg, Object[] firstRow)
   {
      CompositeMessagePart rootPart = msg.getRoot();
      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)rootPart.getMapping();
      CompositeMessagePart rowPart = (CompositeMessagePart)rootPart.getPart(0);
      CSVMessagePartMapping rowMapping = (CSVMessagePartMapping)rowPart.getMapping();
      MessagePart[] partsInOrder = rootMapping.getPartsInOrder();

      TransferObject result = null;
      List listResult;

View Full Code Here

   protected Object[] rawReadRow(MessagePart[] partsInOrder, CSVMessagePartMapping rowMapping) throws IOException
   {
      Object[] result = new Object[rowMapping.getHighestOrdinal()];
      int nResultIndex = 0;
      char chDelimiter = rowMapping.getDelimiter().charValue();
      CSVMessagePartMapping partMapping;

      while (!m_bEOF && (m_chCurrent != '\n' && m_chCurrent != '\r'))
      {
         //Do not get more fields than necessary, if number of fields is known.
         if (partsInOrder != null && nResultIndex >= result.length)
         {
            break;
         }

         if (partsInOrder != null && partsInOrder[nResultIndex] != null)
         {
            partMapping = (CSVMessagePartMapping)partsInOrder[nResultIndex].getMapping();
         }
         else
         {
            partMapping = rowMapping;
         }

         //Infer presence of data if this field starts with a delimiter
         if (nResultIndex > 0 && m_chCurrent == chDelimiter)
         {
            //Advance to first character of data field.
            if (!m_bEOF)
            {
               readNext();
            }
         }

         chDelimiter = partMapping.getDelimiter().charValue();

         // Resize array to accommodate data, if getting unknown number of fields
         if (partsInOrder == null && nResultIndex >= result.length)
         {
            Object[] tmp = new Object[result.length << 1];
View Full Code Here

         //Traverse graph of TransferObjects to find the object to which this
         //datum should be attached, creating the graph as necessary.
         if ((datum != null && datum != Invalid.VALUE) || part.isRequired())
         {
            CSVMessagePartMapping mapping = (CSVMessagePartMapping)part.getMapping();

            if (mapping.getFormat() == null)
            {
               datum = part.convertValue(datum);
            }
            else
            {
               if (m_primitiveFormatter == null)
               {
                  m_primitiveFormatter = new PrimitiveFormatter(m_context);
               }

               datum = m_primitiveFormatter.parse((String)datum, part);
            }

            TransferObject nestedResult = result;
            TransferObject nextNestedResult = null;
            String[] dataKeyPath = mapping.getDataKeyPath();

            for (int nKeyPathIndex=0; nKeyPathIndex < dataKeyPath.length - 1; nKeyPathIndex++)
            {
               nextNestedResult = (TransferObject)nestedResult.findValue(dataKeyPath[nKeyPathIndex]);
View Full Code Here

         if (part == null)
         {
            continue;
         }

         CSVMessagePartMapping partMapping = (CSVMessagePartMapping)part.getMapping();

         if (!partEncounteredArray[partMapping.getOrdinal()-1])
         {
            partEncounteredArray[partMapping.getOrdinal()-1] = true;
         }
         else
         {
            throw new IntegrationException("err.integration.csv.duplicateFieldInHeader",
               new Object[]{rawRow[nNameIndex], new Integer(nNameIndex+1)});
View Full Code Here

      //Consider all pairs of Message objects in the table.
      for (int nMessageIndex1 = 0; nMessageIndex1 < nMessages; nMessageIndex1++)
      {
         Message message1 = table.getMessage(nMessageIndex1);
         CSVMessagePartMapping message1Mapping = (CSVMessagePartMapping)message1.getRoot().getMapping();

         for (int nMessageIndex2 = 0; nMessageIndex2 < nMessages; nMessageIndex2++)
         {
            Message message2 = table.getMessage(nMessageIndex2);

            if (message2 == message1 || message2.getName() == message1.getName())
            {
               continue;
            }

            CSVMessagePartMapping message2Mapping = (CSVMessagePartMapping)message2.getRoot().getMapping();

            //Perform verification on the message pair (message1, message2)
            if (!haveSameConfiguration(message1Mapping, message2Mapping) || !verifyLengthRestriction(message1, message2))
            {
               throw new IntegrationException("err.integration.csv.messageTableConflict",
View Full Code Here

    * @return True if the given Message objects may be distinguished by
    *         the parser based solely on number of fields; false otherwise.
    */
   protected static boolean verifyLengthRestriction(Message m1, Message m2)
   {
      CSVMessagePartMapping map1 = (CSVMessagePartMapping)m1.getRoot().getMapping();
      CSVMessagePartMapping map2 = (CSVMessagePartMapping)m2.getRoot().getMapping();

      MessagePart[] m1parts = map1.getPartsInOrder();
      MessagePart[] m2parts = map2.getPartsInOrder();

      int nLength1 = m1parts.length;
      int nRequired1 = computeRequired(m1parts);
      int nLength2 = m2parts.length;
      int nRequired2 = computeRequired(m2parts);
View Full Code Here

TOP

Related Classes of nexj.core.meta.integration.format.csv.CSVMessagePartMapping

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.