Package nexj.core.scripting

Examples of nexj.core.scripting.Pair


      assertEquals("p1", params[0]);
      assertEquals(Primitive.ZERO_DOUBLE, params[1]);

      assertNull(req.getInvocation(0).getAttributes());

      Pair pair = req.getInvocation(1).getAttributes();

      assertEquals("a", pair.getHead());
      assertEquals("b", pair.getNext().getHead());
      assertNull(pair.getNext().getNext());

      OID oid = contact.getOID();

      assertEquals(1, oid.getCount());
      assertEquals("123", oid.getValue(0));

      assertEquals("Contact", contact.getClassName());
      assertEquals("update", contact.getEventName());
      assertEquals(12345, contact.getVersion());
      assertEquals(24, contact.getValueCount());
      assertEquals("Java", contact.getValue("firstName"));
      assertEquals("Kava", contact.getValue("lastName"));
      assertNull(contact.getValue("null"));
      assertSame(contact, contact.getValue("self"));
      checkEquals(Primitive.ONE_INTEGER, (Number)contact.getValue("integer"));
      checkEquals(Primitive.createLong(2), (Number)contact.getValue("long"));
      checkEquals(Primitive.createFloat(0.625f), (Number)contact.getValue("float"));
      checkEquals(Primitive.createDouble(1.625), (Number)contact.getValue("double"));
      checkEquals(new BigDecimal("1.2345"), (Number)contact.getValue("decimal"));
      assertEquals(new Timestamp(12345), contact.getValue("timestamp"));
      assertEquals(Boolean.TRUE, contact.getValue("boolean"));
      assertEquals(new Binary(new byte[]{1, 2, 3, 4, 5}), contact.getValue("binary"));
      assertEquals(new Binary(new byte[]{1, 2, 3, 4, 5, 6, 7}), contact.getValue("binary2"));
      assertEquals(new Binary(new byte[]{1, 2}), contact.getValue("binary3"));
      assertEquals("sym", ((Symbol)contact.getValue("symbol")).getName());
      assertSame(Symbol.define("sym"), contact.getValue("symbol"));

      Pair pairA = (Pair)contact.getValue("pair");
      assertEquals("A", pairA.getHead());

      Pair pairB = pairA.getNext();
      assertEquals("B", pairB.getHead());
      assertNull(pairB.getTail());

      char[] cvec = (char[])contact.getValue("cvector");

      assertEquals(3, cvec.length);
      assertEquals('a', cvec[0]);
View Full Code Here


      assertEquals("a", m_list.getInstance(1).getValue("city"));
   }

   public void testList()
   {
      Pair pair = m_list.list();
     
      assertEquals(2, Pair.length(pair));
      assertEquals("a", ((Instance)pair.getHead()).getValue("city"));
      assertEquals("b", ((Instance)pair.getNext().getHead()).getValue("city"));
   }
View Full Code Here

    * @throws Exception If an error occurs.
    */
   protected void checkSameResults(Metaclass clazz, String sReferenceQueryAttributes, String sTestQueryAttributes, String sOrderBy)
      throws Exception
   {
      Pair orderBy = parse(sOrderBy);
      Pair attributes;
      List expectedData = new ArrayList(8);
      List actualData = new ArrayList(8);

      attributes = parse(sReferenceQueryAttributes);
      query(clazz, attributes, expectedData, orderBy);
View Full Code Here

      assertEquals("create", ((TransferObject)res.getResult(0)).getEventName());
      assertNull(tobj.getOID());
      assertEquals(1, res.getEventCount());
      assertEquals(1, ((List)res.getEvent(0)).size());

      tobj.setValue("number", new Pair(new PCodeFunction()));

      try
      {
         server.invoke(req);
         fail("Expected RPCException");
View Full Code Here

      m_unmarshaller = new TextUnmarshaller(new InvocationContext(Repository.getMetadata()));
   }

   public void testDeserializeExpression() throws IOException
   {
      Pair pair = (Pair)m_unmarshaller.deserialize(new StringReader("3vP3X(1)1#"));

      assertEquals(new Integer(1), ((Pair)pair.getHead()).getHead());
      assertNull(((Pair)pair.getHead()).getTail());
      assertSame(pair.getHead(), pair.getTail());
   }
View Full Code Here

      assertEquals(new OID(new Object[] { null, "a", Primitive.createInteger(123), Primitive.createLong(567), Primitive.createDouble(1.234),
               new BigDecimal("456.789"), new Date(1234567), Boolean.FALSE,
               new Binary(new byte[] { (byte) 134, 45, (byte) 173 }) }), oid);

      clear();
      m_marshaller.serialize(new Pair("A", new Pair(new Pair("B",Symbol.define("C")))), m_writer);
      assertEquals("{\":head\":\"A\",\":tail\":{\":head\":{\":head\":\"B\",\":tail\":{\":symbol\":\"C\"}}}}", m_writer.toString());

      Pair p = (Pair) m_unmarshaller.deserialize(new StringReader(m_writer.toString()));
      assertEquals(new Pair("A", new Pair(new Pair("B",Symbol.define("C")))), p);
   }
View Full Code Here

   public void testSchemeExpression() throws UnmarshallerException, IOException
   {
      m_unmarshaller = new JSONUnmarshaller(new InvocationContext(Repository.getMetadata()));

      Pair pair = (Pair) m_unmarshaller.deserialize(new StringReader("{\":expression\":\"(firstName lastName fullName \\\"loginName\\\" )\"}"));
      assertEquals(Pair.list(Symbol.define("firstName"), Symbol.define("lastName"), Symbol.define("fullName") , "loginName"), pair);
   }
View Full Code Here

      assertEquals("Cottage", ((Instance)list.getInstance(0).getValue("f1")).getValue("caption"));
   }

   protected Object parseEval(String sScript)
   {
      Pair code = parse(sScript);

      return m_context.getMachine().eval(code);
   }
View Full Code Here

   /**
    * @see nexj.core.persistence.Operator#getExpression(nexj.core.persistence.Query)
    */
   public Object getExpression(Query root)
   {
      Pair expression = null;

      for (int i = m_nOperandCount - 1; i >= 0; i--)
      {
         expression = new Pair(m_operandArray[i].getExpression(root),expression);
      }

      return new Pair(getSymbol(), expression);
   }
View Full Code Here

         refPart = ((CompositeMessagePartRef)part).getRefPart();
         message = refPart.getDeclarator();

         if (!currPathSet.add(refPart))
         {
            return (m_attribute == null) ? null : new Pair(m_attribute.getSymbol());
         }
      }

      CompositeMessagePart composite = (CompositeMessagePart)part;
      Pair attributes = null;

      for (int i = composite.getPartCount() - 1; i >= 0; --i)
      {
         MessagePart childPart = composite.getPart(i);
         ObjectMessagePartMapping childMapping = (ObjectMessagePartMapping)childPart.getMapping();
         Object childAttributes = childMapping.getAttributes(childPart, currPathSet, message);

         if (childAttributes != null)
         {
            attributes = new Pair(childAttributes, attributes);
         }
      }

      // Add attributes from derived messages
      if (refPart != null)
      {
         ObjectMessagePartMapping refMapping = (ObjectMessagePartMapping)refPart.getMapping();
         Message refMessage = refMapping.getMessage();

         for (int i = 0, nCount = refMessage.getDerivedMessageCount(); i < nCount; i++)
         {
            Message derivedMessage = refMessage.getDerivedMessage(i);
            CompositeMessagePart derivedRoot = derivedMessage.getRoot();
            ObjectMessagePartMapping derivedMapping = (ObjectMessagePartMapping)derivedRoot.getMapping();
            Object derivedAttributes = derivedMapping.getAttributes(derivedRoot, currPathSet, refMessage);

            if (derivedAttributes != null)
            {
               if (derivedAttributes instanceof Symbol)
               {
                  derivedAttributes = new Pair(derivedAttributes);
               }

               if (derivedMapping.getMetaclass() != refMapping.getMetaclass())
               {
                  derivedAttributes = new Pair(Symbol.ATAT,
                     new Pair(derivedMapping.getMetaclass().getSymbol(), derivedAttributes));
                  attributes = new Pair(derivedAttributes, attributes);
               }
               else
               {
                  attributes = Pair.nconc((Pair)derivedAttributes, attributes);
               }
            }
         }

         currPathSet.remove(refPart);
      }

      return (m_attribute == null) ? attributes : new Pair(m_attribute.getSymbol(), attributes);
   }
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.