Package nexj.core.scripting

Examples of nexj.core.scripting.Pair


    * @return The shortest association path or null if no such path can be found.
    */
   private Pair findCommonAssocSuffix(Pair associationPath, Pair oldPath)
   {
      int nDiffLen = Pair.length(associationPath) - Pair.length(oldPath);
      Pair longerPath = (nDiffLen > 0) ? associationPath : oldPath;

      if (nDiffLen != 0)
      {
         CompositeMessagePart rootPart = ((CompositeMessagePart)longerPath.getHead()).getRoot();

         for (int i = Math.abs(nDiffLen); i > 1; i--, longerPath = longerPath.getNext()) ;

         CompositeMessagePart recursivePart = (CompositeMessagePart)longerPath.getHead();

         if (recursivePart instanceof CompositeMessagePartRef)
         {
            CompositeMessagePart refPart = ((CompositeMessagePartRef)recursivePart).getRefPart();

            if (refPart != rootPart)
            {
               return null;
            }
         }

         longerPath = longerPath.getNext();
      }

      if (!ObjUtil.equal((nDiffLen <= 0) ? associationPath : oldPath, longerPath))
      {
         return null;
View Full Code Here


    */
   private void addAssociationPath(MessagePart part, Pair associationPath, boolean bRoot)
   {
      if (associationPath != null)
      {
         Pair pathToAdd = associationPath;

         if (m_assocPathByDependentMsgPartMap == null)
         {
            m_assocPathByDependentMsgPartMap = new HashTab();
         }
         else
         {
            Pair oldPath = (Pair)m_assocPathByDependentMsgPartMap.get(part);

            if (oldPath != null)
            {
               pathToAdd = findCommonAssocSuffix(associationPath, oldPath);
            }
View Full Code Here

    * @return The reverse association path for the dependentPart.
    * @param dependentPart The dependent message part.
    */
   public Pair getReverseAssociationPath(MessagePart dependentPart)
   {
      Pair associationPath = (dependentPart != null && m_assocPathByDependentMsgPartMap != null) ?
         (Pair)m_assocPathByDependentMsgPartMap.get(dependentPart) : null;

      Pair reverseAssocPath = null;

      if (associationPath != null)
      {
         for (; associationPath != null; associationPath = associationPath.getNext())
         {
            Symbol partSymbol = ((ObjectMessagePartMapping)((MessagePart)associationPath.getHead()).getMapping())
               .getAttribute().getSymbol();

            reverseAssocPath = new Pair(partSymbol, reverseAssocPath);
         }

         reverseAssocPath = new Pair(Symbol.ATAT, new Pair(getMetaclass().getSymbol(),
            Pair.nreverse(reverseAssocPath)));
      }

      return reverseAssocPath;
   }
View Full Code Here

            CompositeMessagePart part = (CompositeMessagePart)msgPart;
            ObjectMessagePartMapping partMapping = (ObjectMessagePartMapping)part.getMapping();

            if (partMapping.getAssociationCode() != null)
            {
               Pair associationPath = new Pair(part);
               CompositeMessagePart rootPart = part.getRoot();

               for (MessagePart parentMsgPart = part.getParent(); parentMsgPart != null; parentMsgPart = parentMsgPart.getParent())
               {
                  ObjectMessagePartMapping parentMsgPartMapping = (ObjectMessagePartMapping)parentMsgPart.getMapping();
                  boolean bRoot = (parentMsgPart == rootPart);

                  if (parentMsgPartMapping.isDelete() || bRoot)
                  {
                     parentMsgPartMapping.addAssociationPath(part, associationPath, bRoot);
                  }

                  if (parentMsgPartMapping.getAttribute() != null)
                  {
                     associationPath = new Pair(parentMsgPart, associationPath);
                  }
               }
            }

            if (currPathSet.add(part))
View Full Code Here

         }

         // Build the dependent message parts map for the referenced message.
         mapping.buildDependentMsgPartsMap(ref.getRefPart());

         Pair localAssocPath = null;

         // Copy the dependency list from the referenced part to the referee while appending to the association paths.
         for (CompositeMessagePart partToResolve = ref; partToResolve != null; partToResolve = partToResolve.getParent())
         {
            ObjectMessagePartMapping partParentMapping = (ObjectMessagePartMapping)partToResolve.getMapping();

            if (mapping.getDependentMessagePartsCount() > 0)
            {
               for (Lookup.Iterator itr = mapping.getDependentMessagePartsIterator(); itr.hasNext();)
               {
                  CompositeMessagePart part = (CompositeMessagePart)itr.next();
                  boolean bRoot = (partToResolve == rootPart);

                  // skip itself, however add to root even if the delete flag is not set on it
                  if (partToResolve != part && (partParentMapping.isDelete() || bRoot))
                  {
                     partParentMapping.addAssociationPath(part, Pair.append(localAssocPath, (Pair)itr.getValue()),
                        bRoot);
                  }
               }
            }

            if (partParentMapping != null && partParentMapping.getAttribute() != null)   // skip root
            {
               localAssocPath = new Pair(partToResolve, localAssocPath);
            }
         }
      }
   }
View Full Code Here

   public void compile(Machine machine)
   {
      if (m_body != null)
      {
         m_function = new Compiler().compile(
            new Pair(Symbol.LAMBDA, new Pair(null, m_body)),
            m_posMap, "upgrade:" + m_upgrade.getName() + '$' + m_sName, machine, false);
         m_body = null;
      }
   }
View Full Code Here

         return (Message)m_msgMap.get(toKey(typeDef));
      }

      protected static Object toKey(XSElementDeclaration elemDecl)
      {
         return new Pair(elemDecl.getNamespace(), elemDecl.getName());
      }
View Full Code Here

         {
            return typeDef;
         }
         else
         {
            return new Pair(typeDef.getNamespace(), typeDef.getName());
         }
      }
View Full Code Here

      {
         logQuery(Logger.DEBUG);
      }

      long lStartTime = getCurrentTime();
      Pair readClosePair = (Pair)machine.invoke(readMapping.getFunction(), m_readArgArray);

      logDuration(lStartTime, true);
      m_resultIterator = getIterator(readClosePair.getHead(), mapping.getMetaclass());
      m_closeFunction = (Function)readClosePair.getTail();
   }
View Full Code Here

    */
   public void generate(Machine machine)
   {
      verifyNotReadOnly();

      Pair assoc = null;

      for (int i = 0, n = getAssociationCount(); i < n; ++i)
      {
         assoc = new ConstPair(getAssociation(i).getReverse().getSymbol(), assoc);
      }

      m_event.addFlowAssoc(assoc);

      ((Workflow)m_activity.getFlow()).addFunction(this, assoc,
         m_event, new Pair(this, new Pair(m_condition, getBody())));

      setBody(null);
   }
View Full Code Here

TOP

Related Classes of nexj.core.scripting.Pair

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.