FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
jinjava/src/main/java/com/hubspot/jinjava/JinjavaConfig.java at master · vesse/jinjava · GitHub
vesse
/
jinjava
Public
forked from
HubSpot/jinjava
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
jinjava
/
src
/
main
/
java
/
com
/
hubspot
/
jinjava
/
JinjavaConfig.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
382 lines (329 loc) · 10.6 KB
Breadcrumbs
jinjava
/
src
/
main
/
java
/
com
/
hubspot
/
jinjava
/
JinjavaConfig.java
Copy path
File metadata and controls
382 lines (329 loc) · 10.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
/**********************************************************************
* Copyright (c) 2014 HubSpot Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**********************************************************************/
package
com
.
hubspot
.
jinjava
;
import
com
.
hubspot
.
jinjava
.
el
.
JinjavaInterpreterResolver
;
import
com
.
hubspot
.
jinjava
.
interpret
.
Context
;
import
com
.
hubspot
.
jinjava
.
interpret
.
Context
.
Library
;
import
com
.
hubspot
.
jinjava
.
interpret
.
InterpreterFactory
;
import
com
.
hubspot
.
jinjava
.
interpret
.
JinjavaInterpreterFactory
;
import
com
.
hubspot
.
jinjava
.
random
.
RandomNumberGeneratorStrategy
;
import
com
.
hubspot
.
jinjava
.
tree
.
parse
.
DefaultTokenScannerSymbols
;
import
com
.
hubspot
.
jinjava
.
tree
.
parse
.
TokenScannerSymbols
;
import
java
.
nio
.
charset
.
Charset
;
import
java
.
nio
.
charset
.
StandardCharsets
;
import
java
.
time
.
ZoneId
;
import
java
.
time
.
ZoneOffset
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
Locale
;
import
java
.
util
.
Map
;
import
java
.
util
.
Set
;
import
javax
.
el
.
ELResolver
;
public
class
JinjavaConfig
{
private
final
Charset
charset
;
private
final
Locale
locale
;
private
final
ZoneId
timeZone
;
private
final
int
maxRenderDepth
;
private
final
long
maxOutputSize
;
private
final
boolean
trimBlocks
;
private
final
boolean
lstripBlocks
;
private
final
boolean
enableRecursiveMacroCalls
;
private
final
int
maxMacroRecursionDepth
;
private
Map
<
Context
.
Library
,
Set
<
String
>>
disabled
;
private
final
boolean
failOnUnknownTokens
;
private
final
boolean
nestedInterpretationEnabled
;
private
final
RandomNumberGeneratorStrategy
randomNumberGenerator
;
private
final
boolean
validationMode
;
private
final
long
maxStringLength
;
private
InterpreterFactory
interpreterFactory
;
private
TokenScannerSymbols
tokenScannerSymbols
;
private
ELResolver
elResolver
;
public
static
Builder
newBuilder
() {
return
new
Builder
();
}
public
JinjavaConfig
() {
this
(
new
JinjavaInterpreterFactory
());
}
public
JinjavaConfig
(
InterpreterFactory
interpreterFactory
) {
this
(
StandardCharsets
.
UTF_8
,
Locale
.
ENGLISH
,
ZoneOffset
.
UTC
,
10
,
new
HashMap
<>(),
false
,
false
,
false
,
0
,
false
,
0
,
true
,
RandomNumberGeneratorStrategy
.
THREAD_LOCAL
,
false
,
0
,
interpreterFactory
,
new
DefaultTokenScannerSymbols
(),
JinjavaInterpreterResolver
.
DEFAULT_RESOLVER_READ_ONLY
);
}
public
JinjavaConfig
(
Charset
charset
,
Locale
locale
,
ZoneId
timeZone
,
int
maxRenderDepth
) {
this
(
charset
,
locale
,
timeZone
,
maxRenderDepth
,
new
HashMap
<>(),
false
,
false
,
false
,
0
,
false
,
0
,
true
,
RandomNumberGeneratorStrategy
.
THREAD_LOCAL
,
false
,
0
,
new
JinjavaInterpreterFactory
(),
new
DefaultTokenScannerSymbols
(),
JinjavaInterpreterResolver
.
DEFAULT_RESOLVER_READ_ONLY
);
}
private
JinjavaConfig
(
Charset
charset
,
Locale
locale
,
ZoneId
timeZone
,
int
maxRenderDepth
,
Map
<
Context
.
Library
,
Set
<
String
>>
disabled
,
boolean
trimBlocks
,
boolean
lstripBlocks
,
boolean
enableRecursiveMacroCalls
,
int
maxMacroRecursionDepth
,
boolean
failOnUnknownTokens
,
long
maxOutputSize
,
boolean
nestedInterpretationEnabled
,
RandomNumberGeneratorStrategy
randomNumberGenerator
,
boolean
validationMode
,
long
maxStringLength
,
InterpreterFactory
interpreterFactory
,
TokenScannerSymbols
tokenScannerSymbols
,
ELResolver
elResolver
) {
this
.
charset
=
charset
;
this
.
locale
=
locale
;
this
.
timeZone
=
timeZone
;
this
.
maxRenderDepth
=
maxRenderDepth
;
this
.
disabled
=
disabled
;
this
.
trimBlocks
=
trimBlocks
;
this
.
lstripBlocks
=
lstripBlocks
;
this
.
enableRecursiveMacroCalls
=
enableRecursiveMacroCalls
;
this
.
maxMacroRecursionDepth
=
maxMacroRecursionDepth
;
this
.
failOnUnknownTokens
=
failOnUnknownTokens
;
this
.
maxOutputSize
=
maxOutputSize
;
this
.
nestedInterpretationEnabled
=
nestedInterpretationEnabled
;
this
.
randomNumberGenerator
=
randomNumberGenerator
;
this
.
validationMode
=
validationMode
;
this
.
maxStringLength
=
maxStringLength
;
this
.
interpreterFactory
=
interpreterFactory
;
this
.
tokenScannerSymbols
=
tokenScannerSymbols
;
this
.
elResolver
=
elResolver
;
}
public
Charset
getCharset
() {
return
charset
;
}
public
Locale
getLocale
() {
return
locale
;
}
public
ZoneId
getTimeZone
() {
return
timeZone
;
}
public
int
getMaxRenderDepth
() {
return
maxRenderDepth
;
}
public
long
getMaxOutputSize
() {
return
maxOutputSize
;
}
public
RandomNumberGeneratorStrategy
getRandomNumberGeneratorStrategy
() {
return
randomNumberGenerator
;
}
public
boolean
isTrimBlocks
() {
return
trimBlocks
;
}
public
boolean
isLstripBlocks
() {
return
lstripBlocks
;
}
public
boolean
isEnableRecursiveMacroCalls
() {
return
enableRecursiveMacroCalls
;
}
public
int
getMaxMacroRecursionDepth
() {
return
maxMacroRecursionDepth
;
}
public
Map
<
Library
,
Set
<
String
>>
getDisabled
() {
return
disabled
;
}
public
boolean
isFailOnUnknownTokens
() {
return
failOnUnknownTokens
;
}
public
boolean
isNestedInterpretationEnabled
() {
return
nestedInterpretationEnabled
;
}
public
boolean
isValidationMode
() {
return
validationMode
;
}
public
long
getMaxStringLength
() {
return
maxStringLength
;
}
public
InterpreterFactory
getInterpreterFactory
() {
return
interpreterFactory
;
}
public
TokenScannerSymbols
getTokenScannerSymbols
() {
return
tokenScannerSymbols
;
}
public
void
setTokenScannerSymbols
(
TokenScannerSymbols
tokenScannerSymbols
) {
this
.
tokenScannerSymbols
=
tokenScannerSymbols
;
}
public
ELResolver
getElResolver
() {
return
elResolver
;
}
public
static
class
Builder
{
private
Charset
charset
=
StandardCharsets
.
UTF_8
;
private
Locale
locale
=
Locale
.
ENGLISH
;
private
ZoneId
timeZone
=
ZoneOffset
.
UTC
;
private
int
maxRenderDepth
=
10
;
private
long
maxOutputSize
=
0
;
// in bytes
private
Map
<
Context
.
Library
,
Set
<
String
>>
disabled
=
new
HashMap
<>();
private
boolean
trimBlocks
;
private
boolean
lstripBlocks
;
private
boolean
enableRecursiveMacroCalls
;
private
int
maxMacroRecursionDepth
;
private
boolean
failOnUnknownTokens
;
private
boolean
nestedInterpretationEnabled
=
true
;
private
RandomNumberGeneratorStrategy
randomNumberGeneratorStrategy
=
RandomNumberGeneratorStrategy
.
THREAD_LOCAL
;
private
boolean
validationMode
=
false
;
private
long
maxStringLength
=
0
;
private
InterpreterFactory
interpreterFactory
=
new
JinjavaInterpreterFactory
();
private
TokenScannerSymbols
tokenScannerSymbols
=
new
DefaultTokenScannerSymbols
();
private
ELResolver
elResolver
=
JinjavaInterpreterResolver
.
DEFAULT_RESOLVER_READ_ONLY
;
private
Builder
() {}
public
Builder
withCharset
(
Charset
charset
) {
this
.
charset
=
charset
;
return
this
;
}
public
Builder
withLocale
(
Locale
locale
) {
this
.
locale
=
locale
;
return
this
;
}
public
Builder
withTimeZone
(
ZoneId
timeZone
) {
this
.
timeZone
=
timeZone
;
return
this
;
}
public
Builder
withDisabled
(
Map
<
Context
.
Library
,
Set
<
String
>>
disabled
) {
this
.
disabled
=
disabled
;
return
this
;
}
public
Builder
withMaxRenderDepth
(
int
maxRenderDepth
) {
this
.
maxRenderDepth
=
maxRenderDepth
;
return
this
;
}
public
Builder
withRandomNumberGeneratorStrategy
(
RandomNumberGeneratorStrategy
randomNumberGeneratorStrategy
) {
this
.
randomNumberGeneratorStrategy
=
randomNumberGeneratorStrategy
;
return
this
;
}
public
Builder
withTrimBlocks
(
boolean
trimBlocks
) {
this
.
trimBlocks
=
trimBlocks
;
return
this
;
}
public
Builder
withLstripBlocks
(
boolean
lstripBlocks
) {
this
.
lstripBlocks
=
lstripBlocks
;
return
this
;
}
public
Builder
withEnableRecursiveMacroCalls
(
boolean
enableRecursiveMacroCalls
) {
this
.
enableRecursiveMacroCalls
=
enableRecursiveMacroCalls
;
return
this
;
}
public
Builder
withMaxMacroRecursionDepth
(
int
maxMacroRecursionDepth
) {
this
.
maxMacroRecursionDepth
=
maxMacroRecursionDepth
;
return
this
;
}
public
Builder
withReadOnlyResolver
(
boolean
readOnlyResolver
) {
this
.
elResolver
=
readOnlyResolver
?
JinjavaInterpreterResolver
.
DEFAULT_RESOLVER_READ_ONLY
:
JinjavaInterpreterResolver
.
DEFAULT_RESOLVER_READ_WRITE
;
return
this
;
}
public
Builder
withElResolver
(
ELResolver
elResolver
) {
this
.
elResolver
=
elResolver
;
return
this
;
}
public
Builder
withFailOnUnknownTokens
(
boolean
failOnUnknownTokens
) {
this
.
failOnUnknownTokens
=
failOnUnknownTokens
;
return
this
;
}
public
Builder
withMaxOutputSize
(
long
maxOutputSize
) {
this
.
maxOutputSize
=
maxOutputSize
;
return
this
;
}
public
Builder
withNestedInterpretationEnabled
(
boolean
nestedInterpretationEnabled
) {
this
.
nestedInterpretationEnabled
=
nestedInterpretationEnabled
;
return
this
;
}
public
Builder
withValidationMode
(
boolean
validationMode
) {
this
.
validationMode
=
validationMode
;
return
this
;
}
public
Builder
withMaxStringLength
(
long
maxStringLength
) {
this
.
maxStringLength
=
maxStringLength
;
return
this
;
}
public
Builder
withInterperterFactory
(
InterpreterFactory
interperterFactory
) {
this
.
interpreterFactory
=
interperterFactory
;
return
this
;
}
public
Builder
withTokenScannerSymbols
(
TokenScannerSymbols
tokenScannerSymbols
) {
this
.
tokenScannerSymbols
=
tokenScannerSymbols
;
return
this
;
}
public
JinjavaConfig
build
() {
return
new
JinjavaConfig
(
charset
,
locale
,
timeZone
,
maxRenderDepth
,
disabled
,
trimBlocks
,
lstripBlocks
,
enableRecursiveMacroCalls
,
maxMacroRecursionDepth
,
failOnUnknownTokens
,
maxOutputSize
,
nestedInterpretationEnabled
,
randomNumberGeneratorStrategy
,
validationMode
,
maxStringLength
,
interpreterFactory
,
tokenScannerSymbols
,
elResolver
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL