Class SQLRenderer
java.lang.Object
com.invirgance.convirgance.jdbc.sql.SQLRenderer
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncapitialize(boolean capitalize) Keywords will be capitalized if this is enabled.Adds a right parenthesis to the query.Adds a column to the SQL query.Ends the current query statement.intGets the current character index.intgetLine()Returns the current line count of the query.booleanIf SQL keywords will be capitalized.booleanIf the query will use pretty printing.Adds a provided SQL keyword to the query.Adds a literal to the query.Adds a left parenthesis to the query.operator(ComparisonOperator operator) Adds a comparison operator to the SQL query.order(NamedSchema column, OrderBy order) Sets the ordering of a Column/NamedSchema.pretty(boolean pretty) Enables pretty printing for this renderer.reset()Resets this object.schema(NamedSchema named) Appends a named schema element into the SQL query.voidsetCapitalizeKeywords(boolean capitalizeKeywords) Will change the query to use capitalized keywords.voidsetPrettyPrint(boolean pretty) This will make it easier for other people to read the query.statement(SQLStatement statement) Adds a SQLStatement to the query.toString()
-
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
Keywords will be capitalized if this is enabled.- Parameters:
capitalize- True to enable.- Returns:
- this
-
pretty
Enables pretty printing for this renderer.- Parameters:
pretty- True to enable.- Returns:
- this
-
reset
Resets this object.- Returns:
- this
-
keyword
Adds a provided SQL keyword to the query.- Parameters:
keyword- A SQLKeyword- Returns:
- this
-
operator
Adds a comparison operator to the SQL query.- Parameters:
operator- AComparisonOperator- Returns:
- this
-
column
Adds a column to the SQL query.- Parameters:
column- AColumn- Returns:
- this
-
order
Sets the ordering of a Column/NamedSchema.- Parameters:
column- ANamedSchemaorder- The ordering to useOrderBy- Returns:
- this
-
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
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
Adds a SQLStatement to the query.- Parameters:
statement- A SQLStatement.- Returns:
- this
-
openParenthesis
Adds a left parenthesis to the query.- Returns:
- this
-
closeParenthesis
Adds a right parenthesis to the query.- Returns:
- this
-
endStatement
Ends the current query statement.- Returns:
- this
-
toString
-