diff --git a/jOOQ/src/main/java/org/jooq/conf/ObjectFactory.java b/jOOQ/src/main/java/org/jooq/conf/ObjectFactory.java index 9d174d1c14..4f6ebf35f7 100644 --- a/jOOQ/src/main/java/org/jooq/conf/ObjectFactory.java +++ b/jOOQ/src/main/java/org/jooq/conf/ObjectFactory.java @@ -72,6 +72,14 @@ public class ObjectFactory { return new MappedTable(); } + /** + * Create an instance of {@link RenderFormatting } + * + */ + public RenderFormatting createRenderFormatting() { + return new RenderFormatting(); + } + /** * Create an instance of {@link JAXBElement }{@code <}{@link Settings }{@code >}} * diff --git a/jOOQ/src/main/java/org/jooq/conf/RenderFormatting.java b/jOOQ/src/main/java/org/jooq/conf/RenderFormatting.java new file mode 100644 index 0000000000..0a884265bc --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/conf/RenderFormatting.java @@ -0,0 +1,131 @@ + + + + + + + + +package org.jooq.conf; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * All sorts of formatting flags / settings. + * + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RenderFormatting", propOrder = { + +}) +@SuppressWarnings({ + "all" +}) +public class RenderFormatting + extends SettingsBase + implements Serializable, Cloneable +{ + + private final static long serialVersionUID = 31000L; + @XmlElement(defaultValue = "\n") + protected String newline = "\n"; + @XmlElement(defaultValue = " ") + protected String indentation = " "; + @XmlElement(defaultValue = "80") + protected Integer printMargin = 80; + + /** + * The character to be used for line breaks. + * + * @return + * possible object is + * {@link String } + * + */ + public String getNewline() { + return newline; + } + + /** + * Sets the value of the newline property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setNewline(String value) { + this.newline = value; + } + + /** + * The characters to be used for indentation. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIndentation() { + return indentation; + } + + /** + * Sets the value of the indentation property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIndentation(String value) { + this.indentation = value; + } + + /** + * The print margin after which (some) formatted elements will break lines. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getPrintMargin() { + return printMargin; + } + + /** + * Sets the value of the printMargin property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setPrintMargin(Integer value) { + this.printMargin = value; + } + + public RenderFormatting withNewline(String value) { + setNewline(value); + return this; + } + + public RenderFormatting withIndentation(String value) { + setIndentation(value); + return this; + } + + public RenderFormatting withPrintMargin(Integer value) { + setPrintMargin(value); + return this; + } + +} diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java index d10b5702cc..20a65c5459 100644 --- a/jOOQ/src/main/java/org/jooq/conf/Settings.java +++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java @@ -48,6 +48,7 @@ public class Settings protected RenderKeywordStyle renderKeywordStyle = RenderKeywordStyle.AS_IS; @XmlElement(defaultValue = "false") protected Boolean renderFormatted = false; + protected RenderFormatting renderFormatting; @XmlElement(defaultValue = "false") protected Boolean renderScalarSubqueriesForStoredFunctions = false; @XmlElement(defaultValue = "DEFAULT") @@ -254,6 +255,30 @@ public class Settings this.renderFormatted = value; } + /** + * All sorts of formatting flags / settings. + * + * @return + * possible object is + * {@link RenderFormatting } + * + */ + public RenderFormatting getRenderFormatting() { + return renderFormatting; + } + + /** + * Sets the value of the renderFormatting property. + * + * @param value + * allowed object is + * {@link RenderFormatting } + * + */ + public void setRenderFormatting(RenderFormatting value) { + this.renderFormatting = value; + } + /** * Whether stored function calls should be wrapped in scalar subqueries. *
@@ -839,6 +864,11 @@ public class Settings
return this;
}
+ public Settings withRenderFormatting(RenderFormatting value) {
+ setRenderFormatting(value);
+ return this;
+ }
+
public Settings withRenderScalarSubqueriesForStoredFunctions(Boolean value) {
setRenderScalarSubqueriesForStoredFunctions(value);
return this;
diff --git a/jOOQ/src/main/java/org/jooq/conf/SettingsTools.java b/jOOQ/src/main/java/org/jooq/conf/SettingsTools.java
index 842b9cf9e1..c70fcbd905 100644
--- a/jOOQ/src/main/java/org/jooq/conf/SettingsTools.java
+++ b/jOOQ/src/main/java/org/jooq/conf/SettingsTools.java
@@ -202,7 +202,9 @@ public final class SettingsTools {
* Clone some settings.
*/
public static final Settings clone(Settings settings) {
- return (Settings) settings.clone();
+ Settings result = (Settings) settings.clone();
+ result.renderFormatting = (RenderFormatting) result.renderFormatting.clone();
+ return result;
}
/**
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
index 62ac95c856..43aa2d590e 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
@@ -62,6 +62,7 @@ import org.jooq.QueryPart;
import org.jooq.QueryPartInternal;
import org.jooq.RenderContext;
import org.jooq.SQLDialect;
+import org.jooq.conf.RenderFormatting;
import org.jooq.conf.RenderKeywordStyle;
import org.jooq.conf.RenderNameStyle;
import org.jooq.conf.Settings;
@@ -88,7 +89,6 @@ class DefaultRenderContext extends AbstractContext