/** * Create a new variable and bind it using the given object condition and value source. * @param condition The object condition. * @param name The variable name. * @param valuesource The value source. * @return The new variable. */ public Variable generateVariableBinding(ConstrainableCondition condition, String name, OAVObjectType type, Object valuesource) { Variable tmpvar = new Variable(name, type, false, true); variables.put(name, tmpvar); BoundConstraint bc = new BoundConstraint(valuesource, tmpvar); boundconstraints.put(tmpvar, bc); condition.addConstraint(bc); bcons.put(tmpvar, condition); return tmpvar; }
/** * Test for equality. * @return True, if equal. */ public boolean equals(Object obj) { return obj instanceof Variable && ((Variable)obj).getName().equals(name); // && ((Variable)obj).getType().equals(type); }
Variable cond = new Variable("?cond", OAVBDIRuntimeModel.java_externalcondition_type); Variable rplan = new Variable("?rplan", OAVBDIRuntimeModel.plan_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition condcon = new ObjectCondition(cond.getType()); condcon.addConstraint(new BoundConstraint(null, cond)); condcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.java_externalcondition_type.getAttributeType("true"), Boolean.TRUE)); ObjectCondition rplancon = new ObjectCondition(rplan.getType()); rplancon.addConstraint(new BoundConstraint(null, rplan)); ObjectCondition capcon = new ObjectCondition(rcapa.getType()); capcon.addConstraint(new BoundConstraint(null, rcapa)); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_plans, rplan, IOperator.CONTAINS));
OAVObjectType optype = ((Variable)params.get(i)).getType(); if(!(optype instanceof OAVJavaType))
/** * Add a new terminal node. * @param rule The rule. * @param context The build context. */ protected void addTerminalNode(IRule rule, BuildContext context) { // Create and connect the terminal node Map varinfos = context.getVarInfos(); Map extractors = new HashMap(); for(Iterator it=varinfos.keySet().iterator(); it.hasNext(); ) { Variable var = (Variable)it.next(); if(!var.isTemporary()) extractors.put(var.getName(), getLeftVariableExtractor(context, var)); } TerminalNode tnode = new TerminalNode(context.getRootNode().getNextNodeId(), rule, extractors); connectLeft(context.getLastBetaNode(), tnode, context); // Save the terminal node for later removal context.getRootNode().putTerminalNode(tnode); }
/** * Test if a variable is contained in the expression. * @param var The variable. * @return True, when the variable is contained. */ public boolean containsVariable(Variable var) { return var.equals(variable); }
/** * Get the string representation. * @return The string representation. */ public String toString() { //return "Variable(name="+name+")";//, type="+type+")"; //return (!isMulti()? "Variable(": "Multivariable(")+name+")"; // return (!isMulti()? "Variable(": "Multivariable(")+name+": "+type!=null? type.getName(): "null"+")"; return (!isMulti()? "Variable(": "Multivariable(")+name+")"; } }
/** * Get the hash code of this variable. */ public int hashCode() { return 31 + getVariable().hashCode(); } }
/** * Get a string representation of this variable. */ public String toString() { return getVariable().toString(); }
mfv.setType(first.getObjectType()); List consts = new ArrayList(); consts.add(new BoundConstraint(null, mfv));
/** * Rule to abort a plan when the corresponding goal was deactivated. */ public static Rule createPlanInstanceAbortRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable rplan = new Variable("?rplan", OAVBDIRuntimeModel.plan_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition goalcon = new ObjectCondition(rgoal.getType()); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_INPROCESS, IOperator.NOTEQUAL)); ObjectCondition plancon = new ObjectCondition(rplan.getType()); plancon.addConstraint(new BoundConstraint(null, rplan)); plancon.addConstraint(new OrConstraint( new LiteralConstraint(OAVBDIRuntimeModel.plan_has_lifecyclestate, OAVBDIRuntimeModel.PLANLIFECYCLESTATE_NEW), new LiteralConstraint(OAVBDIRuntimeModel.plan_has_lifecyclestate, OAVBDIRuntimeModel.PLANLIFECYCLESTATE_BODY))); plancon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.plan_has_reason, rgoal)); ObjectCondition capcon = new ObjectCondition(rcapa.getType()); capcon.addConstraint(new BoundConstraint(null, rcapa)); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_plans, rplan, IOperator.CONTAINS)); Rule abort_plan = new Rule("planinstance_abort", new AndCondition(new ICondition[]{goalcon, plancon, capcon}), PLAN_ABORT); return abort_plan; }
OAVObjectType optype = ((Variable)params.get(i)).getType(); if(!(optype instanceof OAVJavaType))
/** * Add a new terminal node. * @param rule The rule. * @param context The build context. */ protected void addTerminalNode(IRule rule, BuildContext context) { // Create and connect the terminal node Map varinfos = context.getVarInfos(); Map extractors = new HashMap(); for(Iterator it=varinfos.keySet().iterator(); it.hasNext(); ) { Variable var = (Variable)it.next(); if(!var.isTemporary()) extractors.put(var.getName(), getLeftVariableExtractor(context, var)); } TerminalNode tnode = new TerminalNode(context.getRootNode().getNextNodeId(), rule, extractors); connectLeft(context.getLastBetaNode(), tnode, context); // Save the terminal node for later removal context.getRootNode().putTerminalNode(tnode); }
/** * Test if a variable is contained in the expression. * @param var The variable. * @return True, when the variable is contained. */ public boolean containsVariable(Variable var) { return var.equals(variable); }
/** * Get the string representation. * @return The string representation. */ public String toString() { //return "Variable(name="+name+")";//, type="+type+")"; //return (!isMulti()? "Variable(": "Multivariable(")+name+")"; // return (!isMulti()? "Variable(": "Multivariable(")+name+": "+type!=null? type.getName(): "null"+")"; return (!isMulti()? "Variable(": "Multivariable(")+name+")"; } }
/** * Get the hash code of this variable. */ public int hashCode() { return 31 + getVariable().hashCode(); } }
/** * Get a string representation of this variable. */ public String toString() { return getVariable().toString(); }
mfv.setType(first.getObjectType()); List consts = new ArrayList(); consts.add(new BoundConstraint(null, mfv));
/** * Create a new variable and bind it using the given object condition and value source. * @param condition The object condition. * @param name The variable name. * @param valuesource The value source. * @return The new variable. */ public Variable generateVariableBinding(ConstrainableCondition condition, String name, OAVObjectType type, Object valuesource) { Variable tmpvar = new Variable(name, type, false, true); variables.put(name, tmpvar); BoundConstraint bc = new BoundConstraint(valuesource, tmpvar); boundconstraints.put(tmpvar, bc); condition.addConstraint(bc); bcons.put(tmpvar, condition); return tmpvar; }