private boolean isFoldable(Expr... exprs) { for (Expr e : exprs) { if (e == null || !e.isConstant()) return false; } return true; } }
protected boolean shouldInline(Expr e) { if (e == null) return false; // Inline everything when being aggressive if (this.aggressive) return true; // If not being aggressive only inline if the expression is a constant return e.isConstant() || e instanceof NodeValue; }
private boolean isFoldable(ExprList exprs) { for (Expr e : exprs) { if (e == null || !e.isConstant()) return false; } return true; }
public static boolean isConstantsOnly(Iterable<Expr> exprs) { for(Expr expr : exprs) { if(!expr.isConstant()) { return false; } } return true; }
public static boolean isConstantsOnly(Iterable<Expr> exprs) { for(Expr expr : exprs) { if(!expr.isConstant()) { return false; } } return true; }
public static boolean isConstantsOnly(Iterable<Expr> exprs) { for(Expr expr : exprs) { if(!expr.isConstant()) { return false; } } return true; }
public static boolean isConstantsOnly(Iterable<Expr> exprs) { for(Expr expr : exprs) { if(!expr.isConstant()) { return false; } } return true; }
public static Optional<String> getIriOrString(Expr expr) { //String result = expr.isConstant() ? expr.getConstant() Optional<String> result = Optional.of(expr) .map(e -> e.isConstant() ? e.getConstant() : null) .map(e -> e.asString()); return result; }
public static Optional<String> getIriOrString(Expr expr) { //String result = expr.isConstant() ? expr.getConstant() Optional<String> result = Optional.of(expr) .map(e -> e.isConstant() ? e.getConstant() : null) .map(e -> e.asString()); return result; }
public static int classify(Expr e) { int result = e.isConstant() ? 0 : e.isVariable() ? 1 : e.isFunction() ? 2 : 3; return result; }
public static E_RdfTerm expandConstant(Expr expr) { E_RdfTerm result = null; if(expr.isConstant()) { result = expandConstant(expr.getConstant().asNode()); } return result; }
public static String getString(Expr expr) { String result = null; if(expr.isConstant()) { NodeValue nv = expr.getConstant(); if(nv.isString()) { result = nv.getString(); } } return result; }
@Override public void visit(NodeValue nv) { if ( ! target.isConstant() ) throw new NoExprMatch("Not a NodeValue") ; if ( ! nv.equals(target.getConstant()) ) throw new NoExprMatch("Different value: "+nv+" & "+target.getConstant()) ; }
@Override public boolean match(Var var, Expr expr, MapResult resultMap) { if ( ! expr.isConstant() ) // throw new NoMatch("ActionMatchString: Not a variable: "+expr) ; return false ; if ( ! expr.getConstant().isString() ) return false ; String x = expr.getConstant().getString() ; // Managed to get the string - pass on up. return super.match(var, expr, resultMap) ; } }
public static RestrictionImpl deriveRestriction(Expr expr) { if(expr instanceof E_StrConcat || expr instanceof E_StrConcatPermissive) { return deriveRestriction(expr); } else if(expr.isConstant()) { RestrictionImpl result = new RestrictionImpl(); result.stateNode(expr.getConstant().asNode()); return result; } return null; }
public static RestrictionImpl deriveRestriction(Expr expr) { if(expr instanceof E_StrConcat || expr instanceof E_StrConcatPermissive) { return deriveRestriction(expr); } else if(expr.isConstant()) { RestrictionImpl result = new RestrictionImpl(); result.stateNode(expr.getConstant().asNode()); return result; } return null; }
public static RdfTermType deriveType(Expr expr) { RdfTermType result = null; if(expr.isConstant()) { result = deriveType(expr.getConstant().asNode()); } else if(expr.isFunction()) { result = deriveType(expr.getFunction()); } return result; } }
private boolean deriveRestrictionEquals(Expr a, Expr b) { if(a.isVariable() && b.isConstant()) { RestrictionImpl r = getOrCreateRestriction(a.asVar()); r.stateNode(b.getConstant().asNode()); return true; } return false; }
public static String derivePrefix(Expr expr) { String result; if(expr.isFunction()) { result = derivePrefix(expr.getFunction()); } else if(expr.isConstant()) { result = derivePrefix(expr.getConstant().getNode()); } else { result = null; } return result; }
public E_StrReplace(Expr expr1, Expr expr2, Expr expr3, Expr expr4) { super(symbol, expr1, expr2, expr3, expr4) ; if ( isString(expr2) && (expr4 == null || isString(expr4)) ) { String flags = null; if ( expr4 != null && expr4.isConstant() && expr4.getConstant().isString() ) flags = expr4.getConstant().getString(); String patternStr = expr2.getConstant().getString(); pattern = RegexJava.makePattern("REPLACE", patternStr, flags); } }