1
1
package com .fasterxml .jackson .core .io ;
2
2
3
+ import com .fasterxml .jackson .core .ErrorReportConfiguration ;
4
+
3
5
import java .io .File ;
4
6
import java .io .IOException ;
5
7
import java .io .ObjectInputStream ;
@@ -52,7 +54,9 @@ public class ContentReference
52
54
* logs.
53
55
*
54
56
* @since 2.9
57
+ * @deprecated Since 2.16. {@link ErrorReportConfiguration.Builder#maxRawContentLength(int)} will be used instead.
55
58
*/
59
+ @ Deprecated
56
60
public static final int DEFAULT_MAX_CONTENT_SNIPPET = 500 ;
57
61
58
62
/**
@@ -81,23 +85,56 @@ public class ContentReference
81
85
*/
82
86
protected final boolean _isContentTextual ;
83
87
88
+ /**
89
+ * max raw content to return as configured
90
+ *
91
+ * @since 2.16
92
+ */
93
+ protected final int _maxRawContentLength ;
94
+
84
95
/*
85
96
/**********************************************************************
86
97
/* Life-cycle
87
98
/**********************************************************************
88
99
*/
89
100
101
+ /**
102
+ * @deprecated Since 2.16. Use {@link #ContentReference(boolean, Object, ErrorReportConfiguration)} instead.
103
+ */
104
+ @ Deprecated
90
105
protected ContentReference (boolean isContentTextual , Object rawContent ) {
91
- this (isContentTextual , rawContent , -1 , -1 );
106
+ this (isContentTextual , rawContent , -1 , -1 , ErrorReportConfiguration . defaults () );
92
107
}
93
108
109
+ /**
110
+ * @deprecated Since 2.16. Use {@link #ContentReference(boolean, Object, int, int, ErrorReportConfiguration)} instead.
111
+ */
112
+ @ Deprecated
94
113
protected ContentReference (boolean isContentTextual , Object rawContent ,
95
114
int offset , int length )
115
+ {
116
+ this (isContentTextual , rawContent , offset , length , ErrorReportConfiguration .defaults ());
117
+ }
118
+
119
+ /**
120
+ * @since 2.16
121
+ */
122
+ protected ContentReference (boolean isContentTextual , Object rawContent , ErrorReportConfiguration errorReportConfiguration )
123
+ {
124
+ this (isContentTextual , rawContent , -1 , -1 , errorReportConfiguration );
125
+ }
126
+
127
+ /**
128
+ * @since 2.16
129
+ */
130
+ protected ContentReference (boolean isContentTextual , Object rawContent ,
131
+ int offset , int length , ErrorReportConfiguration errorReportConfiguration )
96
132
{
97
133
_isContentTextual = isContentTextual ;
98
134
_rawContent = rawContent ;
99
135
_offset = offset ;
100
136
_length = length ;
137
+ _maxRawContentLength = errorReportConfiguration .getMaxRawContentLength ();
101
138
}
102
139
103
140
/**
@@ -124,14 +161,41 @@ public static ContentReference unknown() {
124
161
public static ContentReference redacted () {
125
162
return REDACTED_CONTENT ;
126
163
}
127
-
164
+
165
+
166
+ /**
167
+ * @deprecated Since 2.16. Use {@link #construct(boolean, Object, ErrorReportConfiguration)} instead.
168
+ */
169
+ @ Deprecated
128
170
public static ContentReference construct (boolean isContentTextual , Object rawContent ) {
129
- return new ContentReference (isContentTextual , rawContent );
171
+ return new ContentReference (isContentTextual , rawContent , ErrorReportConfiguration . defaults () );
130
172
}
131
173
174
+ /**
175
+ * @deprecated Since 2.16. Use {@link #construct(boolean, Object, int, int, ErrorReportConfiguration)} instead.
176
+ */
177
+ @ Deprecated
132
178
public static ContentReference construct (boolean isContentTextual , Object rawContent ,
133
179
int offset , int length ) {
134
- return new ContentReference (isContentTextual , rawContent , offset , length );
180
+ return new ContentReference (isContentTextual , rawContent , offset , length , ErrorReportConfiguration .defaults ());
181
+ }
182
+
183
+ /**
184
+ * @since 2.16
185
+ */
186
+ public static ContentReference construct (boolean isContentTextual , Object rawContent ,
187
+ int offset , int length , ErrorReportConfiguration errorReportConfiguration )
188
+ {
189
+ return new ContentReference (isContentTextual , rawContent , offset , length , errorReportConfiguration );
190
+ }
191
+
192
+ /**
193
+ * @since 2.16
194
+ */
195
+ public static ContentReference construct (boolean isContentTextual , Object rawContent ,
196
+ ErrorReportConfiguration errorReportConfiguration )
197
+ {
198
+ return new ContentReference (isContentTextual , rawContent , errorReportConfiguration );
135
199
}
136
200
137
201
/**
@@ -203,10 +267,11 @@ public Object getRawContent() {
203
267
* which content is counted, either bytes or chars) to use for truncation
204
268
* (so as not to include full content for humongous sources or targets)
205
269
*
270
+ * @see ErrorReportConfiguration#getMaxRawContentLength()
206
271
* @return Maximum content snippet to include before truncating
207
272
*/
208
- protected int maxContentSnippetLength () {
209
- return DEFAULT_MAX_CONTENT_SNIPPET ;
273
+ protected int maxRawContentLength () {
274
+ return _maxRawContentLength ;
210
275
}
211
276
212
277
/*
@@ -266,7 +331,7 @@ public StringBuilder appendSourceDescription(StringBuilder sb)
266
331
String trimmed ;
267
332
268
333
// poor man's tuple...
269
- final int maxLen = maxContentSnippetLength ();
334
+ final int maxLen = maxRawContentLength ();
270
335
int [] offsets = new int [] { contentOffset (), contentLength () };
271
336
272
337
if (srcRef instanceof CharSequence ) {
0 commit comments