Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.PrimitiveMessagePart


      XMLMetadataExporter exporter = new XMLMetadataExporter(writer);
      exporter.exportMessage(tableMessage);
     
      assertEquals(tableMessage.getRoot().getPartCount(), 2);
      CompositeMessagePart rowPart = (CompositeMessagePart)tableMessage.getRoot().getPart("Row");
      PrimitiveMessagePart namePart = (PrimitiveMessagePart)rowPart.getPart("name");
      assertEquals(namePart.getType(), Primitive.STRING);
      PrimitiveMessagePart timePart = (PrimitiveMessagePart)rowPart.getPart("time");
      assertEquals(timePart.getType(), Primitive.LONG);
      PrimitiveMessagePart booleanPart = (PrimitiveMessagePart)rowPart.getPart("required");
      assertEquals(booleanPart.getType(), Primitive.BOOLEAN);
      PrimitiveMessagePart enumPart = (PrimitiveMessagePart)rowPart.getPart("type");
      assertEquals(enumPart.getType(), Primitive.STRING);
      assertEquals( enumPart.getEnumerationCount(), 10);

      //System.err.println(XMLUtil.formatXML(writer.toString()));
     
      Message recursiveElement = getMessage("recursiveElement");
     
View Full Code Here


            entryList.add(entry);

            // Iterate the parts, assigning data from the Zip entry
            for (int i = 0; i < entriesPart.getPartCount(); i++)
            {
               PrimitiveMessagePart part = (PrimitiveMessagePart)entriesPart.getPart(i);
               ZipMessagePartMapping mapping = (ZipMessagePartMapping)part.getMapping();
               Object datum = null;
               Primitive partType = part.getType();

               switch (mapping.getValue())
               {
                  case ZipMessagePartMapping.VALUE_CONTENTS:
                     Binary contents = new PagedBinary(zipStream);

                     zipStream.closeEntry();

                     if (s_logger.isDebugEnabled())
                     {
                        s_logger.debug("Extracted contents of \"" + zipEntry.getName() + "\" size=" + contents.getSize());
                     }

                     if (contents.getSize() > 0)
                     {
                        datum = partType.getConverter(Primitive.BINARY).invoke(contents);
                     }

                     sKeyContents = part.getName();
                     break;

                  case ZipMessagePartMapping.VALUE_COMMENT:
                     datum = partType.getConverter(Primitive.STRING).invoke(zipEntry.getComment());
                     break;

                  case ZipMessagePartMapping.VALUE_DIRECTORY:
                     datum = partType.getConverter(Primitive.BOOLEAN).invoke(Boolean.valueOf(zipEntry.isDirectory()));
                     break;

                  case ZipMessagePartMapping.VALUE_EXTRA:
                     if (zipEntry.getExtra() != null)
                     {
                        datum = partType.getConverter(Primitive.BINARY).invoke(new Binary(zipEntry.getExtra()));
                     }

                     break;

                  case ZipMessagePartMapping.VALUE_NAME:
                     datum = partType.getConverter(Primitive.STRING).invoke(convertZipSeparatorToPlatformSeparator(zipEntry.getName()));
                     break;

                  case ZipMessagePartMapping.VALUE_SIZE:
                     datum = partType.getConverter(Primitive.LONG).invoke(Primitive.createLong(zipEntry.getSize()));
                     sKeySize = part.getName();
                     lValueSize = zipEntry.getSize();
                     sizeType = partType;
                     break;

                  case ZipMessagePartMapping.VALUE_TIME:
                     datum = partType.getConverter(Primitive.LONG).invoke(Primitive.createLong(zipEntry.getTime()));
                     break;

                  default:
                     throw new IllegalStateException("Unknown value: " + mapping.getValue());
               }

               entry.setValue(part.getName(), datum);
            }

            // Process the size entry
            if (sKeySize != null && sKeyContents != null)
            {
View Full Code Here

            m_writer.closeEmptyElement();
         }
      }
      else
      {
         PrimitiveMessagePart primitive = (PrimitiveMessagePart)part;

         if (obj == null)
         {
            if (derivedMapping.isNillable())
            {
               m_writer.setNamespace(sNamespace);
               m_writer.openElement(sNodeName);
               m_writer.setNamespace(XMLNamespace.XSI_NAME);
               m_writer.writeAttribute("nil", "1");
               m_writer.closeEmptyElement();
            }
         }
         else
         {
            m_writer.setNamespace(sNamespace);
            m_writer.openElement(sNodeName);

            // Write xsi:type for ANY parts
            if (primitive.getType() == Primitive.ANY && derivedMapping.getSubtype() == XMLMessagePartMapping.SUBTYPE_XSI)
            {
               appendType((String)s_primitiveNameMap.get(Primitive.primitiveOf(obj)));
            }

            m_writer.closeElement();
View Full Code Here

               throw new IntegrationException("err.integration.minPartCount", new Object[]{childPart.getFullPath()});
            }
         }
         else if (nNodeType == XMLMessagePartMapping.VALUE)
         {
            PrimitiveMessagePart contentPart = (PrimitiveMessagePart)childPart;

            if (contentPart.getType() == Primitive.ANY)
            {
               Object value = tobj.findValue(contentPart.getName());

               if (bEmpty)
               {
                  m_writer.closeElement();
               }

               bEmpty = false;
               appendValue(value, contentPart, true);
            }
         }
      }

      if (bRequired && !bMatch)
      {
         throw new IntegrationException("err.integration.missingPart",
               new Object[]{part.getFullPath()});
      }

      // Append element content, if exists
      XMLMessagePartMapping mapping = (XMLMessagePartMapping)part.getMapping();
      PrimitiveMessagePart contentPart = mapping.getValuePart();
      Object content = null;

      if (contentPart != null && contentPart.getType() != Primitive.ANY)
      {
         content = tobj.findValue(mapping.getValuePart().getName());
      }

      if (content != null)
View Full Code Here

      String sKeySize = null;
      String sKeyTime = null;

      for (int i = 0; i < entriesPart.getPartCount(); i++)
      {
         PrimitiveMessagePart part = (PrimitiveMessagePart)entriesPart.getPart(i);
         ZipMessagePartMapping mapping = (ZipMessagePartMapping)part.getMapping();

         switch (mapping.getValue())
         {
            case ZipMessagePartMapping.VALUE_COMMENT:
               sKeyComment = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_CONTENTS:
               sKeyContents = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_EXTRA:
               sKeyExtra = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_NAME:
               sKeyName = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_SIZE:
               sKeySize = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_TIME:
               sKeyTime = part.getName();
               break;

            default:
               // Ignore values that are not for output
               break;
View Full Code Here

      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();
      }
View Full Code Here

                     }
                  }
                  else
                  {
                     CompositeMessagePart composite2 = (CompositeMessagePart)part;
                     PrimitiveMessagePart valuePart = mapping.getValuePart();

                     tobj = new TransferObject(composite2.getPartCount());
                     parseAttributes(tobj, composite2, attributes);

                     // Process message inheritance
                     if (composite2 instanceof CompositeMessagePartRef)
                     {
                        CompositeMessagePartRef ref = (CompositeMessagePartRef)composite2;
                        CompositeMessagePart referencedPart = ref.getRefPart();

                        tobj.setClassName(referencedPart.getName());

                        RootXMLMessagePartMapping refRootMapping = (RootXMLMessagePartMapping)referencedPart.getMapping();
                        Message derivedMessage = getDerivedMessage(attributes, refRootMapping, part.getFullPath());

                        if (derivedMessage != null)
                        {
                           Message referencedMessage = refRootMapping.getRootMessage();

                           Message.validatePolymorphism(referencedMessage, derivedMessage, part);
                           tobj.setClassName(derivedMessage.getName());
                           part = derivedMessage.getRoot();
                           valuePart = ((XMLMessagePartMapping)part.getMapping()).getValuePart();
                        }
                     }

                     if (valuePart != null && valuePart.getType() == Primitive.ANY)
                     {
                        XMLMessagePartMapping valuePartMapping = (XMLMessagePartMapping)valuePart.getMapping();

                        if (valuePartMapping.getInterface() == null)
                        {
                           startParsingAnyType(null)// value part cannot parse to a primitive (attributes not allowed if primitive)
                        }
View Full Code Here

      assert basePart == null || basePart.getName() != null;

      if (part instanceof PrimitiveMessagePart)
      {
         PrimitiveMessagePart primitivePart = (PrimitiveMessagePart)part;

         if (primitivePart.getType() == Primitive.ANY)
         {
            if ((obj = getAnyTypeValue()) == null)
            {
               // An element-mapped part with an interface
               obj = m_stack.getTopObject();
View Full Code Here

         MessagePart parentPart = m_stack.getTopMessagePart();

         /* If parent is a referenced message part: should use mapping from referrer,
          * but value part must be taken from referenced message part mapping.
          */
         PrimitiveMessagePart valuePart = ((XMLMessagePartMapping)parentPart.getMapping()).getValuePart();

         if (valuePart != null && childPart.getParent() == null)
         {
            // Handle type=any, value-mapped, with interface.
            //
            // ChildPart has not parent -> root part -> parentPart is any/interface
            // Value Parts are never composite, so cannot be a reference.
            if (valuePart.isCollection())
            {
               List list = (List)m_stack.getTopValue();

               if (list == null)
               {
View Full Code Here

       */
      boolean bVerifyWhitespace = false;

      if (part instanceof CompositeMessagePart)
      {
         PrimitiveMessagePart valuePart = ((XMLMessagePartMapping)part.getMapping()).getValuePart();

         if (valuePart == null || valuePart.getType() == Primitive.ANY)
         {
            if (!((CompositeMessagePart)part).isLax())
            {
               bVerifyWhitespace = true;
            }
View Full Code Here

TOP

Related Classes of nexj.core.meta.integration.PrimitiveMessagePart

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.