Package nexj.core.scripting

Examples of nexj.core.scripting.Pair


    */
   private Pair resolveDependency(Metaclass metaclass, Pair dep) throws MetadataException
   {
      try
      {
         Pair first, last;

         for (first = last = null; dep != null; dep = dep.getNext())
         {
            Pair pair;

            if (dep.getHead() instanceof Pair)
            {
               Pair head = (Pair)dep.getHead();

               if (head == null || head.getHead() == null)
               {
                  throw new MetadataException("err.meta.attributeDep",
                     new Object[]{getName(), m_metaclass.getName()});
               }

               Attribute attribute = metaclass.getAttribute(((Symbol)head.getHead()).getName());
               Type type = attribute.getType();

               if (type.isPrimitive())
               {
                  throw new MetadataException("err.meta.attributeAssocDep",
                     new Object[]{attribute.getName(), attribute.m_metaclass.getName(),
                        getName(), m_metaclass.getName()});
               }

               pair = new Pair(new Pair(attribute, resolveDependency((Metaclass)type, head.getNext())));
            }
            else if (dep.getHead() instanceof Symbol)
            {
               pair = new Pair(metaclass.getAttribute(((Symbol)dep.getHead()).getName()));
            }
            else
            {
               throw new MetadataException("err.meta.attributeDep",
                  new Object[]{getName(), m_metaclass.getName()});
View Full Code Here


      {
         Attribute attribute;

         if (dep.getHead() instanceof Pair)
         {
            Pair pair = (Pair)dep.getHead();
           
            attribute = (Attribute)pair.getHead();
           
            if (attribute.getReverse() != null)
            {
               stack.add(attribute);
               addInverseDependency(pair.getNext(), stack, depSet);
               stack.remove(stack.size() - 1);
            }
         }
         else
         {
View Full Code Here

      {
         Attribute attribute;

         if (dep.getHead() instanceof Pair)
         {
            Pair pair = (Pair)dep.getHead();

            attribute = (Attribute)pair.getHead();
            pair = pair.getNext();

            if (pair != null)
            {
               if (m_nCached < 0 && attribute.getReverse() == null)
               {
View Full Code Here

    */
   public void addCumulativeDependency(Pair dep)
   {
      verifyNotReadOnly();
     
      Pair cumulativeDep = m_cumulativeDependency;

   loop:
      for (; dep != null; dep = dep.getNext())
      {
         Object value = dep.getHead();
         Attribute attr1 = (value instanceof Attribute) ? (Attribute)value : null;

         for (Pair pair = cumulativeDep; pair != null; pair = pair.getNext())
         {
            if (pair.getHead() == value)
            {
               continue loop;
            }

            if (attr1 != null && pair.getHead() instanceof Attribute)
            {
               Attribute attr2 = (Attribute)pair.getHead();

               if (attr1.getOrdinal() == attr2.getOrdinal() &&
                  attr1.isStatic() == attr2.isStatic() &&
                  attr1.getRootDeclarator() == attr2.getRootDeclarator())
               {
                  continue loop;
               }
            }
         }

         m_cumulativeDependency = new Pair(value, m_cumulativeDependency);
      }
   }
View Full Code Here

   private Pair resolveOrderBy(Metaclass metaclass, Pair orderBy) throws MetadataException
   {
      try
      {
         boolean bAscending = true;
         Pair first = null;
         Pair last = null;

         for (boolean bFirst = true; orderBy != null; orderBy = orderBy.getNext(), bFirst = false)
         {
            orderBy = new Pair(orderBy.getHead(), orderBy.getTail());

            if (orderBy.getHead() instanceof Pair)
            {
               Pair head = (Pair)orderBy.getHead();

               if (head.getHead() instanceof Symbol)
               {
                  metaclass.getAttribute(head.getHead().toString());
               }
               else if (!(head.getHead() instanceof Pair))
               {
                  throw new ClassCastException();
               }

               if (!(head.getTail() instanceof Boolean))
               {
                  throw new ClassCastException();
               }
              
               if (bFirst)
               {
                  bAscending = ((Boolean)head.getTail()).booleanValue();
                  head.setTail(Boolean.TRUE);
               }
               else
               {
                  head.setTail(Boolean.valueOf((!((Boolean)head.getTail()).booleanValue() ^ bAscending)));
               }
            }
            else
            {
               Symbol sym = (Symbol)orderBy.getHead();

               if (sym == null)
               {
                  throw new ClassCastException();
               }

               metaclass.getAttribute(sym.getName());
               orderBy.setHead(new Pair(sym, Boolean.valueOf(bAscending)));
            }
           
            if (first == null)
            {
               first = last = orderBy;
View Full Code Here

    */
   public OID generateOID(Instance instance, PersistenceAdapter adapter)
   {
      Table table = ((RelationalMapping)instance.getPersistenceMapping()).getPrimaryTable();
      UnitOfWork uow = instance.getUnitOfWork();
      Object key = new Pair(table, KEY);
      Object count = uow.getCachedLocal(key);

      if (count == null)
      {
         Column column = table.getPrimaryKey().getIndexColumn(0).getColumn();
View Full Code Here

            if (sQuery == null)
            {
               break;
            }
           
            Pair pair = (Pair)new XMLMetadataHelper().parse(sQuery, true, null, null, m_context.getMachine().getGlobalEnvironment());
           
            if (pair == null || !(pair.getHead() instanceof Symbol))
            {
               throw new IllegalArgumentException("Invalid query class name");
            }
           
            Symbol classSymbol = (Symbol)pair.getHead();

            pair = pair.getNext();
           
            Pair attributes = null;
            Object where = null;
           
            if (pair != null)
            {
               attributes = (Pair)pair.getHead();
View Full Code Here

    * whether the parameters go in the URL query string or in the request body.
    * @throws Exception If an error occurs.
    */
   public void testParametrize() throws Exception
   {
      Pair result;
      TransferObject params = new TransferObject(2);
      MIMEHeaderMap emptyHeaderMap = new MIMEHeaderMap();
      MIMEHeaderMap formHeaderMap = new MIMEHeaderMap();

      params.setValue("a", "x");
      params.setValue("b", "y");

      formHeaderMap.add("Content-Type", "application/x-www-form-urlencoded");

      // Parameters go in URL (with or without ? on end of input URL)
      result = HTTPAdapter.parametrize("http://www.example.com/test1", null, params, emptyHeaderMap);
      assertEquals("http://www.example.com/test1?a=x&b=y", result.getHead());
      assertNull(result.getTail());
      result = HTTPAdapter.parametrize("http://www.example.com/test1?", null, params, emptyHeaderMap);
      assertEquals("http://www.example.com/test1?a=x&b=y", result.getHead());
      assertNull(result.getTail());

      // Parameters go in body (because using form-encoded content type)
      result = HTTPAdapter.parametrize("http://www.example.com/test1", null, params, formHeaderMap);
      assertEquals("http://www.example.com/test1", result.getHead());
      assertEquals("a=x&b=y", result.getTail());
      result = HTTPAdapter.parametrize("http://www.example.com/test1?", null, params, formHeaderMap);
      assertEquals("http://www.example.com/test1?", result.getHead());
      assertEquals("a=x&b=y", result.getTail());

      // Parameters mixed between URL and body (also try with fragment)
      result = HTTPAdapter.parametrize("http://www.example.com/test1?a=d&c=f", null, params, formHeaderMap);
      assertEquals("http://www.example.com/test1?a=x&c=f", result.getHead());
      assertEquals("b=y", result.getTail());
      result = HTTPAdapter.parametrize("http://www.example.com/test1?a=d&c=f#fragment1", null, params, formHeaderMap);
      assertEquals("http://www.example.com/test1?a=x&c=f#fragment1", result.getHead());
      assertEquals("b=y", result.getTail());

      // Parameters to URL, with defaults
      result = HTTPAdapter.parametrize("http://www.example.com/test1?a=d&c=f", null, params, emptyHeaderMap);
      assertEquals("http://www.example.com/test1?a=x&c=f&b=y", result.getHead());
      assertNull(result.getTail());

      // Parameters to body, but leave question mark at end of URL
      result = HTTPAdapter.parametrize("http://www.example.com/test1?", null, params, formHeaderMap);
      assertEquals("http://www.example.com/test1?", result.getHead());
      assertEquals("a=x&b=y", result.getTail());

      // Don't overwrite body if body already specified
      result = HTTPAdapter.parametrize("http://www.example.com/test1", "Hello, World!", params, formHeaderMap);
      assertEquals("http://www.example.com/test1", result.getHead());
      assertEquals("Hello, World!", result.getTail());

      // Handles fragments
      result = HTTPAdapter.parametrize("http://www.example.com/test1#f1", null, params, emptyHeaderMap);
      assertEquals("http://www.example.com/test1?a=x&b=y#f1", result.getHead());
      assertNull(result.getTail());
      result = HTTPAdapter.parametrize("http://www.example.com/test1#", null, params, emptyHeaderMap);
      assertEquals("http://www.example.com/test1?a=x&b=y#", result.getHead());
      assertNull(result.getTail());
   }
View Full Code Here

   {
      Object[] array = new Object[1];

      array[0] = Pair.list(array);

      Pair pair = Pair.list(array);

      StringWriter writer = new StringWriter();

      try
      {
View Full Code Here

      contact.setValue("boolean", Boolean.TRUE);
      contact.setValue("binary", new Binary(new byte[]{1, 2, 3, 4, 5}));
      contact.setValue("binary2", new Binary(new byte[]{1, 2, 3, 4, 5, 6, 7}));
      contact.setValue("binary3", new Binary(new byte[]{1, 2}));
      contact.setValue("symbol", Symbol.define("sym"));
      contact.setValue("pair", new Pair("A", new Pair("B")));
      contact.setValue("cvector", new char[]{'a', 'b', 'c'});
      contact.setValue("bvector", new byte[]{0, (byte)0xAB, 0x12});
      contact.setValue("svector", new String[]{"a", "b", "c"});
      contact.setValue("vector", new Object[]{"a", "b", "c"});
      contact.setValue("function", new PCodeFunction(new char[]{0, 1, 2}, new Object[]{"abc"}));
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.