Package com.dtrules.infrastructure

Examples of com.dtrules.infrastructure.RulesException


    /**
     * @see com.dtrules.interpreter.IRObject#tableValue()
     */
    public Map<IRObject,IRObject> tableValue() throws RulesException {
        throw new RulesException("Undefined","Not Supported","No Table value exists for "+RSession.typeInt2Str(this.type()));
    }
View Full Code Here


      if(e==null) {
              e = ((RSession)session).createEntity(null,entity);
          }
      if(code!=null) entities.put(key,e);
     }
       if(e==null)throw new RulesException("undefined","LoadMapping.findEntity()","Failed to create the entity "+entity);
       UpdateReferences(e,info);
       return e;
 
View Full Code Here

                            value = RBoolean.getRBoolean(body.length()==0? "false" : body);
                        } else if (type == IRObject.iTime){
                            if(body.trim().length()>0){
                              value = RTime.getRDate(session,body);
                              if(value == null){
                                throw new RulesException("MappingError","LoadMapping","Bad Date... Could not parse '"+body+"'");
                              }
                            }else{
                              value = RNull.getRNull();
                            }
                        } else if (type == IRObject.iEntity){
                            if(entity!=null){
                               value = entity;
                            }else{
                                throw new RulesException("MappingError","LoadMapping","Entity Tags have to create some Entity Reference");
                            }   
                        }else {
                value = RString.newRString(body);
              }
              //   conversion in the Rules Engine to do the proper thing.
View Full Code Here

               }else if(token.getType()== Token.Type.LSQUARE) {
                          IRObject o = compile(ruleset,tokenizer, v, false, depth+1);
                          result.add(o);
               }else if(token.getType()== Token.Type.RSQUARE) {
                          if(depth==0 || executable){
                              throw new RulesException("Parsing Error",
                                      "String Compile",
                                      "\nError parsing <<"+v+">> \nThe token ']' was unexpected.");
                                    
                          }
                          return result;
               }else if(token.getType()== Token.Type.LCURLY) {
                          IRObject o = compile(ruleset,tokenizer,v,true,  depth+1);
                          result.add(o);
               }else if(token.getType()== Token.Type.RCURLY) {
                          if(depth==0 || !executable){
                              throw new RulesException("Parsing Error",
                                      "String Compile",
                                      "\nError parsing <<"+v+">> \nThe token '}' was unexpected.");
                                     
                          }
                          return result;
               }else if(token.getType()== Token.Type.NAME) {
                      if(token.nameValue.isExecutable()){       // All executable names are checked for compile time lookup.
                          IRObject prim = lookup(ruleset,token.nameValue);
                          if(prim == null){                     // If this name is not a primitive, then
                              result.add(token.nameValue);      // then add the name as it is to the array.
                          }else{   
                              result.add(prim);                 // Otherwise, compile the reference to the operator.
                          }
                      }else{
                  result.add(token.nameValue);
                      }
                     
               }else if (token.getType() == Token.Type.DATE){
                      result.add(token.datevalue);
                     
               }else if (token.getType()== Token.Type.INT) {   
              RInteger i = RInteger.getRIntegerValue(token.longValue);
              result.add(i);
         }else if (token.getType()== Token.Type.REAL) {
              RDouble d = RDouble.getRDoubleValue(token.doubleValue);
              result.add(d);
         }
       }
           if(depth!=0){
               throw new RulesException("Parsing Error",
                       "String Compile",
                       "\nError parsing << " + v + " >>\n missing a " + (executable ? "}" : "]"));
                      
           }
       return (IRObject) result;
      } catch (RuntimeException e) {
       throw new RulesException("Undefined","String Compile","Error compiling string: '"+v+"'\n"+e);
      }
      
  }
View Full Code Here

   */
  public void execute(DTState state) throws RulesException
    cnt++;
        IRObject o = state.find(this);          // Does a lookup of the name on the Entity Stack
    if(o==null){
            throw new RulesException("Undefined","RName","The Name '"+name+"' was not defined by any Entity on the Entity Stack");
    }
    if(o.isExecutable()){
      o.execute(state);
    }else{
      state.datapush(o);
View Full Code Here

     * @return -- The new decision table
     */
    public RDecisionTable newDecisionTable(RName name, IRSession session)throws RulesException{
        IRObject table = decisiontables.get(name);
        if(table !=null && table.type() != IRObject.iDecisiontable){
            throw new RulesException("ParsingError","New Decision Table","For some reason, "+name.stringValue()+" isn't a decision table");
        }
        if(table != null){
            session.getState().debug("Overwritting the Decision Table: "+name.stringValue());
        }
        RDecisionTable dtTable = new RDecisionTable(session,name.stringValue());
View Full Code Here

    public void loadedd(IRSession session, String filename, InputStream edd) throws RulesException {
      EDDLoader loader = new EDDLoader(filename, session, this);
        try {
         GenericXMLParser.load(edd,loader);
         if(loader.succeeded==false){
             throw new RulesException("Parsing Error(s)","EDD Loader",loader.errorMsgs);
         }
        } catch(Exception e){
            throw new RulesException("Parsing Error","EDD Loader",e.toString());
        }
    }
View Full Code Here

    public void loaddt(IRSession session, InputStream dt) throws RulesException {
      DTLoader loader = new DTLoader(session, this);
      try {
        GenericXMLParser.load(dt, loader);
      }catch (Exception e) {
            throw new RulesException("Parsing Error","Decision Table Loader",e.toString());
    }
    }
View Full Code Here

     
        switch(type){
            case IRObject.iEntity : {
                if(defaultstr.length()==0)return RNull.getRNull();
                IREntity e = ef.findcreateRefEntity(false,RName.getRName(defaultstr));
                if(e==null)throw new RulesException(
                        "ParsingError",
                        "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;
            }
          case IRObject.iString :
                if(defaultstr.length()==0)return RNull.getRNull();
            return RString.newRString(defaultstr);
          case IRObject.iName :
                if(defaultstr.length()==0)return RNull.getRNull();
            return RName.getRName(defaultstr.trim(),false);
          case IRObject.iBoolean : {
                if(defaultstr.length()==0)return RNull.getRNull();
                return RBoolean.getRBoolean(defaultstr);
         
          case IRObject.iDouble : {
                if(defaultstr.length()==0)return RNull.getRNull();
            double value = Double.parseDouble(defaultstr);
            return RDouble.getRDoubleValue(value);
         
          case IRObject.iInteger : {
                if(defaultstr.length()==0)return RNull.getRNull();
            long value = Long.parseLong(defaultstr);
            return RInteger.getRIntegerValue(value);
         
            case IRObject.iTime : {
                if(defaultstr.length()==0) return RNull.getRNull();
                SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy");
                try {
                    Date date = fmt.parse(defaultstr);
                    return RTime.getRTime(date);
                } catch (ParseException e) {
                    throw new RulesException("Invalid Date Format","EntityFactory.computeDefaultValue","Only support dates in 'MM/dd/yyyy' form.");
                }
            }
            case IRObject.iTable : {
                RTable table = RTable.newRTable(ef, null, defaultstr, -1);
                if(defaultstr.length()==0) return table;
View Full Code Here

     * has to be created prior to any sessions that are going to
     * execute against the entityfactory.
     * @return uniqueID (a long)
     */
    public int getUniqueID() throws RulesException{
        if(frozen)throw new RulesException("No UniqueID","EntityFactory.getUniqueID()","Once a session has been created, you can't modify the EntityFactory");
        return uniqueID++;
       
    }
View Full Code Here

TOP

Related Classes of com.dtrules.infrastructure.RulesException

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.