Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.RArray


    @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().getId() == 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


    public void execute(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 = RArray.newArray(state.getSession(), true, false)// Create a new array
      int newdepth = im++;                                                 // skip the mark (remember its index)
     
      while (im < state.ddepth()) {                                        // copy elements to the array
        IRObject o = state.getds(im++);
          newarray.add(o);
        if (state.testState(DTState.TRACE)) {
                  state.traceInfo("addto", "arrayId", newarray.getID() + "",
                          o.postFix());
              }
      }
     
      while (newdepth < state.ddepth())
View Full Code Here

        node.setList(new ArrayList<Object>());
      }else{
          node.getList().clear();
      }
     
        RArray result = (RArray) node.getTargetList();
        for(IRObject obj : result){
            Object value   = convert(obj);
            node.getList().add(value);
        }
       
View Full Code Here

      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

      super("intersection");
    }

    public void execute(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);
          if (state.testState(DTState.TRACE)) {
                    state.traceInfo("addto", "arrayId", ret.getID() + "",
                            v.postFix());
                }
        }
      }
View Full Code Here

      super("intersects");
    }

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

           *
           */
          public static class TestDateFormat extends ROperator {
            TestDateFormat() {super("testdateformat"); }
              public void arrayExecute(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().getId() != 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("addto");
    }

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

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.