Class SQLRenderer

java.lang.Object
com.invirgance.convirgance.jdbc.sql.SQLRenderer

public class SQLRenderer extends Object
Core SQL generation engine that renders SQL statements into properly formatted SQL strings. This class handles all SQL syntax details including keyword formatting, proper spacing, parentheses balancing, and identifier quoting based on database type.
Author:
jbanes
  • Constructor Details

    • SQLRenderer

      public SQLRenderer()
  • Method Details

    • isCapitalizeKeywords

      public boolean isCapitalizeKeywords()
      If SQL keywords will be capitalized.
      Returns:
      If the keywords will be capitalized.
    • setCapitalizeKeywords

      public void setCapitalizeKeywords(boolean capitalizeKeywords)
      Will change the query to use capitalized keywords.
      Parameters:
      capitalizeKeywords - True to enable.
    • isPrettyPrint

      public boolean isPrettyPrint()
      If the query will use pretty printing.
      Returns:
      True is enabled.
    • setPrettyPrint

      public void setPrettyPrint(boolean pretty)
      This will make it easier for other people to read the query. If you don't intend on other people reading the query leave this disabled to save a few bytes.
      Parameters:
      pretty - True to enable.
    • getLine

      public int getLine()
      Returns the current line count of the query.
      Returns:
      An int.
    • getCharacter

      public int getCharacter()
      Gets the current character index. Note: This will change depending on the state of pretty print.
      Returns:
      The character index.
    • capitialize

      public SQLRenderer capitialize(boolean capitalize)
      Keywords will be capitalized if this is enabled.
      Parameters:
      capitalize - True to enable.
      Returns:
      this
    • pretty

      public SQLRenderer pretty(boolean pretty)
      Enables pretty printing for this renderer.
      Parameters:
      pretty - True to enable.
      Returns:
      this
    • reset

      public SQLRenderer reset()
      Resets this object.
      Returns:
      this
    • keyword

      public SQLRenderer keyword(Keyword keyword)
      Adds a provided SQL keyword to the query.
      Parameters:
      keyword - A SQL Keyword
      Returns:
      this
    • operator

      public SQLRenderer operator(ComparisonOperator operator)
      Adds a comparison operator to the SQL query.
      Parameters:
      operator - A ComparisonOperator
      Returns:
      this
    • column

      public SQLRenderer column(Column column)
      Adds a column to the SQL query.
      Parameters:
      column - A Column
      Returns:
      this
    • order

      public SQLRenderer order(NamedSchema column, OrderBy order)
      Sets the ordering of a Column/NamedSchema.
      Parameters:
      column - A NamedSchema
      order - The ordering to use OrderBy
      Returns:
      this
    • literal

      public SQLRenderer literal(Object literal)
      Adds a literal to the query. Specific handling for Null, Number and String, otherwise the object is toString()-ed
      Parameters:
      literal - An object.
      Returns:
      this
    • schema

      public SQLRenderer schema(NamedSchema named)
      Appends a named schema element into the SQL query. This method handles proper formatting of schema identifiers, including automatically adding schema qualification (e.g., "schema.table") for TabularStructure objects.
      Parameters:
      named - The NamedSchema object to render (table, column, etc.)
      Returns:
      this
    • statement

      public SQLRenderer statement(SQLStatement statement)
      Adds a SQLStatement to the query.
      Parameters:
      statement - A SQLStatement.
      Returns:
      this
    • openParenthesis

      public SQLRenderer openParenthesis()
      Adds a left parenthesis to the query.
      Returns:
      this
    • closeParenthesis

      public SQLRenderer closeParenthesis()
      Adds a right parenthesis to the query.
      Returns:
      this
    • endStatement

      public SQLRenderer endStatement()
      Ends the current query statement.
      Returns:
      this
    • toString

      public String toString()
      Overrides:
      toString in class Object