Package nexj.core.persistence.operator

Examples of nexj.core.persistence.operator.ConstantOperator


         throw new InvalidQueryException("err.persistence.file.query");
      }
     
      ComparisonOperator op = (ComparisonOperator)query.getWhere();
      AttributeOperator aop;
      ConstantOperator con;
     
      if (op.getLeft().getOrdinal() == AttributeOperator.ORDINAL)
      {
         aop = (AttributeOperator)op.getLeft();
      }
      else if (op.getRight().getOrdinal() == AttributeOperator.ORDINAL)
      {
         aop = (AttributeOperator)op.getRight();
      }
      else
      {
         throw new InvalidQueryException("err.persistence.file.query");
      }
     
      if (op.getLeft().getOrdinal() == ConstantOperator.ORDINAL)
      {
         con = (ConstantOperator)op.getLeft();
      }
      else if (op.getRight().getOrdinal() == ConstantOperator.ORDINAL)
      {
         con = (ConstantOperator)op.getRight();
      }
      else
      {
         throw new InvalidQueryException("err.persistence.file.query");
      }

      OID oid;
     
      /*
       * Two kinds of queries:
       * 1) Lookup by equating a class to an OID.
       * 2) Lookup by equating name field to a string.
       */
      if (aop.getType() instanceof Metaclass)
      {
         if(con.getValue() instanceof OIDHolder)
         {
            oid = ((OIDHolder)con.getValue()).getOID();
         }
         else
         {
            throw new InvalidQueryException("err.persistence.file.query");
         }
      }
      else
      {
         if (con.getType() == Primitive.STRING)
         {
            oid = new OID(new Object[]{con.getValue()});
         }
         else
         {
            throw new InvalidQueryException("err.persistence.file.query");
         }
View Full Code Here


               }
            }

            if (nOutput == OUTPUT_NONE || machine.isEvalSupported(pair))
            {
               return new ConstantOperator(machine.eval(obj, pair.getNext()));
            }

            return null;
         }

         if (obj instanceof Symbol)
         {
            if (nOutput != OUTPUT_NONE)
            {
               return null;
            }

            Attribute attribute = m_metaclass.getAttribute(obj.toString());

            if (attribute.getValue() != Undefined.VALUE && !attribute.isPersistent())
            {
               return createOperator(key, attribute.getDispatchedValue(), nOutput);
            }

            return new AttributeOperator(addAttribute(key, attribute, null, false, nOutput));
         }

         return new ConstantOperator(obj);
      }
      catch (ClassCastException e)
      {
         throw new InvalidQueryException("err.persistence.queryOperator", e);
      }
View Full Code Here

         if (itr.hasNext())
         {
            InOperator in = new InOperator();

            in.addOperand(new AttributeOperator(typeCodeField));
            in.addOperand(new ConstantOperator(value));

            do
            {
               in.addOperand(new ConstantOperator(itr.next()));
            }
            while (itr.hasNext());

            return in;
         }
         else
         {
            EqualsOperator eq = new EqualsOperator();

            eq.setLeft(new AttributeOperator(typeCodeField));
            eq.setRight(new ConstantOperator(value));

            return eq;
         }
      }
      else
      {
         return new ConstantOperator(Boolean.FALSE);
      }
   }
View Full Code Here

         if (isCached() && m_persistenceMapping.getCaching() == PersistenceMapping.CACHING_INSTANCE)
         {
            EqualsOperator eq = new EqualsOperator();

            eq.setLeft(aop);
            eq.setRight(new ConstantOperator(null));

            for (Iterator itr = oidSet.iterator(); itr.hasNext();)
            {
               EqualsOperator clone = (oidSet.size() == 1) ? eq : (EqualsOperator)eq.clone();

               clone.getRight().setValue(itr.next());
               read(clone);
            }
         }
         else
         {
            InOperator in = new InOperator();

            in.addOperand(aop);

            for (Iterator itr = oidSet.iterator(); itr.hasNext();)
            {
               in.addOperand(new ConstantOperator(itr.next()));
            }

            read(in);
         }
View Full Code Here

TOP

Related Classes of nexj.core.persistence.operator.ConstantOperator

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.