001package gudusoft.gsqlparser.pp.para;
002
003import gudusoft.gsqlparser.pp.para.styleenums.TAlignOption;
004import gudusoft.gsqlparser.pp.para.styleenums.TAlignStyle;
005import gudusoft.gsqlparser.pp.para.styleenums.TCaseOption;
006import gudusoft.gsqlparser.pp.para.styleenums.TCompactMode;
007import gudusoft.gsqlparser.pp.para.styleenums.TEmptyLinesOption;
008import gudusoft.gsqlparser.pp.para.styleenums.TLinefeedsCommaOption;
009
010/**
011 * Mutable configuration for the SQL pretty-printer.
012 *
013 * <p>Create an instance with {@link GFmtOptFactory}, finish configuring it,
014 * and pass it to the formatter. Do not modify an instance while formatting is
015 * in progress. The formatter uses {@link #sessionId} to associate processors
016 * and mediators with this option set.</p>
017 *
018 * <p>Every public field is documented with its default and its interaction
019 * with related options. Fields in the "Lifecycle and advanced controls"
020 * category are public for compatibility but are not ordinary presentation
021 * settings.</p>
022 *
023 * @author zhoujun
024 */
025public class GFmtOpt
026{
027
028        /**
029         * Identifies the formatting session used by formatter, processor, and
030         * mediator caches. Use a unique id for independently configured concurrent
031         * calls; the id is not rendered in the output.
032         *
033         * <p><b>Category:</b> Lifecycle and advanced controls</p>
034         * <p><b>Default:</b> Supplied to the constructor.</p>
035         */
036        public final String sessionId;
037
038        /**
039         * Enables the low-level source-token mutation operations that implement
040         * formatting. Setting this to {@code false} makes token add/remove helpers
041         * ignore requests and therefore disables most formatting; it is intended
042         * for diagnostics, not as a preserve-layout mode.
043         *
044         * <p><b>Category:</b> Lifecycle and advanced controls</p>
045         * <p><b>Default:</b> {@code true}.</p>
046         */
047        public boolean opearateSourceToken = true;
048
049        /**
050         * Chooses stacked or wrapped layout for SELECT result columns and is also
051         * reused by GROUP BY and ORDER BY lists. Stacked layout permits line breaks
052         * according to {@link #selectColumnlistComma}; wrapped layout keeps items on
053         * the current line. Alias alignment is applied only to stacked lists.
054         *
055         * <p><b>Category:</b> SELECT list and query clauses</p>
056         * <p><b>Default:</b> {@link TAlignStyle#AsStacked}.</p>
057         */
058        public TAlignStyle selectColumnlistStyle = TAlignStyle.AsStacked;
059
060        /**
061         * Chooses whether a comma ends the previous line or begins the next line in
062         * stacked SELECT, GROUP BY, and ORDER BY lists. The setting has no line-break
063         * effect when {@link #selectColumnlistStyle} is wrapped.
064         *
065         * <p><b>Category:</b> SELECT list and query clauses</p>
066         * <p><b>Default:</b> {@link TLinefeedsCommaOption#LfAfterComma}.</p>
067         */
068        public TLinefeedsCommaOption selectColumnlistComma = TLinefeedsCommaOption.LfAfterComma;
069
070        /**
071         * Places the first SELECT item on a line after SELECT. The same switch also
072         * places the first GROUP BY and ORDER BY item, and the HAVING expression,
073         * after their clause keywords; subsequent item breaks are controlled by the
074         * list style and comma option.
075         *
076         * <p><b>Category:</b> SELECT list and query clauses</p>
077         * <p><b>Default:</b> {@code false}.</p>
078         */
079        public boolean selectItemInNewLine = false;
080
081        /**
082         * Pads stacked SELECT expressions so their explicit or implicit aliases
083         * begin in the same column. It is ignored for wrapped lists and may be
084         * skipped for exceptionally wide lists to avoid excessive padding.
085         *
086         * <p><b>Category:</b> SELECT list and query clauses</p>
087         * <p><b>Default:</b> {@code true}.</p>
088         */
089        public boolean alignAliasInSelectList = true;
090
091        /**
092         * Adds a synthetic DISTINCT result-column node to the parsed SELECT list so
093         * it participates in stacking and comma-layout calculations. This mutates
094         * the statement's result-column list for formatting, although the rendered
095         * SQL semantics are unchanged.
096         *
097         * <p><b>Category:</b> SELECT list and query clauses</p>
098         * <p><b>Default:</b> {@code false}.</p>
099         */
100        public boolean treatDistinctAsVirtualColumn = false;
101
102        /**
103         * Chooses stacked or wrapped layout for comma-separated table sources in a
104         * FROM clause. JOIN clauses have their own newline and alignment controls.
105         *
106         * <p><b>Category:</b> FROM, JOIN, and WHERE</p>
107         * <p><b>Default:</b> {@link TAlignStyle#AsStacked}.</p>
108         */
109        public TAlignStyle selectFromclauseStyle = TAlignStyle.AsStacked;
110
111        /**
112         * Positions commas for stacked comma-separated FROM items. It is effective
113         * only when {@link #selectFromclauseStyle} is stacked.
114         *
115         * <p><b>Category:</b> FROM, JOIN, and WHERE</p>
116         * <p><b>Default:</b> {@link TLinefeedsCommaOption#LfAfterComma}.</p>
117         */
118        public TLinefeedsCommaOption selectFromclauseComma = TLinefeedsCommaOption.LfAfterComma;
119
120        /**
121         * Places the first table source on a new indented line after FROM (and the
122         * corresponding INTO table source where that clause shares this processor).
123         * When false, one space separates the clause keyword and first source.
124         *
125         * <p><b>Category:</b> FROM, JOIN, and WHERE</p>
126         * <p><b>Default:</b> {@code false}.</p>
127         */
128        public boolean fromClauseInNewLine = false;
129
130        /**
131         * Places the ON condition of a JOIN on a separate line. JOIN keywords are
132         * always normalized onto their own lines by the JOIN processor; this switch
133         * controls the additional break before ON.
134         *
135         * <p><b>Category:</b> FROM, JOIN, and WHERE</p>
136         * <p><b>Default:</b> {@code true}.</p>
137         */
138        public boolean selectFromclauseJoinOnInNewline = true;
139
140        /**
141         * Aligns the beginning of JOIN phrases with the FROM keyword rather than
142         * with the first table source. It does not control whether ON starts a new
143         * line; use {@link #selectFromclauseJoinOnInNewline} for that.
144         *
145         * <p><b>Category:</b> FROM, JOIN, and WHERE</p>
146         * <p><b>Default:</b> {@code false}.</p>
147         */
148        public boolean alignJoinWithFromKeyword = false;
149
150        /**
151         * Aligns leading AND and OR operators under the WHERE keyword. When false,
152         * boolean continuations use the expression formatter's normal indentation.
153         *
154         * <p><b>Category:</b> FROM, JOIN, and WHERE</p>
155         * <p><b>Default:</b> {@code false}.</p>
156         */
157        public boolean andOrUnderWhere = false;
158
159        /**
160         * Chooses stacked or wrapped layout for the target-column list of INSERT.
161         * Comma placement comes from {@link #defaultCommaOption} rather than the
162         * SELECT-specific comma option.
163         *
164         * <p><b>Category:</b> INSERT and general lists</p>
165         * <p><b>Default:</b> {@link TAlignStyle#AsStacked}.</p>
166         */
167        public TAlignStyle insertColumnlistStyle = TAlignStyle.AsStacked;
168
169        /**
170         * Chooses stacked or wrapped layout for each INSERT VALUES list. Comma
171         * placement comes from {@link #defaultCommaOption}.
172         *
173         * <p><b>Category:</b> INSERT and general lists</p>
174         * <p><b>Default:</b> {@link TAlignStyle#AsStacked}.</p>
175         */
176        public TAlignStyle insertValuelistStyle = TAlignStyle.AsStacked;
177
178        /**
179         * Places the opening parenthesis of a CREATE TABLE column list on a new line
180         * and indents it by {@link #indentLen}. If list items are also placed on new
181         * lines, they receive one additional indentation level.
182         *
183         * <p><b>Category:</b> CREATE TABLE</p>
184         * <p><b>Default:</b> {@code false}.</p>
185         */
186        public boolean beStyleCreatetableLeftBEOnNewline = false;
187
188        /**
189         * Places the closing parenthesis of a CREATE TABLE column list on its own
190         * line. Its indentation accounts for whether the opening parenthesis was
191         * also moved to a new line.
192         *
193         * <p><b>Category:</b> CREATE TABLE</p>
194         * <p><b>Default:</b> {@code false}.</p>
195         */
196        public boolean beStyleCreatetableRightBEOnNewline = false;
197
198        /**
199         * Places the first CREATE TABLE column or constraint on a new line after the
200         * opening parenthesis. Remaining items follow {@link #defaultAligntype} and
201         * {@link #defaultCommaOption}.
202         *
203         * <p><b>Category:</b> CREATE TABLE</p>
204         * <p><b>Default:</b> {@code false}.</p>
205         */
206        public boolean createtableListitemInNewLine = false;
207
208        /**
209         * Left- or right-aligns CREATE TABLE column names within the widest column-
210         * name width. It is applied only when {@link #defaultAligntype} is stacked.
211         *
212         * <p><b>Category:</b> CREATE TABLE</p>
213         * <p><b>Default:</b> {@link TAlignOption#AloLeft}.</p>
214         */
215        public TAlignOption createtableFieldlistAlignOption = TAlignOption.AloLeft;
216
217        /**
218         * Provides comma placement for formatter lists without a dedicated comma
219         * setting, including INSERT columns/values, UPDATE SET items, and CREATE
220         * TABLE columns and constraints.
221         *
222         * <p><b>Category:</b> INSERT and general lists</p>
223         * <p><b>Default:</b> {@link TLinefeedsCommaOption#LfAfterComma}.</p>
224         */
225        public TLinefeedsCommaOption defaultCommaOption = TLinefeedsCommaOption.LfAfterComma;
226
227        /**
228         * Provides stacked or wrapped layout for lists without a dedicated style,
229         * notably UPDATE SET and CREATE TABLE lists. INSERT has separate style fields
230         * but still uses {@link #defaultCommaOption} for commas.
231         *
232         * <p><b>Category:</b> INSERT and general lists</p>
233         * <p><b>Default:</b> {@link TAlignStyle#AsStacked}.</p>
234         */
235        public TAlignStyle defaultAligntype = TAlignStyle.AsStacked;
236
237        /**
238         * Sets the general indentation increment, in columns, used by nested clauses,
239         * expressions, CTE bodies, parameters, and many statement processors. More
240         * specialized indentation options add to, rather than replace, this value.
241         *
242         * <p><b>Category:</b> Indentation and procedural blocks</p>
243         * <p><b>Default:</b> {@code 2}.</p>
244         */
245        public Integer indentLen = 2;
246
247        /**
248         * Enables the final tab-alignment pass. The formatter first computes spaces,
249         * then pads each indented line to a multiple of {@link #tabSize}; this option
250         * does not replace all indentation characters with literal tab characters.
251         *
252         * <p><b>Category:</b> Indentation and procedural blocks</p>
253         * <p><b>Default:</b> {@code false}.</p>
254         */
255        public Boolean useTab = false;
256
257        /**
258         * Defines the tab-stop width used by the final tab-alignment pass when
259         * {@link #useTab} is enabled. Use a positive value.
260         *
261         * <p><b>Category:</b> Indentation and procedural blocks</p>
262         * <p><b>Default:</b> {@code 2}.</p>
263         */
264        public Integer tabSize = 2;
265
266        /**
267         * Reserved compatibility setting for stored-routine body indentation. The
268         * active formatter currently does not read this field; use
269         * {@link #beStyleBlockIndentSize} and {@link #indentLen} for effective body
270         * indentation.
271         *
272         * <p><b>Category:</b> Indentation and procedural blocks</p>
273         * <p><b>Default:</b> {@code 2}; currently has no effect.</p>
274         */
275        public Integer beStyleFunctionBodyIndent = 2;
276
277        /**
278         * Places a procedural BEGIN token on a new line. This is used by PL/SQL-like
279         * blocks and by SQL Server BEGIN/END block formatting, with vendor-specific
280         * paths applying the related indentation settings.
281         *
282         * <p><b>Category:</b> Indentation and procedural blocks</p>
283         * <p><b>Default:</b> {@code true}.</p>
284         */
285        public Boolean beStyleBlockLeftBEOnNewline = true;
286
287        /**
288         * Adds columns to the containing statement's indentation for a BEGIN token
289         * moved to a new line. It is meaningful when
290         * {@link #beStyleBlockLeftBEOnNewline} is true.
291         *
292         * <p><b>Category:</b> Indentation and procedural blocks</p>
293         * <p><b>Default:</b> {@code 2}.</p>
294         */
295        public Integer beStyleBlockLeftBEIndentSize = 2;
296
297        /**
298         * Controls END indentation for block paths where BEGIN remains on the current
299         * line. When BEGIN is moved, those paths align END using the BEGIN indent
300         * instead, so this value may be ignored.
301         *
302         * <p><b>Category:</b> Indentation and procedural blocks</p>
303         * <p><b>Default:</b> {@code 2}.</p>
304         */
305        public Integer beStyleBlockRightBEIndentSize = 2;
306
307        /**
308         * Adds indentation to statements inside BEGIN/END blocks and to returned
309         * query bodies in supported CREATE FUNCTION and CREATE VIEW forms. It is
310         * measured relative to the enclosing block marker.
311         *
312         * <p><b>Category:</b> Indentation and procedural blocks</p>
313         * <p><b>Default:</b> {@code 2}.</p>
314         */
315        public Integer beStyleBlockIndentSize = 2;
316
317        /**
318         * Adds indentation to a single statement controlled by IF or ELSE when the
319         * body is not represented as a BEGIN/END block. Block bodies instead use the
320         * block indentation options.
321         *
322         * <p><b>Category:</b> Indentation and procedural blocks</p>
323         * <p><b>Default:</b> {@code 2}.</p>
324         */
325        public Integer beStyleIfElseSingleStmtIndentSize = 2;
326
327        /**
328         * Keeps each WHEN condition and its THEN keyword on one line when true. When
329         * false, THEN starts a new line and its indentation additionally uses
330         * {@link #indentCaseThen}.
331         *
332         * <p><b>Category:</b> CASE expressions</p>
333         * <p><b>Default:</b> {@code false}.</p>
334         */
335        public Boolean caseWhenThenInSameLine = false;
336
337        /**
338         * Indents WHEN, ELSE, and END relative to the CASE keyword. The value is an
339         * absolute number of columns added at that CASE nesting level.
340         *
341         * <p><b>Category:</b> CASE expressions</p>
342         * <p><b>Default:</b> {@code 2}.</p>
343         */
344        public Integer indentCaseFromSwitch = 2;
345
346        /**
347         * Adds indentation to a line-broken THEN relative to its WHEN indentation.
348         * It is ignored when {@link #caseWhenThenInSameLine} is true.
349         *
350         * <p><b>Category:</b> CASE expressions</p>
351         * <p><b>Default:</b> {@code 0}.</p>
352         */
353        public Integer indentCaseThen = 0;
354
355        /**
356         * Left- or right-aligns multiword and single-word query clause labels such as
357         * SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY within their shared
358         * keyword width.
359         *
360         * <p><b>Category:</b> Keyword alignment and capitalization</p>
361         * <p><b>Default:</b> {@link TAlignOption#AloLeft}.</p>
362         */
363        public TAlignOption selectKeywordsAlignOption = TAlignOption.AloLeft;
364
365        /**
366         * Converts SQL keyword tokens to the selected case. Datatypes and recognized
367         * function names use their dedicated case settings instead.
368         *
369         * <p><b>Category:</b> Keyword alignment and capitalization</p>
370         * <p><b>Default:</b> {@link TCaseOption#CoUppercase}.</p>
371         */
372        public TCaseOption caseKeywords = TCaseOption.CoUppercase;
373
374        /**
375         * Converts unquoted identifier tokens that are not recognized as datatypes
376         * or function names. Changing case can change semantics in case-sensitive
377         * databases, so preserve case unless that transformation is intentional.
378         *
379         * <p><b>Category:</b> Keyword alignment and capitalization</p>
380         * <p><b>Default:</b> {@link TCaseOption#CoNoChange}.</p>
381         */
382        public TCaseOption caseIdentifier = TCaseOption.CoNoChange;
383
384        /**
385         * Converts double-quoted identifier contents while preserving the quote
386         * characters. Quoted identifiers are frequently case-sensitive; use any
387         * value other than no-change with care.
388         *
389         * <p><b>Category:</b> Keyword alignment and capitalization</p>
390         * <p><b>Default:</b> {@link TCaseOption#CoNoChange}.</p>
391         */
392        public TCaseOption caseQuotedIdentifier = TCaseOption.CoNoChange;
393
394        /**
395         * Converts tokens recognized by the parser as function names, including
396         * built-in and user-defined calls where classification is available.
397         *
398         * <p><b>Category:</b> Keyword alignment and capitalization</p>
399         * <p><b>Default:</b> {@link TCaseOption#CoInitCap}.</p>
400         */
401        public TCaseOption caseFuncname = TCaseOption.CoInitCap;
402
403        /**
404         * Converts tokens recognized as datatype names. This classification takes
405         * precedence over the general keyword and identifier case settings.
406         *
407         * <p><b>Category:</b> Keyword alignment and capitalization</p>
408         * <p><b>Default:</b> {@link TCaseOption#CoUppercase}.</p>
409         */
410        public TCaseOption caseDatatype = TCaseOption.CoUppercase;
411
412        /**
413         * Inserts one space on both sides of recognized binary arithmetic and
414         * comparison operators. Unary plus and minus are kept adjacent to their
415         * operand regardless of this setting.
416         *
417         * <p><b>Category:</b> Whitespace and parentheses</p>
418         * <p><b>Default:</b> {@code true}.</p>
419         */
420        public Boolean wsPaddingOperatorArithmetic = true;
421
422        /**
423         * Inserts one space just inside the parameter-list parentheses of CREATE
424         * FUNCTION, PROCEDURE, PACKAGE, and TRIGGER declarations when parameters are
425         * present. It does not affect ordinary function calls.
426         *
427         * <p><b>Category:</b> Whitespace and parentheses</p>
428         * <p><b>Default:</b> {@code false}.</p>
429         */
430        public Boolean wsPaddingParenthesesInFunction = false;
431
432        /**
433         * Inserts one space just inside parentheses that group an expression, for
434         * example {@code ( a + b )}. Subqueries, function calls, and datatype
435         * parameters use separate options.
436         *
437         * <p><b>Category:</b> Whitespace and parentheses</p>
438         * <p><b>Default:</b> {@code true}.</p>
439         */
440        public Boolean wsPaddingParenthesesInExpression = true;
441
442        /**
443         * Inserts one space just inside parentheses that enclose a formatted
444         * subquery. Internal subquery line breaks and indentation are still produced
445         * by the nested statement formatter.
446         *
447         * <p><b>Category:</b> Whitespace and parentheses</p>
448         * <p><b>Default:</b> {@code false}.</p>
449         */
450        public Boolean wsPaddingParenthesesOfSubQuery = false;
451
452        /**
453         * Inserts one space just inside ordinary function-call parentheses. Stored-
454         * routine declaration parentheses use
455         * {@link #wsPaddingParenthesesInFunction} instead.
456         *
457         * <p><b>Category:</b> Whitespace and parentheses</p>
458         * <p><b>Default:</b> {@code false}.</p>
459         */
460        public Boolean wsPaddingParenthesesInFunctionCall = false;
461
462        /**
463         * Inserts one space just inside datatype-parameter parentheses, for example
464         * {@code VARCHAR( 20 )}. It applies only when the parser classifies the node
465         * as a type name.
466         *
467         * <p><b>Category:</b> Whitespace and parentheses</p>
468         * <p><b>Default:</b> {@code false}.</p>
469         */
470        public Boolean wsPaddingParenthesesOfTypename = false;
471
472        /**
473         * Places the AS keyword of each common table expression on a new line aligned
474         * under the CTE name area. When false, AS follows the CTE header after one
475         * space; the CTE query itself is formatted in both cases.
476         *
477         * <p><b>Category:</b> CTEs and declarations</p>
478         * <p><b>Default:</b> {@code true}.</p>
479         */
480        public Boolean cteNewlineBeforeAs = true;
481
482        /**
483         * Places the first variable declaration on a new indented line after DECLARE.
484         * Later declaration items are always stacked by the DECLARE formatter.
485         *
486         * <p><b>Category:</b> CTEs and declarations</p>
487         * <p><b>Default:</b> {@code false}.</p>
488         */
489        public Boolean linebreakAfterDeclare = false;
490
491        /**
492         * Chooses stacked or wrapped layout for stored-routine, package, trigger, and
493         * supported CREATE VIEW parameter declarations. Stacked parameters also have
494         * their names/types aligned by the parameter formatter.
495         *
496         * <p><b>Category:</b> Routine declarations and EXEC</p>
497         * <p><b>Default:</b> {@link TAlignStyle#AsStacked}.</p>
498         */
499        public TAlignStyle parametersStyle = TAlignStyle.AsStacked;
500
501        /**
502         * Positions commas for stacked stored-routine parameter declarations. It is
503         * effective when {@link #parametersStyle} is stacked.
504         *
505         * <p><b>Category:</b> Routine declarations and EXEC</p>
506         * <p><b>Default:</b> {@link TLinefeedsCommaOption#LfAfterComma}.</p>
507         */
508        public TLinefeedsCommaOption parametersComma = TLinefeedsCommaOption.LfAfterComma;
509
510        /**
511         * Places the opening parenthesis of a stored-routine parameter list on a new
512         * line. The setting applies only when a parameter declaration list exists.
513         *
514         * <p><b>Category:</b> Routine declarations and EXEC</p>
515         * <p><b>Default:</b> {@code false}.</p>
516         */
517        public Boolean beStyleFunctionLeftBEOnNewline = false;
518
519        /**
520         * Adds columns to the current indentation of a stored-routine opening
521         * parenthesis moved to a new line. It is ignored unless
522         * {@link #beStyleFunctionLeftBEOnNewline} is true.
523         *
524         * <p><b>Category:</b> Routine declarations and EXEC</p>
525         * <p><b>Default:</b> {@code 0}.</p>
526         */
527        public Integer beStyleFunctionLeftBEIndentSize = 0;
528
529        /**
530         * Places the closing parenthesis of a stored-routine parameter list on a new
531         * line. The setting applies only when a parameter declaration list exists.
532         *
533         * <p><b>Category:</b> Routine declarations and EXEC</p>
534         * <p><b>Default:</b> {@code true}.</p>
535         */
536        public Boolean beStyleFunctionRightBEOnNewline = true;
537
538        /**
539         * Adds columns relative to the routine declaration when a parameter-list
540         * closing parenthesis is moved to a new line. It is ignored unless
541         * {@link #beStyleFunctionRightBEOnNewline} is true.
542         *
543         * <p><b>Category:</b> Routine declarations and EXEC</p>
544         * <p><b>Default:</b> {@code 0}.</p>
545         */
546        public Integer beStyleFunctionRightBEIndentSize = 0;
547
548        /**
549         * Places the first stored-routine parameter on a new line and indents it one
550         * general indentation level beyond its current parameter-list indentation.
551         * Subsequent parameters follow the parameter style and comma settings.
552         *
553         * <p><b>Category:</b> Routine declarations and EXEC</p>
554         * <p><b>Default:</b> {@code false}.</p>
555         */
556        public Boolean beStyleFunctionFirstParamInNewline = false;
557
558        /**
559         * Places the first SQL Server EXEC/EXECUTE argument on a new line, indented by
560         * {@link #indentLen} from the statement. It does not control stored-routine
561         * declaration parameters.
562         *
563         * <p><b>Category:</b> Routine declarations and EXEC</p>
564         * <p><b>Default:</b> {@code true}.</p>
565         */
566        public Boolean linebreakBeforeParamInExec = true;
567
568        /**
569         * Determines how blank lines found between top-level statements are handled:
570         * remove them, collapse them to one blank line, or preserve their count.
571         * Statement-separating newlines themselves are always retained.
572         *
573         * <p><b>Category:</b> Blank lines and batches</p>
574         * <p><b>Default:</b> {@link TEmptyLinesOption#EloMergeIntoOne}.</p>
575         */
576        public TEmptyLinesOption emptyLines = TEmptyLinesOption.EloMergeIntoOne;
577
578        /**
579         * Inserts a blank line between statements inside supported BEGIN/END batches.
580         * It is applied in addition to the general {@link #emptyLines} policy.
581         *
582         * <p><b>Category:</b> Blank lines and batches</p>
583         * <p><b>Default:</b> {@code false}.</p>
584         */
585        public Boolean insertBlankLineInBatchSqls = false;
586
587        /**
588         * Suppresses the formatter's otherwise automatic blank line between adjacent
589         * SET or DECLARE-family statements. It does not remove ordinary separator
590         * newlines and does not override unrelated batch blank-line insertion.
591         *
592         * <p><b>Category:</b> Blank lines and batches</p>
593         * <p><b>Default:</b> {@code false}.</p>
594         */
595        public Boolean noEmptyLinesBetweenMultiSetStmts = false;
596
597        /**
598         * Prefixes every output line with a zero-padded line number. Width is based on
599         * the total formatted line count; margins are controlled by the line-number
600         * margin settings.
601         *
602         * <p><b>Category:</b> Line numbers</p>
603         * <p><b>Default:</b> {@code false}.</p>
604         */
605        public Boolean linenumberEnabled = false;
606
607        /**
608         * Starts generated line numbers at zero when true, or one when false. It has
609         * no effect unless {@link #linenumberEnabled} is enabled.
610         *
611         * <p><b>Category:</b> Line numbers</p>
612         * <p><b>Default:</b> {@code false} (one-based numbering).</p>
613         */
614        public Boolean linenumberZeroBased = false;
615
616        /**
617         * Inserts this many spaces before each generated line number. It has no
618         * effect unless {@link #linenumberEnabled} is enabled.
619         *
620         * <p><b>Category:</b> Line numbers</p>
621         * <p><b>Default:</b> {@code 0}.</p>
622         */
623        public Integer linenumberLeftMargin = 0;
624
625        /**
626         * Inserts this many spaces between each generated line number and the SQL
627         * text. It has no effect unless {@link #linenumberEnabled} is enabled.
628         *
629         * <p><b>Category:</b> Line numbers</p>
630         * <p><b>Default:</b> {@code 2}.</p>
631         */
632        public Integer linenumberRightMargin = 2;
633
634        /**
635         * Chooses stacked or wrapped layout for argument lists in ordinary function
636         * calls. This is independent from the stored-routine declaration parameter
637         * style.
638         *
639         * <p><b>Category:</b> Function calls</p>
640         * <p><b>Default:</b> {@link TAlignStyle#AsWrapped}.</p>
641         */
642        public TAlignStyle functionCallParametersStyle = TAlignStyle.AsWrapped;
643
644        /**
645         * Positions commas when ordinary function-call arguments use stacked layout.
646         * It has no line-break effect while
647         * {@link #functionCallParametersStyle} is wrapped.
648         *
649         * <p><b>Category:</b> Function calls</p>
650         * <p><b>Default:</b> {@link TLinefeedsCommaOption#LfAfterComma}.</p>
651         */
652        public TLinefeedsCommaOption functionCallParametersComma = TLinefeedsCommaOption.LfAfterComma;
653
654        /**
655         * Removes ordinary line and block comments before formatting and reparses the
656         * modified token stream. Oracle optimizer hints beginning with {@code /*+}
657         * are preserved. Because removal mutates the parser's token list, use a fresh
658         * parser if the original comments are needed later.
659         *
660         * <p><b>Category:</b> Comments, compact mode, and wrapping</p>
661         * <p><b>Default:</b> {@code false}.</p>
662         */
663        public Boolean removeComment = false;
664
665        /**
666         * Selects normal pretty-printing or compact output. {@code Cpmugly}
667         * short-circuits statement-specific layout, normalizes the token stream, and
668         * wraps only when {@link #lineWidth} is exceeded; most other layout options
669         * are therefore ignored.
670         *
671         * <p><b>Category:</b> Comments, compact mode, and wrapping</p>
672         * <p><b>Default:</b> {@link TCompactMode#CpmNone}.</p>
673         */
674        public TCompactMode compactMode = TCompactMode.CpmNone;
675
676        /**
677         * Sets the maximum line width used by compact mode. It is a soft limit:
678         * indivisible tokens longer than the value can still exceed it. The active
679         * normal pretty-printing pipeline does not currently use this field.
680         *
681         * <p><b>Category:</b> Comments, compact mode, and wrapping</p>
682         * <p><b>Default:</b> {@code 99}.</p>
683         */
684        public Integer lineWidth = 99;
685
686        /**
687         * Limits how many items are stacked at once in large SELECT-style lists. When
688         * a list exceeds the threshold, the comma processor packs several items per
689         * line up to {@link #lineWidth} (a comment ends the line, and an item that
690         * spans lines gets a line of its own) and alias alignment is skipped; use
691         * {@link Integer#MAX_VALUE} to disable the threshold.
692         *
693         * <p><b>Category:</b> Comments, compact mode, and wrapping</p>
694         * <p><b>Default:</b> {@code 20}. This option is available only in GSP Java.</p>
695         */
696        public Integer maxSelectListColumn = 20;
697
698        private final static GOutputFmt defaultOutputFmt = GOutputFmt.ofSql;
699
700        /**
701         * Selects the renderer used after token formatting. The active formatter
702         * supports {@link GOutputFmt#ofSql} and {@link GOutputFmt#ofhtml};
703         * {@link GOutputFmt#ofUnknown} falls back to SQL, while the other legacy enum
704         * values currently throw {@link UnsupportedOperationException}. After HTML
705         * output initializes the static renderer, later {@code FormatterFactory.pp}
706         * calls reuse it until {@code FormatterFactory.setOutputConfig(null)} is
707         * called.
708         *
709         * <p><b>Category:</b> Output rendering</p>
710         * <p><b>Default:</b> {@link GOutputFmt#ofSql}.</p>
711         *
712         * @see GOutputFmt
713         */
714        public GOutputFmt outputFmt = defaultOutputFmt;
715
716        /**
717         * Replaces each literal tab in HTML output with this string. It is used only
718         * by the Java HTML renderer ({@code outputFmt == ofhtml}) and is independent
719         * of the tab-stop calculation controlled by {@link #useTab} and
720         * {@link #tabSize}.
721         *
722         * <p><b>Category:</b> Output rendering</p>
723         * <p><b>Default:</b> {@code "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"}.</p>
724         */
725        public String tabHtmlString = "&nbsp;&nbsp;&nbsp;&nbsp;";
726
727        /**
728         * Creates an option set for the supplied formatting-session id.
729         *
730         * @param sessionId cache key shared by components in one formatting call
731         */
732        public GFmtOpt( String sessionId )
733        {
734                this.sessionId = sessionId;
735        }
736
737}