001 002package gudusoft.gsqlparser.pp.para; 003 004import gudusoft.gsqlparser.pp.para.styleenums.TAlignOption; 005import gudusoft.gsqlparser.pp.para.styleenums.TAlignStyle; 006import gudusoft.gsqlparser.pp.para.styleenums.TCaseOption; 007import gudusoft.gsqlparser.pp.para.styleenums.TCompactMode; 008import gudusoft.gsqlparser.pp.para.styleenums.TEmptyLinesOption; 009import gudusoft.gsqlparser.pp.para.styleenums.TLinefeedsCommaOption; 010 011/** 012 * the format options 013 * 014 * @author zhoujun 015 */ 016public class GFmtOpt 017{ 018 019 /** 020 * the session id. each thread can own only one id. 021 */ 022 public final String sessionId; 023 024 /** 025 * if it is true, the helper class will operate the source tokens. if not, 026 * the helper class will ignore the operation request 027 */ 028 public boolean opearateSourceToken = true; 029 030 // select list, group by clause, order by Clause 031 /** 032 * the align style for the select column 033 * //todo add sample1 034 */ 035 public TAlignStyle selectColumnlistStyle = TAlignStyle.AsStacked; 036 037 /** 038 * the comma style in select statement 039 * //todo add sample2 040 */ 041 public TLinefeedsCommaOption selectColumnlistComma = TLinefeedsCommaOption.LfAfterComma; 042 043 /** 044 * each column in the select statement should append a new line. 045 * //todo add sample3 046 */ 047 public boolean selectItemInNewLine = false; 048 049 /** 050 * //todo add sample4 051 */ 052 public boolean alignAliasInSelectList = true; 053 054 /** 055 * //todo add sample5 056 */ 057 public boolean treatDistinctAsVirtualColumn = false; 058 059 // select from clause / Join clause 060 /** 061 * the table name style in the from clause 062 * //todo add sample6 063 */ 064 public TAlignStyle selectFromclauseStyle = TAlignStyle.AsStacked; 065 066 /** 067 * the comma style in the from clause 068 * //todo add sample7 069 */ 070 public TLinefeedsCommaOption selectFromclauseComma = TLinefeedsCommaOption.LfAfterComma; 071 072 /** 073 * each column in the table names in the form clause should start with a new 074 * line. 075 * //todo add sample8 076 */ 077 public boolean fromClauseInNewLine = false; 078 079 /** 080 * the join clause should start with a new line. 081 * //todo add sample9 082 */ 083 public boolean selectFromclauseJoinOnInNewline = true; 084 085 /** 086 * align 'join' keyword with 'from' keyword 087 * //todo add sample10 088 */ 089 public boolean alignJoinWithFromKeyword = false; 090 091 // And/Or keyword under where 092 /** 093 * in the where clause, the 'and' and 'or' keyword should under the 'where' 094 * keyword 095 * //todo add sample11 096 */ 097 public boolean andOrUnderWhere = false; 098 099 // Insert statement 100 101 /** 102 * the align style for the insert column 103 * //todo add sample12 104 */ 105 public TAlignStyle insertColumnlistStyle = TAlignStyle.AsStacked; 106 107 /** 108 * the value style in insert statement 109 * //todo add sample13 110 */ 111 public TAlignStyle insertValuelistStyle = TAlignStyle.AsStacked; 112 113 // create table 114 /** 115 * //todo add sample14 116 */ 117 public boolean beStyleCreatetableLeftBEOnNewline = false; 118 /** 119 * //todo add sample15 120 */ 121 public boolean beStyleCreatetableRightBEOnNewline = false; 122 /** 123 * //todo add sample16 124 */ 125 public boolean createtableListitemInNewLine = false; 126 /** 127 * //todo add sample17 128 */ 129 public TAlignOption createtableFieldlistAlignOption = TAlignOption.AloLeft; 130 131 // default options 132 /** 133 * //todo add sample18 134 */ 135 public TLinefeedsCommaOption defaultCommaOption = TLinefeedsCommaOption.LfAfterComma; 136 /** 137 * //todo add sample19 138 */ 139 public TAlignStyle defaultAligntype = TAlignStyle.AsStacked; 140 141 // Indent 142 /** 143 * //todo add sample20 144 */ 145 public Integer indentLen = 2; 146 /** 147 * //todo add sample21 148 */ 149 public Boolean useTab = false; 150 /** 151 * //todo add sample22 152 */ 153 public Integer tabSize = 2; 154 public Integer beStyleFunctionBodyIndent = 2; 155 /** 156 * //todo add sample23 157 */ 158 public Boolean beStyleBlockLeftBEOnNewline = true; 159 /** 160 * //todo add sample24 161 */ 162 public Integer beStyleBlockLeftBEIndentSize = 2; 163 /** 164 * //todo add sample25 165 */ 166 public Integer beStyleBlockRightBEIndentSize = 2; 167 /** 168 * //todo add sample26 169 */ 170 public Integer beStyleBlockIndentSize = 2; 171 /** 172 * //todo add sample27 173 */ 174 public Integer beStyleIfElseSingleStmtIndentSize = 2; 175 176 // case when 177 /** 178 * //todo add sample28 179 */ 180 public Boolean caseWhenThenInSameLine = false; 181 /** 182 * //todo add sample29 183 */ 184 public Integer indentCaseFromSwitch = 2; 185 /** 186 * //todo add sample30 187 */ 188 public Integer indentCaseThen = 0; 189 190 // keyword align option 191 /** 192 * //todo add sample31 193 */ 194 public TAlignOption selectKeywordsAlignOption = TAlignOption.AloLeft; 195 196 // case option 197 /** 198 * //todo add sample32 199 */ 200 public TCaseOption caseKeywords = TCaseOption.CoUppercase; 201 /** 202 * //todo add sample33 203 */ 204 public TCaseOption caseIdentifier = TCaseOption.CoNoChange; 205 /** 206 * //todo add sample34 207 */ 208 public TCaseOption caseQuotedIdentifier = TCaseOption.CoNoChange; 209 /** 210 * //todo add sample35 211 */ 212 public TCaseOption caseFuncname = TCaseOption.CoInitCap; 213 /** 214 * //todo add sample36 215 */ 216 public TCaseOption caseDatatype = TCaseOption.CoUppercase; 217 218 // WSPadding 219 /** 220 * //todo add sample37 221 */ 222 public Boolean wsPaddingOperatorArithmetic = true; 223 /** 224 * //todo add sample38 225 */ 226 public Boolean wsPaddingParenthesesInFunction = false; 227 /** 228 * //todo add sample39 229 */ 230 public Boolean wsPaddingParenthesesInExpression = true; 231 /** 232 * //todo add sample40 233 */ 234 public Boolean wsPaddingParenthesesOfSubQuery = false; 235 /** 236 * //todo add sample41 237 */ 238 public Boolean wsPaddingParenthesesInFunctionCall = false; 239 /** 240 * //todo add sample42 241 */ 242 public Boolean wsPaddingParenthesesOfTypename = false; 243 244 // CTE 245 /** 246 * //todo add sample43 247 */ 248 public Boolean cteNewlineBeforeAs = true; 249 250 /** 251 * declare statement 252 * //todo add sample44 253 */ 254 public Boolean linebreakAfterDeclare = false; 255 256 // create function 257 /** 258 * //todo add sample45 259 */ 260 public TAlignStyle parametersStyle = TAlignStyle.AsStacked; 261 262 /** 263 * //todo add sample46 264 */ 265 public TLinefeedsCommaOption parametersComma = TLinefeedsCommaOption.LfAfterComma; 266 267 /** 268 * //todo add sample47 269 */ 270 public Boolean beStyleFunctionLeftBEOnNewline = false; 271 272 /** 273 * //todo add sample48 274 */ 275 public Integer beStyleFunctionLeftBEIndentSize = 0; 276 277 /** 278 * //todo add sample49 279 */ 280 public Boolean beStyleFunctionRightBEOnNewline = true; 281 282 /** 283 * //todo add sample50 284 */ 285 public Integer beStyleFunctionRightBEIndentSize = 0; 286 287 /** 288 * //todo add sample51 289 */ 290 public Boolean beStyleFunctionFirstParamInNewline = false; 291 292 /** 293 * used for execute statement 294 * //todo add sample52 295 */ 296 public Boolean linebreakBeforeParamInExec = true; 297 298 // the empty lines 299 /** 300 * //todo add sample53 301 */ 302 public TEmptyLinesOption emptyLines = TEmptyLinesOption.EloMergeIntoOne; 303 /** 304 * //todo add sample54 305 */ 306 public Boolean insertBlankLineInBatchSqls = false; 307 /** 308 * //todo add sample55 309 */ 310 public Boolean noEmptyLinesBetweenMultiSetStmts = false; 311 312 // line number 313 /** 314 * //todo add sample56 315 */ 316 public Boolean linenumberEnabled = false; 317 /** 318 * //todo add sample57 319 */ 320 public Boolean linenumberZeroBased = false; 321 /** 322 * //todo add sample58 323 */ 324 public Integer linenumberLeftMargin = 0; 325 /** 326 * //todo add sample59 327 */ 328 public Integer linenumberRightMargin = 2; 329 330 /** 331 * //todo add sample60 332 */ 333 public TAlignStyle functionCallParametersStyle = TAlignStyle.AsWrapped; 334 /** 335 * //todo add sample61 336 */ 337 public TLinefeedsCommaOption functionCallParametersComma = TLinefeedsCommaOption.LfAfterComma; 338 339 /** 340 * //todo add sample62 341 */ 342 public Boolean removeComment = false; 343 344 // used for compact mode 345 /** 346 * //todo add sample63 347 */ 348 public TCompactMode compactMode = TCompactMode.CpmNone; 349 /** 350 * //todo add sample64 351 */ 352 public Integer lineWidth = 99; 353 /** 354 * //todo add issue 51 355 */ 356 public Integer maxSelectListColumn = 20; 357 358 private final static GOutputFmt defaultOutputFmt = GOutputFmt.ofSql; 359 360 /** 361 * used for sql output format. 362 * //todo add sample65 363 * @see GOutputFmt 364 */ 365 public GOutputFmt outputFmt = defaultOutputFmt; 366 367 public String tabHtmlString = " "; 368 369 public GFmtOpt( String sessionId ) 370 { 371 this.sessionId = sessionId; 372 } 373 374}