Ejemplo n.º 1
0
  @Override
  public void meet(ValueConstant node) throws RuntimeException {
    String val = node.getValue().stringValue();

    switch (optypes.peek()) {
      case STRING:
      case URI:
        builder.append("'").append(val).append("'");
        break;
      case INT:
        builder.append(Integer.parseInt(val));
        break;
      case DECIMAL:
      case DOUBLE:
        builder.append(Double.parseDouble(val));
        break;
      case BOOL:
        builder.append(Boolean.parseBoolean(val));
        break;
      case DATE:
        builder.append("'").append(sqlDateFormat.format(DateUtils.parseDate(val))).append("'");
        break;

        // in this case we should return a node ID and also need to make sure it actually exists
      case TERM:
      case NODE:
        KiWiNode n = parent.getConverter().convert(node.getValue());
        builder.append(n.getId());
        break;

      default:
        throw new IllegalArgumentException("unsupported value type: " + optypes.peek());
    }
  }
Ejemplo n.º 2
0
  @Override
  public void meet(LangMatches lm) throws RuntimeException {
    ValueConstant pattern = (ValueConstant) lm.getRightArg();

    if (pattern.getValue().stringValue().equals("*")) {
      lm.getLeftArg().visit(this);
      builder.append(" LIKE '%'");
    } else if (pattern.getValue().stringValue().equals("")) {
      lm.getLeftArg().visit(this);
      builder.append(" IS NULL");
    } else {
      builder.append("(");
      lm.getLeftArg().visit(this);
      builder.append(" = '");
      builder.append(pattern.getValue().stringValue().toLowerCase());
      builder.append("' OR ");
      lm.getLeftArg().visit(this);
      builder.append(" LIKE '");
      builder.append(pattern.getValue().stringValue().toLowerCase());
      builder.append("-%' )");
    }
  }