Package org.apache.imperius.spl.core

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


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

        //System.out.println("AnyInCollection: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(Thread.currentThread().getName()+" "+"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("AnyInCollection : 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.getType().getIsArray())
        {
          //System.out.println(" expression3.getType().getIsArray() "+expression3.getType().getIsArray());
          //System.out.println("expression3 "+expression3.getClass()+" "+expression3.toString());
          logger.severe(Thread.currentThread().getName()+" "+"Last Expression should be a collection");
           
View Full Code Here

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

       //System.out.println("SubCollection : validate ");
        Expression lhsExpression = (Expression) this._lhsExp;
        Expression rhsExpression = (Expression) this._rhsExp;
        if ((lhsExpression == null) || (rhsExpression == null))
        {
           //System.out.println("SubCollection : One or more expressions are null ");
            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
           
            return false;
        }
        if (!TypeResolver.areTypesEqual(lhsExpression.getType(),rhsExpression.getType()))
        {
           //System.out.println("SubCollection : lhs Type !=rhs Type " + lhsExpression.getType() + ":" + rhsExpression.getType());
            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
           
            return false;
        }
        if (lhsExpression.isArray())
        {
           //System.out.println("lhsExpression.getType() ==TypeConstants.basicCollectionType");
            if (rhsExpression.isArray())
            {
               //System.out.println("rhsExpression.getType() ==TypeConstants.basicCollectionType");
                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
               
                return true;
View Full Code Here

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

       //System.out.println("Union : validate ");
        Expression lhsExpression = (Expression) this._lhsExp;
        Expression rhsExpression = (Expression) this._rhsExp;
        _dataType.copy(_lhsExp.getType());
       
        if ((lhsExpression == null) || (rhsExpression == null))
        {
           //System.out.println("Union : One or more expressions are null ");
            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
           
            return false;
        }
        if (lhsExpression.getType().getType() != rhsExpression.getType().getType())
        {
           //System.out.println("Union : lhs Type !=rhs Type "+ lhsExpression.getType() + ":" + rhsExpression.getType());
            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
           
            return false;
        }
        if (lhsExpression.isArray())
        {
           //System.out.println("lhsExpression.getType() ==TypeConstants.basicCollectionType");
            if (rhsExpression.isArray())
            {
               //System.out.println("rhsExpression.getType() ==TypeConstants.basicCollectionType");
                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
               
                return true;
View Full Code Here

    //HashMap map = new HashMap();
    //SensorLookup lookup = new SensorLookupImpl(map);

    try {
      Vector v = new Vector();
      Expression exp;
      v.add(new StringConstant(string));
      v.add(ic4);
      v.add(ic5);
      v.add(lr);
      Expression esnnl = new MiddleSubstring(v,true);

      v.clear();
      v.add(new StringConstant(string));
      v.add(ic4);
      v.add(ic5);
      v.add(rl);
      Expression esnnr = new MiddleSubstring(v,true);

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"om\""));
      v.add(ic5);
      v.add(lr);
      Expression essnl = new MiddleSubstring(v,true);

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"om\""));
      v.add(ic5);
      v.add(rl);
      Expression essnr = new MiddleSubstring(v,true);

      v.clear();
      v.add(new StringConstant(string));
      v.add(ic4);
      v.add(new StringConstant("\"om\""));
      v.add(lr);
      Expression esnsl = new MiddleSubstring(v,true);

      v.clear();
      v.add(new StringConstant(string));
      v.add(ic4);
      v.add(new StringConstant("\"om\""));
      v.add(rl);
      Expression esnsr = new MiddleSubstring(v,true);

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"on\""));
      v.add(new StringConstant("\"om\""));
      v.add(lr);
      Expression esssl = new MiddleSubstring(v,true);

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"on\""));
      v.add(new StringConstant("\"om\""));
      v.add(rl);
      Expression esssr = new MiddleSubstring(v,true);

      assertTrue(((String) esnnl.evaluate()).equals("nomic"));
      assertTrue(((String) esnnr.evaluate()).equals("ing"));
      assertTrue(((String) essnl.evaluate()).equals("icCom"));
      assertTrue(((String) essnr.evaluate()).equals("putin"));
      assertTrue(((String) esnsl.evaluate()).equals("n"));
      assertTrue(((String) esnsr.evaluate()).equals("pu"));
      assertTrue(((String) esssl.evaluate()).equals(""));
      assertTrue(((String) esssr.evaluate()).equals("Aut"));

      v.clear();
      v.add(new StringConstant(string));
      v.add(new IntegerConstant(4));
      v.add(new IntegerConstant(5));
View Full Code Here

    try {
      Vector v = new Vector();
      v.add(new StringConstant(string));
      v.add(ic4);
      v.add(lr);
      Expression esnl = new RightSubstring(v,true);
      // Examples: RightSubstring("AutonomicComputing", 4, LeftToRight) = "ting".

      v.clear();
      v.add(new StringConstant(string));
      v.add(icmin1);
      v.add(lr);
      Expression esnlmin1 = new RightSubstring(v,true);
      // Examples: RightSubstring("AutonomicComputing", -1, LeftToRight) = "AutonomicComputing".

      v.clear();
      v.add(new StringConstant(string));
      v.add(ic4);
      v.add(rl);
      Expression esnr = new RightSubstring(v,true);
      // RightSubstring("AutonomicComputing", 4, RightToLeft) = "nomicComputing".<p>

      v.clear();
      v.add(new StringConstant(string));
      v.add(icmin1);
      v.add(rl);
      Expression esnrmin1 = new RightSubstring(v,true);
      // Examples: RightSubstring("AutonomicComputing", -1, RightToLeft) = "".

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"om\""));
      v.add(lr);
      Expression essl = new RightSubstring(v,true);
      // Examples: RightSubstring("AutonomicComputing", "om", LeftToRight)="icComputing"

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"jj\""));
      v.add(lr);
      Expression esslne = new RightSubstring(v,true);
      // Examples: RightSubstring("AutonomicComputing", "jj", LeftToRight)=""

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"om\""));
      v.add(rl);
      Expression essr = new RightSubstring(v,true);
      // RightSubstring("AutonomicComputing", "om", RightToLeft)="puting".

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"jj\""));
      v.add(rl);
      Expression essrne = new RightSubstring(v,true);
      // RightSubstring("AutonomicComputing", "jj", RightToLeft)="".

      assertTrue(((String) esnl.evaluate()).equals("ting"));
      assertTrue(
          ((String) esnlmin1.evaluate()).equals(
          "AutonomicComputing"));
      assertTrue(
          ((String) esnr.evaluate()).equals("nomicComputing"));
      assertTrue(((String) esnrmin1.evaluate()).equals(""));
      assertTrue(((String) essl.evaluate()).equals("icComputing"));
      assertTrue(((String) esslne.evaluate()).equals(""));
      assertTrue(((String) essr.evaluate()).equals("puting"));
      assertTrue(((String) essrne.evaluate()).equals(""));
    } catch (SPLException e) {
      fail("Received evaluation exception " + e.getMessage());
    } catch (Exception e) {
      fail("Received expression exception " + e.getMessage());
    }
View Full Code Here

    try {
      Vector v = new Vector();
      v.add(new StringConstant(string));
      v.add(ic4);
      v.add(lr);
      Expression esnl = new LeftSubstring(v,true);
      // Examples: LeftSubstring("AutonomicComputing", 4, LeftToRight) = "Auto".

      v.clear();
      v.add(new StringConstant(string));
      v.add(icmin1);
      v.add(lr);
      Expression esnlmin1 = new LeftSubstring(v,true);
      // Examples: LeftSubstring("AutonomicComputing", -1, LeftToRight) = "AutonomicComputing".

      v.clear();
      v.add(new StringConstant(string));
      v.add(ic4);
      v.add(rl);
      Expression esnr = new LeftSubstring(v,true);
      // LeftSubstring("AutonomicComputing", 4, RightToLeft) = "AutonomicCompu".

      v.clear();
      v.add(new StringConstant(string));
      v.add(icmin1);
      v.add(rl);
      Expression esnrmin1 = new LeftSubstring(v,true);
      // Examples: LeftSubstring("AutonomicComputing", -1, RightToLeft) = "".

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"om\""));
      v.add(lr);
      Expression essl = new LeftSubstring(v,true);
      // Examples: LeftSubstring("AutonomicComputing", "om", LeftToRight)="Auton"

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"\""));
      v.add(lr);
      Expression esslempty = new LeftSubstring(v,true);
      // Examples: LeftSubstring("AutonomicComputing", "", LeftToRight)=""

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"om\""));
      v.add(rl);
      Expression essr = new LeftSubstring(v,true);
      // LeftSubstring("AutonomicComputing", "om", RightToLeft)="AutonomicC"

      v.clear();
      v.add(new StringConstant(string));
      v.add(new StringConstant("\"\""));
      v.add(lr);
      Expression essrempty = new LeftSubstring(v,true);
      // Examples: LeftSubstring("AutonomicComputing", "", RightToLeft)=""

      assertTrue(((String) esnl.evaluate()).equals("Auto"));
      assertTrue(
          ((String) esnlmin1.evaluate()).equals(
          "AutonomicComputing"));
      assertTrue(
          ((String) esnr.evaluate()).equals("AutonomicCompu"));
      assertTrue(((String) esnrmin1.evaluate()).equals(""));
      assertTrue(((String) essl.evaluate()).equals("Auton"));
      assertTrue(((String) esslempty.evaluate()).equals(""));
      assertTrue(((String) essr.evaluate()).equals("AutonomicC"));
      assertTrue(((String) essrempty.evaluate()).equals(""));
    } catch (SPLException e) {
      fail("Received evaluation exception " + e.getMessage());
    } catch (Exception e) {
      fail("Received expression exception " + e.getMessage());
    }
View Full Code Here

    //SensorLookup lookup = new SensorLookupImpl(map);

    try {
      Vector v = new Vector();
      v.add(new StringConstant(s1));
      Expression e1 = new StringLength(v,true);

      v.clear();
      v.add(new StringConstant(s2));
      Expression e2 = new StringLength(v,true);

      v.clear();
      v.add(new StringConstant(s3));
      Expression e3 = new StringLength(v,true);

      v.clear();
      v.add(propertySensor1);
      Expression eps1 = new StringLength(v,true);

      v.clear();
      v.add(propertySensor2);
      Expression eps2 = new StringLength(v,true);

      v.clear();
      v.add(propertySensor3);
      Expression eps3 = new StringLength(v,true);
      s1 = s1.substring(1, s1.length()-1);
      s2 = s2.substring(1, s2.length()-1);
      s3 = s3.substring(1, s3.length()-1);

      assertTrue(
          new Integer(s1.length()).compareTo((Integer)e1.evaluate()) == 0);
      assertTrue(
          new Integer(s2.length()).compareTo((Integer)e2.evaluate()) == 0);
      assertTrue(
          new Integer(s3.length()).compareTo((Integer)e3.evaluate()) == 0);
      assertTrue(
          new Integer(s1.length()).compareTo((Integer)eps1.evaluate()) == 0);
      assertTrue(
          new Integer(s2.length()).compareTo((Integer)eps2.evaluate()) == 0);
      assertTrue(
          new Integer(s3.length()).compareTo((Integer)eps3.evaluate()) == 0);
    } catch (SPLException e) {
      fail("Received evaluation exception " + e.getMessage());
    } catch (Exception e) {
      fail("Received expression exception " + e.getMessage());
    }
View Full Code Here

    try {
      Vector v = new Vector();
      v.add(new StringConstant(s1));
      v.add(new StringConstant(s2));
      v.add(new StringConstant(s3));
      Expression e1 = new ReplaceSubstring(v,true);

      v.clear();
      v.add(propertySensor1);
      v.add(propertySensor2);
      v.add(propertySensor3);
      Expression eps1 = new ReplaceSubstring(v,true);
      s4 = s4.substring(1, s4.length()-1);
      assertTrue(s4.compareTo((String)e1.evaluate()) == 0);
      assertTrue(s4.compareTo((String)eps1.evaluate()) == 0);
    } catch (SPLException e) {
      fail("Received evaluation exception " + e.getMessage());
    } catch (Exception e) {
      fail("Received expression exception " + e.getMessage());
    }
View Full Code Here

    try {
      Vector v = new Vector();
      v.add(new StringConstant(s1));
      v.add(new StringConstant(s2));
      Expression e1 = new StartsWith(v,true);

      v.clear();
      v.add(propertySensor1);
      v.add(propertySensor2);
      Expression eps1 = new StartsWith(v,true);

      assertTrue(((Boolean) (e1.evaluate())).booleanValue());
      assertTrue(((Boolean) (eps1.evaluate())).booleanValue());
    } catch (SPLException e) {
      fail("Received evaluation exception " + e.getMessage());
    } catch (Exception e) {
      fail("Received expression exception " + e.getMessage());
    }
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.