Package org.apache.imperius.spl.core

Examples of org.apache.imperius.spl.core.Expression


        try {
            // Property1 != Property2   
            Vector v = new Vector();
            v.add(propertySensor1);
            v.add(propertySensor2);
            Expression firstExpression = new Equal(v,true);

            // Property1 == Property3   
            v.clear();
            v.add(propertySensor1);
            v.add(propertySensor3);
            Expression secondExpression = new Equal(v,true);

            // Property1 == StringConstant("test");
            v.clear();
            v.add(propertySensor1);
            v.add(new StringConstant("test"));
            Expression thirdExpression = new Equal(v,true);

            // StringConstant("test") != StringConstant("testing")
            v.clear();
            v.add(new StringConstant("test"));
            v.add(new StringConstant("testing"));
            Expression fourthExpression = new Equal(v,true);

            assertFalse(
                ((Boolean) firstExpression.evaluate()).booleanValue());
            assertTrue(
                ((Boolean) secondExpression.evaluate()).booleanValue());
            assertTrue(
                ((Boolean) thirdExpression.evaluate()).booleanValue());
            assertFalse(
                ((Boolean) fourthExpression.evaluate()).booleanValue());
        } catch (SPLException e) {
          logger.severe("Received evaluation exception " + e.getMessage());
           
            fail("Received evaluation exception " + e.getMessage());
        } catch (Exception e) {
View Full Code Here


        try {
            // Property1 > Property2 (20 > 5) = true   
            Vector v = new Vector();
            v.add(propertySensor1);
            v.add(propertySensor2);
            Expression expression1 = new Greater(v,true);

            // Property3 > Property1 (-20 > 20) = false   
            v.clear();
            v.add(propertySensor3);
            v.add(propertySensor1);
            Expression expression2 = new Greater(v,true);

            v.clear();
            v.add(propertySensor1);
            v.add(new ShortConstant((short) 5));
            Expression expression3 = new Greater(v,true);

            v.clear();
            v.add(new ShortConstant((short) - 20));
            v.add(new ShortConstant((short) 20));
            Expression expression4 = new Greater(v,true);

            //TODO at least one comparison for each of the numeric types against another numeric type
            assertTrue(((Boolean) expression1.evaluate()).booleanValue());
            assertFalse(
                ((Boolean) expression2.evaluate()).booleanValue());
            assertTrue(((Boolean) expression3.evaluate()).booleanValue());
            assertFalse(
                ((Boolean) expression4.evaluate()).booleanValue());
        } catch (SPLException e) {
          logger.severe("Received evaluation exception " + e.getMessage());
           
            fail("Received evaluation exception " + e.getMessage());
        } catch (Exception e) {
View Full Code Here

        try {
            // Property1 > Property2 (20 > 5) = true   
            Vector v = new Vector();
            v.add(propertySensor1);
            v.add(propertySensor2);
            Expression expression1 = new Greater(v,true);

            // Property3 > Property1 (-20 > 20) = false   
            v.clear();
            v.add(propertySensor3);
            v.add(propertySensor1);
            Expression expression2 = new Greater(v,true);

            v.clear();
            v.add(propertySensor1);
            v.add(new IntegerConstant(5));
            Expression expression3 = new Greater(v,true);

            v.clear();
            v.add(new ShortConstant((short) - 20));
            v.add(new IntegerConstant(20));
            Expression expression4 = new Greater(v,true);

            assertTrue(((Boolean) expression1.evaluate()).booleanValue());
            assertFalse(
                ((Boolean) expression2.evaluate()).booleanValue());
            assertTrue(((Boolean) expression3.evaluate()).booleanValue());
            assertFalse(
                ((Boolean) expression4.evaluate()).booleanValue());
        } catch (SPLException e) {
          logger.severe("Received evaluation exception " + e.getMessage());
           
            fail("Received evaluation exception " + e.getMessage());
        } catch (Exception e) {
View Full Code Here

   
    public Object evaluate() throws SPLException
    {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
        //System.out.println("AllInCollection:evaluate");
        Expression lhsExpression = (Expression) this._lhsExp;
        Expression rhsExpression = (Expression) this._rhsExp;
       
        if (rhsExpression.isArray())
        {
            //System.out.println("rhs is of type Basic Collection");
            Object rhsResult = rhsExpression.evaluate();
            //System.out.println("rhsResult , class " + rhsResult + " "+ rhsResult.getClass());
            if (!(rhsResult instanceof java.util.List))
            {

                logger.severe(
View Full Code Here

    public boolean validate() throws SPLException
    {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");

        //System.out.println("AllInCollection : validate ");
        Expression expression1 = (Expression) this._lhsExp;
        Expression expression2 = (Expression) this._midExp;
        Expression expression3 = (Expression) this._rhsExp;
  //      expression3.validate();
        TypeInfo leftType = expression1.getType();
        TypeInfo middleType = expression2.getType();
        TypeInfo rightType = expression3.getType();
       
        if (!rightType.getIsArray())
        {
            logger.severe(
            "Last Expression should be a collection");
View Full Code Here

    public Object evaluate() throws SPLException
    {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");

        //System.out.println("ApplyToCollection:evaluate");
        Expression lhsExpression = (Expression) this._lhsExp;
        Expression rhsExpression = (Expression) this._rhsExp;
       
        if (rhsExpression.isArray())
        {
            //System.out.println("rhs is of type Basic Collection");
            Object rhsResult = rhsExpression.evaluate();
            //System.out.println("rhsResult , class " + rhsResult + " "+ rhsResult.getClass());
            if (!(rhsResult instanceof java.util.List))
            {
                //System.out.println("rhsResult is not of type List");
                throw new SPLException(Messages.getString(
View Full Code Here

    public boolean validate() throws SPLException
    {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");

        //System.out.println("ApplyToCollection : validate ");
        Expression expression1 = (Expression) this._lhsExp;
        Expression expression2 = (Expression) this._midExp;
        Expression expression3 = (Expression) this._rhsExp;
        TypeInfo leftType = expression1.getType();
        TypeInfo middleType = expression2.getType();
        TypeInfo rightType = expression3.getType();
       
        if (!expression3.isArray())
        {
            logger.severe(Thread.currentThread().getName()+" "+"Last Expression should be a collection");
           
            throw new SPLException("Last Expression should be a collection");
        }
View Full Code Here

        {
            Iterator expIterator = this._expressions.iterator();
            Number min = null;
            while (expIterator.hasNext())
            {
                Expression exp = (Expression) expIterator.next();
                Number evalResult = (Number) exp.evaluate();
               
                if (min == null)
                {
                    min = evalResult;
                }
View Full Code Here

        Iterator expIterator = this._expressions.iterator();
        TypeInfo currentDataType = new TypeInfoImpl();
        while (expIterator.hasNext())
        {
            Expression exp = (Expression) expIterator.next();
            TypeInfo type = exp.getType();
            if (!TypeResolver.isNumeric(type))
            {
                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
               
                return false;
View Full Code Here

  {
    List resultList = new ArrayList();
    Iterator expIt = _expressions.iterator();
    while (expIt.hasNext())
    {
      Expression exp = (Expression)expIt.next();
      Object result = exp.evaluate();
      resultList.add(result);
    }
   
   
    ReturnObjectStore.addReturnValues(resultList);
View Full Code Here

TOP

Related Classes of org.apache.imperius.spl.core.Expression

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.