Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.RArray


    public void arrayExecute(DTState state) throws RulesException {
      int im = state.ddepth() - 1; // Index of top of stack
      while (im >= 0 && state.getds(im).type().getId() != iMark)
        im--; // Index of mark
      RArray newarray = new RArray(state.getSession().getUniqueID(),
          true, false); // Create a new array
      int newdepth = im++; // skip the mark (remember its index)
      while (im < state.ddepth()) { // copy elements to the array
        newarray.add(state.getds(im++));
      }
      while (newdepth < state.ddepth())
        state.datapop(); // toss elements AND mark
      state.datapush(newarray); // push the new array.
    }
View Full Code Here


      super("addarray");
    }

    public void arrayExecute(DTState state) throws RulesException {
      boolean dups = state.datapop().booleanValue();
      RArray a2 = state.datapop().rArrayValue();
      RArray a1 = state.datapop().rArrayValue();

      for (IRObject o : a1) {
        if (dups || !a2.contains(o)) {
          a2.add(o);
        }
View Full Code Here

                if(obj1.type() != IRObject.iNull){
                   v = obj1.stringValue().trim();
                }  
                String [] results = v.split(pattern);
               
                RArray r = new RArray(state.getSession().getUniqueID(),false,false);
                for(String t : results){
                    r.add(RString.newRString(t));
                    if(state.testState(DTState.TRACE)){
                        state.traceInfo("addto", "arrayID",r.getID()+"",t);
                    }
                }
                state.datapush(r);
            }
View Full Code Here

      super("intersection");
    }

    public void arrayExecute(DTState state) throws RulesException {

      RArray array1 = state.datapop().rArrayValue();
      RArray array2 = state.datapop().rArrayValue();

      RArray ret = RArray.NewArray(state.getSession(), false, false);

      for (IRObject v : array1) {
        if (array2.contains(v)) {
          ret.add(v);
        }
      }

      state.datapush(ret);
    }
View Full Code Here

      super("intersects");
    }

    public void arrayExecute(DTState state) throws RulesException {

      RArray array1 = state.datapop().rArrayValue();
      RArray array2 = state.datapop().rArrayValue();

      for (IRObject v : array1) {
        if (array2.contains(v)) {
          state.datapush(RBoolean.getRBoolean(true));
          return;
        }
      }
View Full Code Here

    static class Addto extends ROperator {
      Addto(){super("addto");}

      public void execute(DTState state) throws RulesException {
        IRObject  value = state.datapop();
        RArray rarray  = state.datapop().rArrayValue();
        if(state.testState(DTState.TRACE)){
                    state.traceInfo("addto", "arrayID",rarray.getID()+"",value.postFix());
                }
        rarray.add(value);
      }
View Full Code Here

      Addat() {super("addat");}
     
      public void execute(DTState state) throws RulesException {
        IRObject value = state.datapop();
        int position = state.datapop().intValue();
                RArray rarray = state.datapop().rArrayValue();
        if(state.testState(DTState.TRACE)){
                    state.traceInfo("addat", "arrayID",rarray.getID()+"", "index",position+"",value.postFix());
                }
        rarray.add(position, value);
       
      }
View Full Code Here

    static class Remove extends ROperator {
      Remove() {super("remove");}
     
      public void execute(DTState state) throws RulesException {
        IRObject  value   = state.datapop();
        RArray    rarray  = (RArray)state.datapop();
                ArrayList array   = rarray.arrayValue();
                boolean removed = false;
                if(value!=null){
          for(int i=0; i<array.size();){
            if(value.equals((IRObject)array.get(i))){
                            if(state.testState(DTState.TRACE)){
                                state.traceInfo("removed", "arrayID",rarray.getID()+"",value.postFix());
                            }
              array.remove(i);
                            removed = true;
            } else {
              i++;
View Full Code Here

    static class Removeat extends ROperator {
      Removeat() {super("removeat");}
     
      public void execute(DTState state) throws RulesException {
        int position = state.datapop().intValue();
                RArray    rarray  = (RArray)state.datapop();
                if(position >= rarray.size()){
                    state.datapush(RBoolean.getRBoolean(false));
                }
               
                ArrayList array   = rarray.arrayValue();
                   if(state.testState(DTState.TRACE)){
                       state.traceInfo("removed", "arrayID",rarray.getID()+"","position",position+"",null);
                   }
               
                array.remove(position);       
                state.datapush(RBoolean.getRBoolean(true));
      }
View Full Code Here

       */   
    static class Newarray extends ROperator {
      Newarray() {super("newarray");}
     
      public void execute(DTState state) throws RulesException {
        IRObject irobject = new RArray(state.getSession().getUniqueID(),true, false);
        state.datapush(irobject);
      }
View Full Code Here

TOP

Related Classes of com.dtrules.interpreter.RArray

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.