Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.RName


   * Entity.
   */
  HashMap entities = new HashMap();
 
  IREntity UpdateReferences(IREntity e, EntityInfo info)throws RulesException {
    RName listname;
    if(info!=null && info.list.length()==0){
        listname   = RName.getRName(e.getName().stringValue()+"s");
    }else{
      listname   = RName.getRName(info.list);
    }
View Full Code Here


            IREntity        entity  = state.datapop().rEntityValue()// Get the entity
            IRObject        body    = state.datapop();                    // Get the body
            Iterator<RName> keys    = entity.getAttributeIterator();      // Get the Attribute Iterator
           
            while(keys.hasNext()){                         // For each attribute
                RName     n = (RName) keys.next();
                IRObject  v = entity.get(n);
                if(v!=null){
                    state.datapush(n);
                    state.datapush(v);
                    body.execute(state);
View Full Code Here

                      break;
                  }
              }
           }
           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().getId();
View Full Code Here

            
             // Select a particular rule set and create a session to load the data and evaluate
             // that data against the rules within this ruleset. 
          
             String         ruleset  = getRuleSetName();
             RName          rsName   = RName.getRName(ruleset);
             RuleSet        rs       = rd.getRuleSet(rsName);
             File           dir      = new File(getTestDirectory());
             File           files[]  = dir.listFiles();
             int            dfcnt    = 1;
            
View Full Code Here

  public String toString(){
    String v = name.stringValue()+" = {";
        Iterator<RName> ia = getAttributeIterator();
        while(ia.hasNext()){
            RName    n = ia.next();
            IRObject o = get(n);
            if(o==null){                // Protect ourselves from nulls.
                o = RNull.getRNull();
            }
            v +=n.stringValue()+" = "+get(n).stringValue()+"  ";
        }
        v +="}";
        return v;
       
  }
View Full Code Here

   
    public void writeXML(PrintStream p) throws RulesException {
        Iterator<RName> attribs = getAttributeIterator();
        p.println();
        while(attribs.hasNext()){
           RName attrib = attribs.next();
           if(attrib.equals(name))continue;     // Skip the self reference.
           REntityEntry entry = attributes.get(attrib);
           p.print("<entity attribute=\"");
           p.print(attrib.stringValue());
           p.print("\" type =\"");
           p.print(RSession.typeInt2Str(entry.type));
           p.print("\" cdd_default_value=\"");
           p.print(entry.defaulttxt);
           p.print("\" cdd_i_c=\"");
View Full Code Here

        private IRObject p(String v) { return RString.newRString(v==null?"":v); }
        private RName    n(String x) { return RName.getRName(x);}
       
        public void execute(DTState state) throws RulesException {
            RName    error        = state.datapop().rNameValue();
            RName    table        = state.datapop().rNameValue();
           
            try{
                state.find(table).execute(state);
            }catch(NullPointerException e){
                throw new RulesException("undefined", "PerformCatchError",
                        "The table '"+table.stringValue()+"' is undefined");
            }catch(RulesException e){
                IRSession     session       = state.getSession();
                EntityFactory ef            = session.getEntityFactory();  
                IREntity      errorEntity   = ef.findRefEntity(error).clone(session).rEntityValue();
                state.entitypush(errorEntity);
View Full Code Here

        if(types!=null)return types;
       
        types = new HashMap<RName, IRType>();
        Iterator<RName> entities = ef.getEntityRNameIterator();
        while(entities.hasNext()){
            RName     name    = entities.next();
            IREntity  entity  = ef.findRefEntity(name);
            Iterator<RName> attribs = entity.getAttributeIterator();
            addType(entity,entity.getName(),IRObject.iEntity);
            while(attribs.hasNext()){
                RName        attribname = attribs.next();
                REntityEntry entry      = entity.getEntry(attribname);
                addType(entity,attribname,entry.type.getId());
            }
        }
       
        Iterator<RName> tables = ef.getDecisionTableRNameIterator();
        while(tables.hasNext()){
            RName tablename = tables.next();
            ELType type = new ELType(tablename,IRObject.iDecisiontable,(REntity) ef.getDecisiontables());
            if(types.containsKey(tablename)){
                System.out.println("Multiple Decision Tables found with the name '"+types.get(tablename)+"'");
            }
            types.put(tablename, type);
View Full Code Here

     */
    public void printTypes(PrintStream out) throws RulesException {
        Object typenames[] = types.keySet().toArray();
        for(int i=0;i<typenames.length-1;i++){
            for(int j=0;j<typenames.length-1;j++){
                RName one = (RName)typenames[j], two = (RName)typenames[j+1];
                if(one.compare(two)>0){
                    Object hold = typenames[j];
                    typenames[j]=typenames[j+1];
                    typenames[j+1]=hold;
                }
            }
        }
        for(int i=0;i<typenames.length-1;i++){
            for(int j=0;j<typenames.length-1;j++){
                RName one = (RName)typenames[j], two = (RName)typenames[j+1];
                if(((ELType)types.get(one)).getType()> ((ELType)types.get(two)).getType()){
                    Object hold = typenames[j];
                    typenames[j]=typenames[j+1];
                    typenames[j+1]=hold;
                }
View Full Code Here

     */
    public 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."
                );
            }
            state.datapush(value);
        }
View Full Code Here

TOP

Related Classes of com.dtrules.interpreter.RName

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.