Package nexj.core.scripting

Examples of nexj.core.scripting.Pair


    * for the nested transformation; may be null.
    */
   public void setTransformationArguments(Object arguments)
   {
      verifyNotReadOnly();
      m_transformationArguments = new Pair(Symbol.LIST, arguments);
   }
View Full Code Here


            break;
         }
      }

      Pair script = m_script;

      if (m_transformation != null && getArgumentCount() > 0)
      {
         // (#transformer'transformNested TOBJ <Transformation> <Arguments>)
         m_script = Pair.list(
            Pair.list(
               Transformation.TRANSFORMER,
               Pair.quote(TRANSFORM_NESTED),
               (m_transformationInput == null) ? Symbol.define(getArgument(0).getName()) : m_transformationInput,
               m_transformation,
               m_transformationArguments
            )
         );
      }

      if (m_condition != Boolean.TRUE || m_script != null)
      {
         Pair args = null;

         for (int i = getArgumentCount() - 1; i >= 0; --i)
         {
            args = new Pair(Symbol.define(getArgument(i).getName()), args);
         }

         if (bMapping)
         {
            if (m_condition == Boolean.TRUE)
            {
               m_condition = null;
            }
            else
            {
               m_condition = new Pair(m_condition);
            }

            for (int i = getArgumentCount() - 1; i >= 0; --i)
            {
               TransformationArgument arg = getArgument(i);

               if (arg.getMapping() != null)
               {
                  m_condition = new Pair(Pair.binary(Symbol.EQ_P, Symbol.define(arg.getName()),
                     Pair.quote(Undefined.VALUE)).not(), m_condition);
               }
            }

            if (((Pair)m_condition).getTail() == null)
            {
               m_condition = ((Pair)m_condition).getHead();
            }
            else
            {
               m_condition = new Pair(Symbol.AND, m_condition);
            }
         }

         if (m_script != null)
         {
            if (m_condition != Boolean.TRUE)
            {
               m_script = Pair.list(Pair.list(Symbol.IF, m_condition,
                  new Pair(new Pair(Symbol.LAMBDA, new Pair(null, m_script))),
                  Pair.quote(Undefined.VALUE)));
            }
         }
         else
         {
            m_script = Pair.list(Pair.list(Symbol.IF, m_condition,
               args.getHead(), Pair.quote(Undefined.VALUE)));
         }

         m_script = new Pair(Symbol.LAMBDA, new Pair(args, m_script));
      }

      if (bMapping)
      {
         int nNewArgCount = 0;
         Pair args = null;

         for (int nArg = getArgumentCount() - 1; nArg >= 0; --nArg)
         {
            TransformationArgument arg = getArgument(nArg);
            TransformationMapping mapping = arg.getMapping();

            if (mapping != null)
            {
               removeArgument(nArg);
               mapping.generate(transformation);

               Object code = null;
               TransformationArgument srcArg = null;

               for (int i = mapping.getArgumentCount() - 1; i >= 0 ; --i)
               {
                  TransformationArgument mapArg = mapping.getArgument(i);
                  TransformationSource src = mapArg.getSource();
                  int nSrc;

                  for (nSrc = getArgumentCount() - 1; nSrc >= 0; --nSrc)
                  {
                     srcArg = getArgument(nSrc);

                     if (srcArg.getSource() == src)
                     {
                        break;
                     }
                  }

                  if (nSrc < 0)
                  {
                     srcArg = new TransformationArgument("#" + nNewArgCount++);
                     srcArg.setSource(src);
                     srcArg.setNull(mapArg.isNull());
                     srcArg.setDefaultValue(mapArg.getDefaultValue());
                     srcArg.setDefaultValueFunction(mapArg.getDefaultValueFunction());
                     addArgument(nArg, srcArg);
                  }

                  if (arg.isNull())
                  {
                     src.setNull(true);
                  }

                  if (arg.isDefault())
                  {
                     src.setDefault(true);
                  }

                  code = new Pair(Symbol.define(srcArg.getName()), code);
               }

               if (mapping.getOrdinal() == 0)
               {
                  code = ((Pair)code).getHead();
               }
               else
               {
                  code = new Pair(Pair.list(Symbol.VECTOR_REF, Transformation.MAPPERS,
                     Primitive.createInteger(mapping.getOrdinal())), code);
               }

               args = new Pair(code, args);
            }
            else
            {
               args = new Pair(Symbol.define(arg.getName()), args);
            }
         }

         Pair code = null;

         for (int i = getArgumentCount() - 1; i >= 0; --i)
         {
            code = new Pair(Symbol.define(getArgument(i).getName()), code);
         }

         if (m_script == null)
         {
            m_script = Pair.list(Symbol.LAMBDA, code, args.getHead());
         }
         else
         {
            m_script = Pair.list(Symbol.LAMBDA, code, new Pair(m_script, args));
         }
      }

      if (m_script != null)
      {
View Full Code Here

         Query parent = query.getParent();

         if (parent == null)
         {
            path.setHead(Symbol.ATAT);
            path = new Pair(query.getMetaclass().getSymbol(), path);
         }
         else
         {
            if (parent != root && !query.isInverse())
            {
               path = getWhereAssoc(root, parent, path);
            }

            path = new Pair(query.getAttribute().getSymbol(), path);

            if (parent != root && query.isInverse() &&
               (root != null || parent.getParent() != root))
            {
               getWhereAssoc(root, parent, path);
View Full Code Here

   /**
    * @see nexj.core.persistence.Operator#getExpression(nexj.core.persistence.Query)
    */
   public Object getExpression(Query root)
   {
      Pair path = new Pair(Symbol.AT);
      Query query = m_source.getQuery();

      if (query.isInverse())
      {
         path.setHead(Symbol.ATAT);
         path = new Pair(query.getMetaclass().getSymbol(), path);
      }

      path = getWhereAssoc(root, query, path);

      if (m_source instanceof Field)
      {
         Field field = (Field)m_source;

         if (field.getAttribute() != null)
         {
            path = new Pair(field.getAttribute().getSymbol(), path);
         }
         else if (field.getItem() instanceof Field)
         {
            field = (Field)field.getItem();

            if (field.getAttribute() != null)
            {
               path = new Pair(field.getAttribute().getSymbol(), path);
            }
         }
      }

      return Pair.nreverse(path);
View Full Code Here

            m_argList.clear();
            m_argList.add(this);
            m_argList.add(m_output);
            m_argList.add(obj);

            Pair head = arguments;
            int nArgCount = transformation.getArgumentCount();

            while (head != null)
            {
               nArgCount--;
               m_argList.add(head.getHead());
               head = head.getNext();
            }

            if (nArgCount != 0)
            {
               throw new IntegrationException("err.meta.transformation.argumentCount",
View Full Code Here

      InputStream in = new BufferedInputStream(URLUtil.openStream(
         new URL(URLUtil.toURL(getRequiredProperty("dump.url")))));

      try
      {
         Pair p = new DataLoader(m_context).getDumpVersion(in);
        
         if (p != null)
         {
            printVersion((String)p.getHead(), (String)p.getTail());
         }
         else
         {
            s_logger.info("Unable to determine the dump version");
            setExitCode(3);
View Full Code Here

      if (sScript != null)
      {
         Intrinsic.load(sScript, machine);
      }

      final Pair spec = (Pair)machine.invoke(new Compiler().compile(
         new SchemeParser(machine.getGlobalEnvironment()).parse(new StringReader(sQuery), null),
         null, machine, true), (Pair)null);

      exportData(new Exporter()
      {
View Full Code Here

    * @param dep Dependencies
    * @return List of association paths
    */
   private Pair getValueDependencyAssociations(Pair dep)
   {
      Pair result = null;

      while (dep != null)
      {
         Object head = dep.getHead();

         if (head instanceof AttributeMeta)
         {
            result = new Pair(new Pair(((AttributeMeta)head).getName()), result);
         }
         else if (head instanceof Pair && ((Pair)head).getHead() instanceof AttributeMeta)
         {
            Pair next = (Pair)head;
            final String sAttr = ((AttributeMeta)next.getHead()).getName();

            next = getValueDependencyAssociations(next.getNext());

            while (next != null)
            {
               result = new Pair(new Pair(sAttr, next.getHead()), result);
               next = next.getNext();
            }
         }
         else
         {
            assert false;
View Full Code Here

   private PCodeFunction compile(Object expr, Pair args, Machine machine, String sItem)
   {
      try
      {
         return new Compiler().compile(
            new Pair(Symbol.LAMBDA, new Pair(args, new Pair(expr))),
            m_textPosMap, machine, false);
      }
      catch (Exception e)
      {
         MetadataValidationException x;
View Full Code Here

      m_metaclass.setCurrent();
      setCurrent();

      try
      {
         Pair dep = new Pair(Boolean.TRUE);

         m_metaclass.dependency(m_value, m_bStatic, dep, null, machine);

         setDerivedDependency(
            Pair.nconc(dep.getNext(),
            resolveDependency(m_metaclass, m_dependency)), Intrinsic.isTrue(dep.getHead()));

         setDerivedOrderBy(resolveOrderBy(m_metaclass, m_orderBy));
      }
      finally
      {
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.