@Override
  public String toString() {
    String distanceSTR = ((this.distance == -1) ? ("") : (" distance='" + this.distance) + "'");

    if (getChildren() == null || getChildren().size() == 0)
      return "<proximity field='"
          + this.field
          + "' inorder='"
          + this.inorder
          + "' type='"
          + this.proximityType.toString()
          + "'"
          + distanceSTR
          + "/>";
    StringBuilder sb = new StringBuilder();
    sb.append(
        "<proximity field='"
            + this.field
            + "' inorder='"
            + this.inorder
            + "' type='"
            + this.proximityType.toString()
            + "'"
            + distanceSTR
            + ">");
    for (QueryNode child : getChildren()) {
      sb.append("\n");
      sb.append(child.toString());
    }
    sb.append("\n</proximity>");
    return sb.toString();
  }
示例#2
0
  protected void initHttpClient() {
    try {
      HttpClientBuilder builder = HttpClient.uri(url);

      // set method, default to GET
      builder = builder.method(null == method ? HttpMethod.GET : method);

      // set credentials
      if (null != credentials && credentials.isValid()) {
        builder = builder.credentials(credentials.getUsername(), credentials.getPassword());
      }

      // set keystore
      if (null != keystore && keystore.isValid()) {
        builder = builder.keyStore(new FileInputStream(keystore.getFile()), keystore.getPassword());
      }

      // set headers
      if (null != headers && headers.isValid()) {
        for (final HeaderNode header : headers.getHeaders()) {
          builder = builder.header(header.getName(), header.getValue());
        }
      }

      // set query parameters
      if (null != query && query.isValid()) {
        for (final QueryParameterNode qp : query.getParameters()) {
          builder = builder.query(qp.getName(), qp.getValue());
        }
      }

      // set request entity
      if (null != entity && entity.isValid()) {
        // prefer file
        if (null != entity.getFile()) {
          final FileInputStream is = new FileInputStream(entity.getFile());
          final ByteArrayOutputStream os = new ByteArrayOutputStream();
          final byte[] buf = new byte[1024];
          try {
            for (int num; (num = is.read(buf)) != -1; ) {
              os.write(buf, 0, num);
            }
          } catch (final IOException e) {
            throw new BuildException(e);
          }

          builder = builder.entity(new ByteArrayInputStream(os.toByteArray()));
        } else {
          builder = builder.entity(entity.getText());
        }
      }

      httpClient = builder.toHttpClient();

    } catch (final Throwable t) {
      throw new BuildException(t);
    }
  }
示例#3
0
 @Override
 public int hashCode() {
   int result = 0;
   for (QueryNode query : queryNodes) {
     result += (query == null) ? 0 : query.hashCode();
   }
   result = result ^ super.hashCode();
   return result;
 }
示例#4
0
 public Object newDeleteStatement(int line, int column, Object delete, Object where) {
   QueryNode queryNode = (QueryNode) delete;
   EJBQLParseTree tree = new EJBQLParseTree();
   queryNode.setParseTree(tree);
   tree.setContext(context);
   tree.setQueryNode(queryNode);
   tree.setWhereNode((WhereNode) where);
   return tree;
 }
示例#5
0
 @Override
 public Set<TermQuery> getPositiveTerms() {
   Set<TermQuery> l = null;
   for (QueryNode query : queryNodes) {
     Set<TermQuery> r = query.getPositiveTerms();
     if (l == null) {
       l = r;
     } else {
       l.addAll(r);
     }
   }
   return l;
 }
示例#6
0
 /**
  * ********************************************************************* Executes the SQL insert
  * statement contained within the <code>InsertNode</code> that calls it.
  *
  * @return a <code>null</code> if the insert is successful.
  */
 public ResultNode execute() {
   Connection con = new Connection();
   con.executeInsert(this);
   con.close();
   /* Query the DB for the primary key of what was just inserted */
   QueryNode query = new QueryNode();
   query.addNode("SELECT", "*");
   query.addNode("FROM", this.getTable());
   Iterator<Map.Entry<String, String>> iter = this.getPairs().entrySet().iterator();
   while (iter.hasNext()) {
     Map.Entry<String, String> entry = iter.next();
     query.addNode("WHERE", entry.getKey() + "='" + entry.getValue() + "'");
   }
   return query.execute();
 }
示例#7
0
 public Object newSelectStatement(
     int line,
     int column,
     Object select,
     Object from,
     Object where,
     Object groupBy,
     Object having,
     Object orderBy) {
   QueryNode queryNode = (QueryNode) select;
   EJBQLParseTree tree = new EJBQLParseTree();
   queryNode.setParseTree(tree);
   tree.setContext(context);
   tree.setQueryNode(queryNode);
   tree.setFromNode((FromNode) from);
   tree.setWhereNode((WhereNode) where);
   tree.setGroupByNode((GroupByNode) groupBy);
   tree.setHavingNode((HavingNode) having);
   tree.setOrderByNode((OrderByNode) orderBy);
   return tree;
 }
示例#8
0
 public Object newSubquery(
     int line,
     int column,
     Object select,
     Object from,
     Object where,
     Object groupBy,
     Object having) {
   QueryNode queryNode = (QueryNode) select;
   EJBQLParseTree tree = new EJBQLParseTree();
   queryNode.setParseTree(tree);
   tree.setQueryNode(queryNode);
   tree.setFromNode((FromNode) from);
   tree.setWhereNode((WhereNode) where);
   tree.setGroupByNode((GroupByNode) groupBy);
   tree.setHavingNode((HavingNode) having);
   tree.setContext(context);
   SubqueryNode node = new SubqueryNode();
   node.setParseTree(tree);
   setPosition(node, line, column);
   return node;
 }
  @Override
  public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) {
    String withinSTR =
        this.proximityType.toQueryString()
            + ((this.distance == -1) ? ("") : (" " + this.distance))
            + ((this.inorder) ? (" INORDER") : (""));

    StringBuilder sb = new StringBuilder();
    if (getChildren() == null || getChildren().size() == 0) {
      // no children case
    } else {
      String filler = "";
      for (QueryNode child : getChildren()) {
        sb.append(filler).append(child.toQueryString(escapeSyntaxParser));
        filler = " ";
      }
    }

    if (isDefaultField(this.field)) {
      return "( " + sb.toString() + " ) " + withinSTR;
    } else {
      return this.field + ":(( " + sb.toString() + " ) " + withinSTR + ")";
    }
  }
 @Override
 public QueryNode visit(FunctionCallNode leftNode) {
   return mRightNode.accept(new FunctionCallNodeMerger(leftNode));
 }
 @Override
 public QueryNode visit(BinaryOperatorNode leftNode) {
   return mRightNode.accept(new BinaryOperatorNodeMerger(leftNode));
 }
 @Override
 public QueryNode visit(FieldNode leftNode) {
   return mRightNode.accept(new FieldNodeMerger(leftNode));
 }
 @Override
 public QueryNode visit(ConstantNode leftNode) {
   return mRightNode.accept(new ConstantNodeMerger(leftNode));
 }