Class Query

java.lang.Object
com.jk.data.dynamic.query.Query

public class Query extends Object
This class is responsible for constructing SQL-like queries using query components.

It allows building of queries by adding various query components, such as keywords, operators, and values.

Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Details

    • Query

      public Query()
  • Method Details

    • addComponent

      public Query addComponent(QueryComponent component)
      This method adds a query component to the query structure.
      Parameters:
      component - Specifies the query component to add.
      Returns:
      the modified query instance.
    • addComponent

      public Query addComponent(QueryComponent component, int count, QueryComponent separator, boolean surroundWithParenchthisis)
      This method adds multiple copies of a query component to the query structure, separated by a specified separator, and optionally surrounded by parentheses.
      Parameters:
      component - Specifies the query component to add multiple times.
      count - Specifies the number of times to add the component.
      separator - Specifies the query component used as a separator between instances.
      surroundWithParenchthisis - Indicates whether to surround the components with parentheses.
      Returns:
      the modified query instance.
    • addComponents

      public Query addComponents(List<QueryComponent> components, QueryComponent separator, boolean surroundWithParenchthisis)
      This method adds a list of query components to the query structure, separated by a specified separator, and optionally surrounded by parentheses.
      Parameters:
      components - Specifies the list of query components to add.
      separator - Specifies the query component used as a separator between components
      surroundWithParenchthisis - Indicates whether to surround the components with parentheses.
      Returns:
      the modified query instance.
    • addValue

      public Query addValue(Object value)
      This method adds a value to the query structure as a query component.
      Parameters:
      value - Specifies the value to add.
      Returns:
      the modified query instance.
    • addValues

      public Query addValues(List<Object> values, QueryComponent separator, boolean surroundWithParenchthisis)
      This method adds a list of values to the query structure as query components, separated by a specified separator, and optionally surrounded by parentheses.
      Parameters:
      values - Specifies the list of values to add.
      separator - Specifies the query component used as a separator between values.
      surroundWithParenchthisis - Indicates whether to surround the values with parentheses.
      Returns:
      the modified query.
    • compile

      public String compile()
      This method compiles the query structure into a query string.
      Returns:
      the compiled query string.