@@ -35,7 +35,8 @@ public static JPropPathSplitter create(JavaPropsSchema schema)
35
35
}
36
36
return new FullSplitter (sep , schema .parseSimpleIndexes (),
37
37
indexMarker ,
38
- pathOnlySplitter (schema ));
38
+ pathOnlySplitter (schema ),
39
+ schema .prefix ());
39
40
}
40
41
41
42
private static JPropPathSplitter pathOnlySplitter (JavaPropsSchema schema )
@@ -262,14 +263,25 @@ public static class FullSplitter extends JPropPathSplitter
262
263
// small but important optimization for cases where index markers are absent
263
264
protected final int _indexFirstChar ;
264
265
protected final JPropPathSplitter _simpleSplitter ;
265
-
266
+
267
+ /**
268
+ * @since 2.10
269
+ */
270
+ protected final String _prefix ;
271
+
266
272
public FullSplitter (String pathSeparator , boolean useSimpleIndex ,
267
- Markers indexMarker , JPropPathSplitter fallbackSplitter )
273
+ Markers indexMarker , JPropPathSplitter fallbackSplitter ,
274
+ String prefix )
268
275
{
269
276
super (useSimpleIndex );
270
277
String startMarker = indexMarker .getStart ();
271
278
_indexFirstChar = startMarker .charAt (0 );
272
279
_simpleSplitter = fallbackSplitter ;
280
+ if (prefix == null || prefix .isEmpty ()) {
281
+ _prefix = null ;
282
+ } else {
283
+ _prefix = prefix + pathSeparator ;
284
+ }
273
285
_indexMatch = Pattern .compile (String .format
274
286
("(%s)|(%s(\\ d{1,9})%s)" ,
275
287
Pattern .quote (pathSeparator ),
@@ -281,6 +293,13 @@ public FullSplitter(String pathSeparator, boolean useSimpleIndex,
281
293
public JPropNode splitAndAdd (JPropNode parent ,
282
294
String key , String value )
283
295
{
296
+ // [dataformats-text#100]: handle possible prefix
297
+ if (_prefix != null ) {
298
+ if (!key .startsWith (_prefix )) {
299
+ return null ;
300
+ }
301
+ key = key .substring (_prefix .length ());
302
+ }
284
303
if (key .indexOf (_indexFirstChar ) < 0 ) { // no index start marker
285
304
return _simpleSplitter .splitAndAdd (parent , key , value );
286
305
}
0 commit comments