コード例 #1
0
ファイル: Equality.java プロジェクト: semantalytics/luposdate
 @Override
 public boolean equals(Object obj) {
   if (obj != null && obj instanceof Equality) {
     final Equality eq = (Equality) obj;
     return leftExpr.equals(eq.leftExpr) && rightExpr.equals(eq.rightExpr);
   } else return false;
 }
コード例 #2
0
ファイル: Equality.java プロジェクト: semantalytics/luposdate
 public boolean isBound(RuleVariable var, Collection<RuleVariable> boundVars) {
   if (leftExpr.equals(var) && !boundVars.contains(var)) {
     if (rightExpr instanceof RuleVariable) if (!boundVars.contains(rightExpr)) return false;
     boundVars.add(var);
     return true;
   }
   if (rightExpr.equals(var) && !boundVars.contains(var)) {
     if (leftExpr instanceof RuleVariable) if (!boundVars.contains(leftExpr)) return false;
     boundVars.add(var);
     return true;
   }
   // TODO:Testen ob ?var = External() muster vorhanden ist, ?x gebunden
   // ist und External die gesuchte Variable enth�lt, die restlichen aber
   // gebunden sind, dann gebunden.
   if (leftExpr instanceof RuleVariable
       && boundVars.contains(leftExpr)
       && rightExpr instanceof External) {
     Set<RuleVariable> extVars = rightExpr.getVariables();
     boolean found = false;
     boolean bound = true;
     for (final RuleVariable ruleVar : extVars)
       if (ruleVar.equals(var)) found = true;
       else if (!boundVars.contains(ruleVar)) bound = false;
     if (found && bound && rightExpr.isBound(var, boundVars)) {
       return true;
     }
   }
   if (rightExpr instanceof RuleVariable
       && boundVars.contains(rightExpr)
       && leftExpr instanceof External) {
     Set<RuleVariable> extVars = leftExpr.getVariables();
     boolean found = false;
     boolean bound = true;
     for (final RuleVariable ruleVar : extVars)
       if (ruleVar.equals(var)) found = true;
       else if (!boundVars.contains(ruleVar)) bound = false;
     if (found && bound && leftExpr.isBound(var, boundVars)) {
       return true;
     }
   }
   return false;
 }