Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.RArray


       */   
    static class Copyelements extends ROperator {
      Copyelements() {super("copyelements");}
     
      public void execute(DTState state) throws RulesException {
        RArray rarray     = state.datapop().rArrayValue();
        RArray newRArray  = rarray.clone(state.getSession()).rArrayValue();
        if(state.testState(DTState.TRACE)){
                  state.traceInfo("copyelements","id",rarray.getID()+"","newarrayid",newRArray.getID()+"",null);
            for(IRObject v : newRArray){
                      state.traceInfo("addto", "arrayID",rarray.getID()+"",v.postFix());
            }
                }
   
View Full Code Here


         */    
        static class DeepCopy extends ROperator {
            DeepCopy () {super("deepcopy");}
           
            public void execute(DTState state) throws RulesException {
                RArray rarray     = state.datapop().rArrayValue();
                RArray newRArray  = rarray.deepCopy(state.getSession()).rArrayValue();
               
                if(state.testState(DTState.TRACE)){
                    state.traceInfo("copyelements","id",rarray.getID()+"","newarrayid",newRArray.getID()+"",null);
                    for(IRObject v : newRArray){
                        state.traceInfo("addto", "arrayID",rarray.getID()+"",v.postFix());
                    }
                }
   
View Full Code Here

     
      public void execute(DTState state) throws RulesException {
        boolean asc  = state.datapop().booleanValue();
        int direction = asc ? 1 : -1;
       
        RArray rarray             = state.datapop().rArrayValue();
        ArrayList<IRObject> array = rarray.arrayValue();
       
                if(state.testState(DTState.TRACE)){
                   state.traceInfo("sort", "length",array.size()+"","arrayID",rarray.getID()+"",asc ? "true" : "false");
                }

        IRObject temp = null;
        int size = array.size();
        for(int i=0; i<size-1; i++){
View Full Code Here

      */
     public static class Translate extends ROperator {
         Translate(){super("translate"); }
         public void arrayExecute(DTState state) throws RulesException {
             boolean duplicates = state.datapop().booleanValue();
             RArray  keys       = state.datapop().rArrayValue();
             RTable  table      = state.datapop().rTableValue();
             RArray valueArray = new RArray(state.getSession().getUniqueID(),duplicates,false);
             for(IRObject key : keys){
                 if(table.containsKey(key)){
                    valueArray.add(table.getValue(key));
                 }
             }
             state.datapush(valueArray);
         }
View Full Code Here

      Sortentities() {super("sortentities");}
     
      public void execute(DTState state) throws RulesException {
        boolean asc  = state.datapop().booleanValue();
        RName rname = state.datapop().rNameValue();
        RArray rarray  = state.datapop().rArrayValue();
        ArrayList<IRObject> array = rarray.arrayValue();
        if(state.testState(DTState.TRACE)){
                 state.traceInfo("sortentities",
                         "length",   array.size()+"",
                         "by",       rname.stringValue(),
                         "arrayID",  rarray.getID()+"",
                         asc ? "true" : "false");
              }
        REntity temp = null;
        int size = array.size();
                int greaterthan = asc ? 1 : -1;
View Full Code Here

    public static class Forall extends ROperator {
        Forall(){super("forall");}

        public void execute(DTState state) throws RulesException {
           
            RArray   array = state.datapop().rArrayValue();
            IRObject body = state.datapop();        // Get the body
           
            for(IRObject o : array){
                 int      t = o.type().getId();
                 if(t== iNull)continue;
View Full Code Here

     */
    public static class For extends ROperator {
        For(){super("for");}

        public void execute(DTState state) throws RulesException {
            RArray   list = state.datapop().rArrayValue();
            IRObject body = state.datapop();        // Get the body
            for(IRObject o : list){
                 state.datapush(o);
                 body.execute(state);
            }
View Full Code Here

     */
    public static class Forfirst extends ROperator {
        Forfirst(){super("forfirst");}

        public void execute(DTState state) throws RulesException {
            RArray              array = state.datapop().rArrayValue();
            IRObject            test  = state.datapop();
            IRObject            body  = state.datapop();
            Iterator<IRObject>  ie    =  array.getIterator();
            while(ie.hasNext()){
                state.entitypush(ie.next().rEntityValue());
                test.execute(state);
                if(state.datapop().booleanValue()){
                    body.execute(state);
View Full Code Here

             
              if(Verbose()){
                  datamap.print(new FileOutputStream(getOutputDirectory()+root+"_datamap.xml"));
                 
                  entityfile = new FileOutputStream(getOutputDirectory()+root+"_entities_before.xml");
                  RArray entitystack = new RArray(0,false,false);
                  for(int i=0; i< session.getState().edepth()-2; i++){
                      entitystack.add(session.getState().entityfetch(i));
                  }
                  session.printEntityReport(new XMLPrinter(entityfile), false, session.getState(), "entitystack", entitystack);
              }
             
              // Once the data is loaded, execute the rules.
              RulesException ex = null;
              try{
                  executeDecisionTables(session);
              }catch(RulesException e){
                  ex = e;
              }
             
              // Then if asked, dump the entities.
              if(Verbose()){
                  entityfile = new FileOutputStream(getOutputDirectory()+root+"_entities_after.xml");
                  RArray entitystack = new RArray(0,false,false);
                  for(int i=0; i< session.getState().edepth()-2; i++){
                      entitystack.add(session.getState().entityfetch(i));
                  }
                  session.printEntityReport(new XMLPrinter(entityfile), false, session.getState(), "entitystack", entitystack);
               }
             
              if(ex!=null)throw ex;
View Full Code Here

    /**
     * By default, we will simply dump the entities as the report file.
     */
    public void printReport(int runNumber, IRSession session, PrintStream out)
            throws Exception {
        RArray entitystack = new RArray(0,false,false);
        for(int i=0; i< session.getState().edepth()-2; i++){
            entitystack.add(session.getState().entityfetch(i));
        }
        session.printEntityReport(new XMLPrinter(out), false, session.getState(), "entitystack", entitystack);
    }
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.