Package com.github.eikecochu.sqlbuilder
Class QueryOptions
- java.lang.Object
-
- com.github.eikecochu.sqlbuilder.QueryOptions
-
public class QueryOptions extends java.lang.ObjectThe QueryOptions class holds all options that are applied at various places throughout the building process of a query.
-
-
Field Summary
Fields Modifier and Type Field Description static intFETCH_ALLThe default value of the fetchSize variable.
-
Constructor Summary
Constructors Constructor Description QueryOptions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringcased(java.lang.String string)Turns a string uppercase if enabled, else lowercaseQueryOptionscopy()Copies this instance including values and returns the new instanceQueryOptionsfetchAll()Fetch all columns on queryQueryOptionsfetchFirst()Fetch the first row only on querystatic QueryOptionsgetDefaultOptions()Returns the default optionsQueryOptionsindent()Increases the indent level by 1java.lang.StringindentString()Creates an indent string based on the indent size and leveljava.lang.StringnewLine()Creates a newline if required, when pretty printing is enabledjava.lang.StringnewLine(boolean noSpace)Creates a newline or space, if enabledjava.lang.StringpadCased(java.lang.String keyword)Combines the methods padded and casedjava.lang.Stringpadded(java.lang.String keyword)Pads a string to a specified length, if enabledjava.lang.StringpreparedValuesString()Returns all contained prepared values as a simple, concatenated stringstatic voidsetDefaultOptions(QueryOptions options)Sets the default optionsjava.lang.Stringticked(java.lang.String string)Wraps a keyword in ticks or quotes, if enabledQueryOptionsunindent()Decreases the indent level by 1
-
-
-
Method Detail
-
indentString
public java.lang.String indentString()
Creates an indent string based on the indent size and level- Returns:
- The indent string
-
newLine
public java.lang.String newLine()
Creates a newline if required, when pretty printing is enabled- Returns:
- The newline or space
-
newLine
public java.lang.String newLine(boolean noSpace)
Creates a newline or space, if enabled- Parameters:
noSpace- If true, returns an empty string if no newline should be created, else creates a string- Returns:
- The newline, space or empty string
-
padCased
public java.lang.String padCased(java.lang.String keyword)
Combines the methods padded and cased- Parameters:
keyword- The keyword- Returns:
- The padded and cased keyword
-
ticked
public java.lang.String ticked(java.lang.String string)
Wraps a keyword in ticks or quotes, if enabled- Parameters:
string- The string- Returns:
- The ticked or quoted string
-
padded
public java.lang.String padded(java.lang.String keyword)
Pads a string to a specified length, if enabled- Parameters:
keyword- The keyword- Returns:
- The padded keyword
-
cased
public java.lang.String cased(java.lang.String string)
Turns a string uppercase if enabled, else lowercase- Parameters:
string- The string- Returns:
- Uppercase string if enabled, else lowercase
-
indent
public QueryOptions indent()
Increases the indent level by 1- Returns:
- This instnace
-
unindent
public QueryOptions unindent()
Decreases the indent level by 1- Returns:
- This instance
-
copy
public QueryOptions copy()
Copies this instance including values and returns the new instance- Returns:
- The copied instance
-
preparedValuesString
public java.lang.String preparedValuesString()
Returns all contained prepared values as a simple, concatenated string- Returns:
- The prepared values of this instance
-
fetchAll
public QueryOptions fetchAll()
Fetch all columns on query- Returns:
- This QueryOptions instance
-
fetchFirst
public QueryOptions fetchFirst()
Fetch the first row only on query- Returns:
- This QueryOptions instance
-
getDefaultOptions
public static QueryOptions getDefaultOptions()
Returns the default options- Returns:
- The default options
-
setDefaultOptions
public static void setDefaultOptions(QueryOptions options)
Sets the default options- Parameters:
options- The new default options
-
-