Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.RArray


    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();
                 if(t== iNull)continue;
View Full Code Here


     */
    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

           *
           */
          static class TestDateFormat extends ROperator {
            TestDateFormat() {super("testdateformat"); }
              public void execute(DTState state) throws RulesException {
                  RArray formatStrings = state.datapop().rArrayValue();
                  String formats[]     = new String[formatStrings.size()];
                  for(int i=0; i<formats.length; i++){
                    formats[i]=formatStrings.get(i).stringValue();
                  }
                  String dateStr = state.datapop().stringValue();
                boolean result = state.getSession().getDateParser().testFormat(dateStr,formats);
                  state.datapush(RBoolean.getRBoolean(result));
              }
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

    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 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<REntity> ie = (Iterator<REntity>) array.getIterator();
            while(ie.hasNext()){
                state.entitypush(ie.next());
                test.execute(state);
                if(state.datapop().booleanValue()){
                    body.execute(state);
View Full Code Here

     */
    static class ForFirstElse extends ROperator {
        ForFirstElse(){super("forfirstelse");}

        public void execute(DTState state) throws RulesException {
            RArray   array = state.datapop().rArrayValue();
            IRObject test  = state.datapop();
            IRObject body2 = state.datapop();
            IRObject body1 = state.datapop();
            for(IRObject obj : array) {
                IREntity e = obj.rEntityValue();
View Full Code Here

                        "EntityFactory.computeDefaultValue()",
                        "Entity Factory does not define an entity '"+defaultstr+"'");
                return e;
            }
            case IRObject.iArray : {
                if(defaultstr.length()==0) return new RArray(ef.getUniqueID(), true,false);
                RArray rval;
                try{
                     RArray v = (RArray) RString.compile(session, defaultstr, false);     // We assume any values are surrounded by brackets, and regardless make
                    
                     rval = v.get(0).getNonExecutable().rArrayValue();             // sure they are non-executable.
                }catch(RulesException e){
                    throw new RulesException("ParsingError","EntityFactory.computeDefaultValue()","Bad format for an array. \r\n"+
                            "\r\nWe tried to interpret the string \r\n'"+defaultstr+"'\r\nas an array, but could not.\r\n"+e.toString());
                }
                return rval;
View Full Code Here

    @SuppressWarnings({ "unchecked", "deprecation" })
    @Override
    public Object mapList(AutoDataMap autoDataMap, LabelMap labelMap, MapNodeList node) {
        IAttribute a = node.getAttribute();
        try {
            RArray list = null;
            RName rname = null;
            Object object = autoDataMap.getCurrentObject();
            if(object instanceof IREntity){
                IREntity entity = (IREntity) object;
                rname = mapName(autoDataMap, labelMap, node.getLabel());
                IRObject olist = entity.get(rname);
                if(olist != null && olist.type() == IRObject.iArray){
                    list = olist.rArrayValue();
                }
            }
           
            node.setTargetList(list);
           
            // Handle Arrays of primitives ... We just keep a link to the list
            // from our data source in this case.
            if(a.getSubType().isPrimitive()){
                if(list == null) return null;
      
                if(node.getData()!=null) for (Object d : (List<Object>) node.getData()){
                    list.add(iconvert(d));
                }
                return list;
            }else{
                List<IMapNode> children = node.getChildren();
                for(IMapNode c : children){
                    autoDataMap.pushMark(); // Make sure no children try and update our list's parent
                    Object o = c.mapNode(autoDataMap, labelMap);
                    if(o instanceof List && ((List)o).size()==1){ // Mostly we are going to get an array of length 
                        o = ((List)o).get(0);                     //   one of the object we want.  If that's the
                    }                                             //   case, get the object we want from the List.
                    autoDataMap.pop();                            // Remove the mark.
                    if(list!=null                                 // If we have a list, and
                            && o != null                          //   a rules engine object
                            && o instanceof IRObject){            //   then add it to our list.
                        list.add((IRObject)o);      // then add it to the list.
                    }
                }
            }
        } catch (RulesException e) {}
       
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.