Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.RArray


      Add_no_dups(){super("add_no_dups");}

      public void execute(DTState state) throws RulesException {
               
        IRObject  value  = state.datapop();
                RArray    rArray = (RArray) state.datapop();
        for(IRObject v : rArray){
          if(value.equals((IRObject)v)){
            return;
          }
        }
        rArray.add(value);
                if(state.testState(DTState.TRACE)){
                    state.traceInfo("addto", "arrayId",rArray.getID()+"",value.postFix());
                }

      }
View Full Code Here


        ArrayList array2  = state.datapop().arrayValue();
        ArrayList array1  = state.datapop().arrayValue();
        ArrayList newarray = new ArrayList();
        newarray.addAll(array1);
        newarray.addAll(array2);
        state.datapush(new RArray(state.getSession().getUniqueID(),false,newarray, false));
      }
View Full Code Here

            Arraytomark(){super("arraytomark");}

            public void execute(DTState state) throws RulesException {
               int im = state.ddepth()-1;                   // Index of top of stack
               while(im>=0 && state.getds(im).type()!=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

        static class AddArray extends ROperator {
            AddArray(){super("addarray");}

            public void execute(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

      */
     public static class Translate extends ROperator {
         Translate(){super("translate"); }
         public void execute(DTState state) throws RulesException {
             boolean duplicates = state.datapop().booleanValue();
             RArray  keys       = state.datapop().rArrayValue();
             RTable  table      = state.datapop().rTableValue();
             RArray valueArray = RArray.newArray(state.getSession(),duplicates,false);
             for(IRObject key : keys){
                 if(table.containsKey(key)){
                    IRObject o = table.getValue(key);
                    valueArray.add(o);
                    if (state.testState(DTState.TRACE)) {
                        state.traceInfo("addto", "arrayId", valueArray.getID() + "",
                                o.postFix());
                    }

                 }
             }
View Full Code Here

      if (obj1.type().getId() != IRObject.iNull) {
        v = obj1.stringValue().trim();
      }
      String[] results = v.split(pattern);

      RArray r = RArray.newArray(state.getSession(), 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("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

    FindMatch() {
      super("findmatch");
    }

    public void execute(DTState state) throws RulesException {
      RArray array = state.datapop().rArrayValue();
      IRObject v3 = state.datapop();
      IRObject n3 = state.datapop();
      IRObject v2 = state.datapop();
      IRObject n2 = state.datapop();
      IRObject v1 = state.datapop();
View Full Code Here

    }

    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

      super("remove");
    }

    public void execute(DTState state) throws RulesException {
      IRObject value = state.datapop();
      RArray rarray = (RArray) state.datapop();
      List<IRObject> 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

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.