Beispiel #1
0
 public void print(PrintContext p, SPINModuleRegistry registry) {
   String name = getName();
   if (name.startsWith("?")) {
     p.print("_:");
     p.print(name.substring(1));
   } else {
     p.printVariable(name);
   }
 }
Beispiel #2
0
  public void print(PrintContext p) {

    Variable asVar = getAs();
    if (asVar != null) {
      p.print("(");
    }

    Resource aggType = getResource(RDF.type);
    String aggName = Aggregations.getName(aggType);
    p.printKeyword(aggName);
    p.print("(");

    if (isDistinct()) {
      p.print("DISTINCT ");
    }

    Statement exprS = getProperty(SP.expression);
    if (exprS != null && exprS.getObject().isResource()) {
      Resource r = exprS.getResource();
      RDFNode expr = SPINFactory.asExpression(r);
      if (expr instanceof Printable) {
        ((Printable) expr).print(p);
      } else {
        p.printURIResource(r);
      }
    } else {
      p.print("*");
    }
    String separator = getString(SP.separator);
    if (separator != null) {
      p.print("; ");
      p.printKeyword("SEPARATOR");
      p.print("='" + StrUtils.escapeString(separator) + "'");
    }
    if (asVar != null) {
      p.print(") ");
      p.printKeyword("AS");
      p.print(" ");
      p.print(asVar.toString());
    }
    p.print(")");
  }