Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.IRObject


           }
           if(type==null || defined==false){
               RName rname = RName.getRName(
                  (entity==null||entity.length()==0?"":entity+".")+ident);
               try {
                  IRObject o = session.getState().find(rname);
                  if(o==null)return -1;
                  return o.type();
                } catch (RulesException e) {
                  return -1;
                }
           }
          
View Full Code Here


      */
     public static class GetWithKey extends ROperator {
         GetWithKey(){ super("getwithkey");}
        
         public void execute(DTState state) throws RulesException {
             IRObject key = state.datapop();
             RTable rtable = state.datapop().rTableValue();
             state.datapush(rtable.getValue(key));
         }
View Full Code Here

    private void dump(IREntity e,int depth){
        Iterator<RName> anames = e.getAttributeIterator();
        while(anames.hasNext()){
            try {
                RName        aname = anames.next();
                IRObject     value = e.get(aname);
               
                dtstate.traceTagBegin("attribute", "name",aname.stringValue(),"type",getType(e,aname));
                int type = e.getEntry(aname).type.getId();
               
               if(type == IRObject.iEntity) {
                      if(value.type().getId() == IRObject.iNull){
                          dtstate.traceInfo("value","type","null","value","null",null);
                      }else{
                        dtstate.traceTagBegin("entity",
                                "name",   ((REntity)value).getName().stringValue(),
                                "id",     printIds ? ((REntity)value).getID()+"" : "");
                       
                        if(!(boundries.get(e)!= null && boundries.get(e).contains(value))){
                            dtstate.debug(" recurse\n");
                        }else{
                            if(boundries.get(e)==null)boundries.put(e, new ArrayList<IREntity>());
                            boundries.get(e).add(value.rEntityValue());
                            dump((IREntity)value, depth+1);
                        }
                        dtstate.traceTagEnd();
                      }
               }else if (type == IRObject.iArray) {
                      ArrayList<IRObject> values = value.arrayValue();
                      for(IRObject v : values){
                          if(v.type().getId() ==IRObject.iEntity){
                              dump((REntity)v,depth+2);
                          }else{
                              dtstate.traceInfo("value","v",v.stringValue(),null);
                          }
                      }
               } else {
                       dtstate.traceInfo("value","v",value.stringValue(),null);
               }
               
                dtstate.traceTagEnd();
            } catch (RulesException e1) {
                dtstate.debug("Rules Engine Exception\n");
View Full Code Here

    static class Lookup extends ROperator {
        Lookup(){super("lookup");}

        public void execute(DTState state) throws RulesException {
            RName name = state.datapop().rNameValue();
            IRObject value = state.find(name);
            if(value == null){
                throw new RulesException(
                        "undefined",
                        "Lookup",
                        "Could not find a value for "+name.stringValue()+" in the current context."
View Full Code Here

     public static class SetWithKey extends ROperator {
         SetWithKey(){ super("setwithkey"); }
     
         public void execute(DTState state) throws RulesException {
            
             IRObject   v      = state.datapop();                // Get the value to store
             IRObject   key    = state.datapop().rNameValue();
             RTable     rtable = state.datapop().rTableValue();
             rtable.setValue(key,v);
            
         }
View Full Code Here

   */
 
 
   public void printEntity(IXMLPrinter rpt, String tag, IREntity e) throws Exception {
       if(tag==null)tag = e.getName().stringValue();
       IRObject id = e.get(RName.getRName("mapping*key"));
       String   idString = id!=null?id.stringValue():"--none--";
         rpt.opentag(tag,"DTRulesId",e.getID()+"","id",printIds ? idString : "");
         Set<RName> names = e.getAttributeSet();
         RName keys[] = sort(names);
         for(RName name : keys){
             IRObject v    = e.get(name);
             if(v.type().getId()==IRObject.iArray && v.rArrayValue().size()==0) continue;
             String   vstr = v==null?"":v.stringValue();
             rpt.printdata("attribute","name",name.stringValue(), vstr);
         }
   }
View Full Code Here

     public static class SetWithKeys extends ROperator {
         SetWithKeys(){ super("setwithkeys");}
        
         public void execute(DTState state) throws RulesException {
             int       cnt = 0;                             // We keep a count of the keys.
             IRObject  v   = state.datapop();               // Get the value to store
             int       d   = state.ddepth()-1;              // Get current depth of data stack less one for the value.
            
             while(state.getds(--d).type().getId()==iTable)cnt++;   // Count the keys (index1, index2, etc.)
            
             if(cnt != 1){
                 IRObject []keys = new IRObject[cnt];           // Get an array big enough to hold the keys
                
                 for(int i=0;i<cnt;i++){                        // Get all the keys off the data stack
                    keys[i]= state.datapop();
                 }
                
                 RTable rtable = state.datapop().rTableValue();
                
                 rtable.setValue(state,keys, v);                // Set the value.
             }else{
                 IRObject   key    = state.datapop();
                 RTable     rtable = state.datapop().rTableValue();
                 rtable.setValue(key,v);
             }
            
            
View Full Code Here

             RTable table)throws RulesException{
        
         Set<IRObject> keys = table.getTable().keySet();
           rpt.opentag("map", "id", printIds ? table.getId(): "");
               for(IRObject key : keys){
                  IRObject value = table.getValue(key);
                  rpt.opentag("pair");
                      rpt.opentag("key");
                          printIRObject(rpt,entitypath,printed,state,"",key);
                      rpt.closetag();
                      rpt.opentag("value");
View Full Code Here

         printEntityReport(rpt,false, false,state,objname);
     }
     public void printEntityReport(IXMLPrinter rpt, boolean printIds, boolean verbose, DTState state, String name ) {
         this.printIds = printIds;
       IRObject obj = state.find(name);
         printEntityReport(rpt,printIds, verbose,state,name,obj);
     }
View Full Code Here

         }else if (printed!= null && printed.contains(e)){
                 rpt.printdata(entityName,"DTRulesId",printIds ? e.getID():"","id",e.get("mapping*key").stringValue(),"multiple reference")
         }else{
             entitypath.add(e);
             if(printed!=null) printed.add(e);
             IRObject id = e.get(RName.getRName("mapping*key"));
             String   idString = id!=null?id.stringValue():"--none--";
             rpt.opentag(entityName,"DTRulesId",printIds ? e.getID():"","id",idString);
             Set<RName> keys = e.getAttributeSet();
             RName akeys [] = sort(keys);
             for(RName name : akeys){
                 IRObject v    = e.get(name);
                 printIRObject(rpt, entitypath, printed, state, name.stringValue(), v);
             }
             rpt.closetag();
             entitypath.remove(entitypath.size()-1);
         }
View Full Code Here

TOP

Related Classes of com.dtrules.interpreter.IRObject

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.