Package nexj.core.meta

Examples of nexj.core.meta.Type


   {
      verifyNesting();
      normalizeOperand(nFlags);

      Operator op = getOperand();
      Type type = op.getType();

      m_type = type;

      if (op.isConstant())
      {
View Full Code Here


   {
      verifyNesting();
      normalizeOperand(nFlags);

      Operator op = getOperand();
      Type type = op.getType();

      if (type == null)
      {
         setConstantValue(null);
         m_type = null;
View Full Code Here

    */
   public Operator normalize(int nFlags)
   {
      normalizeOperand(nFlags);

      Type type = m_operand.getType();

      if (type == null)
      {
         m_type = null;
         setConstantValue(null);
      }
      else if (type.isPrimitive())
      {
         ConversionMapper mapper = null;
         UnaryDescriptor descriptor = null;
         Primitive resultType = null;

View Full Code Here

            return op.normalize(nFlags | NORMALIZE_NORECUR);
         }
      }

      Type leftType = m_left.getType();
      Type rightType = m_right.getType();

      if (leftType == null)
      {
         assert m_left.isConstant();
         assert m_right.isConstant();

         setConstantValue(Boolean.valueOf(nullPredicate(m_right.getValue() == null)));

         return this;
      }

      if (rightType == null)
      {
         rightType = leftType;
         m_right.setType(rightType);
      }

      if (!isEquivalence())
      {
         if (rightType == null || m_right.isConstant() && m_right.getValue() == null)
         {
            Operator op = createNullComparison();

            op.setParent(m_parent);

            if (op.getOrdinal() != ConstantOperator.ORDINAL)
            {
               ComparisonOperator cmpOp = (ComparisonOperator)op;

               cmpOp.setLeft(m_left);
               cmpOp.setRight(m_right);
            }

            return op.normalize(nFlags | NORMALIZE_NORECUR);
         }
      }

      setSource(findCommonSource(m_left, m_right), nFlags);

      if (leftType.isPrimitive())
      {
         if (rightType != null)
         {
            if (!rightType.isPrimitive())
            {
               throw new TypeMismatchException(getSymbol());
            }
         }

         if (leftType == Primitive.ANY && m_left.isConstant() && m_right.isConstant())
         {
            foldObjectComparison();
            return this;
         }

         ConversionMapper mapper = null;
         BinaryDescriptor descriptor = null;

         if (m_source != null)
         {
            mapper = m_source.getAdapter().getConversionMapper();
            descriptor = mapper.getBinaryDescriptor(this);
         }

         if (descriptor == null)
         {
            m_source = null;
            mapper = getConversionMapper();
            descriptor = mapper.getBinaryDescriptor(this);

            if (descriptor == null)
            {
               throw new TypeMismatchException(getSymbol());
            }
         }

         Primitive rightPrimitive = (Primitive)rightType;

         if (mapper.getType(rightPrimitive) != mapper.getType(descriptor.getRightType()))
         {
            setRight(new TypeConversionOperator(descriptor.getRightType(), m_right));
            m_right = m_right.normalize(nFlags | NORMALIZE_NORECUR);
         }

         Primitive leftPrimitive = (Primitive)leftType;

         if (mapper.getType(leftPrimitive) != mapper.getType(descriptor.getLeftType()))
         {
            if (m_right.isConstant() && Primitive.isOrderPreserved(leftPrimitive, descriptor.getLeftType()))
            {
               if (m_right.getValue() != null)
               {
                  m_bConstant = false;

                  if (unconvertConstantComparison(leftPrimitive, rightPrimitive, m_right.getValue()))
                  {
                     if (m_bConstant)
                     {
                        return this;
                     }
                  }
                  else
                  {
                     setLeft(new TypeConversionOperator(descriptor.getLeftType(), m_left));
                     m_left = m_left.normalize(nFlags | NORMALIZE_NORECUR);
                  }
               }
            }
            else
            {
               setLeft(new TypeConversionOperator(descriptor.getLeftType(), m_left));
               m_left = m_left.normalize(nFlags | NORMALIZE_NORECUR);
            }
         }

         if (m_left.isConstant())
         {
            assert m_right.isConstant();

            setConstantValue(evaluate());
         }
         else if (m_right.isConstant())
         {
            if (m_left.getOrdinal() == AttributeOperator.ORDINAL)
            {
               AttributeOperator left = (AttributeOperator)m_left;
               Converter converter = left.getConverter();

               if (converter != null && (isEquivalence() ||
                  Primitive.isOrderPreserved(converter.getSourceType(), converter.getDestinationType())))
               {
                  left.setType(converter.getSourceType());
                  left.setNoConversion(true);
                  m_right.setValue(converter.getInverseFunction().invoke(m_right.getValue()));
                  m_right.setType(converter.getSourceType());
               }
            }
            else if (m_left.getType() == Primitive.BOOLEAN && m_right.getValue() != null)
            {
               switch (booleanPredicate(((Boolean)m_right.getValue()).booleanValue()))
               {
                  case BOOL_LHS:
                     return m_left;

                  case BOOL_NOT:
                     NotOperator op = new NotOperator();

                     op.setOperand(m_left);
                     op.normalize(nFlags | NORMALIZE_NORECUR);

                     return op;

                  case BOOL_TRUE:
                     setConstantValue(Boolean.TRUE);
                     break;

                  case BOOL_FALSE:
                     setConstantValue(Boolean.FALSE);
                     break;
               }
            }
         }
      }
      else
      {
         assert m_left.getOrdinal() == AttributeOperator.ORDINAL;

         if (rightType != null)
         {
            if (rightType.isPrimitive() &&
               (rightType != Primitive.ANY || !m_right.isConstant() ||
                m_right.getValue() != null && !(m_right.getValue() instanceof OIDHolder)))
            {
               throw new TypeMismatchException(getSymbol());
            }
View Full Code Here

            return false;
         }

         if (m_type != null && m_type.isPrimitive())
         {
            Type opType = op.getType();

            if (opType != null && opType.isPrimitive() && m_type != opType)
            {
               m_converter = new PrimitiveConverter((Primitive)opType, (Primitive)m_type);
            }
         }
      }
View Full Code Here

      boolean bConstant = true;

      for (int i = 0; i < m_nOperandCount; ++i)
      {
         Operator op = getOperand(i);
         Type fromType = op.getType();

         if (fromType != null)
         {
            if (!fromType.isPrimitive())
            {
               throw new TypeMismatchException(getSymbol());
            }

            Primitive toType = m_argTypeArray[i];
View Full Code Here

      {
         m_left = m_left.normalize(nFlags);
         m_right = m_right.normalize(nFlags);
      }

      Type leftType = m_left.getType();
      Type rightType = m_right.getType();

      if (leftType == null || rightType == null)
      {
         m_type = null;
         setConstantValue(null);
      }
      else if (leftType.isPrimitive())
      {
         if (rightType.isPrimitive())
         {
            setSource(findCommonSource(m_left, m_right), nFlags);

            ConversionMapper mapper = null;
            BinaryDescriptor descriptor = null;
View Full Code Here

            m_operandArray[i] = m_operandArray[i].normalize(nFlags);
         }
      }

      Operator first = m_operandArray[0];
      Type type = first.getType();

      if (type == null || m_nOperandCount <= 1)
      {
         setConstantValue(Boolean.FALSE);

         for (int i = 1; i < m_nOperandCount; ++i)
         {
            Operator op = m_operandArray[i];

            if (!op.isConstant())
            {
               throw new InvalidQueryException("err.persistence.variableInList");
            }

            if (op.getValue() == null)
            {
               m_value = Boolean.TRUE;
               break;
            }
         }

         return this;
      }

      setSource(first.getSource(), nFlags);

      if (type.isPrimitive())
      {
         if (type == Primitive.ANY && first.isConstant())
         {
            foldObjectIn(first);
            return this;
View Full Code Here

    */
   protected Object evaluate()
   {
      Operator first = m_operandArray[0];
      Object firstValue = first.getValue();
      Type type = first.getType();

      if (type.isPrimitive())
      {
         Primitive primitiveType = (Primitive)type;
         BinaryFunction f = primitiveType.getEQFunction(primitiveType);

         for (int i = 1; i < m_nOperandCount; ++i)
View Full Code Here

   {
      verifyNesting();
      normalizeOperand(nFlags);

      Operator op = getOperand();
      Type type = op.getType();

      if (type == null || op.isConstant() && op.getValue() == null)
      {
         setConstantValue(Primitive.ZERO_LONG);
      }
      else if (!type.isPrimitive() && (nFlags & NORMALIZE_PERSISTENCE) != 0 && m_source != null)
      {
         Field[] fieldArray = m_source.getAdapter().getFields(op.getSource());

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

TOP

Related Classes of nexj.core.meta.Type

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.