Skip to content

Commit 05aae50

Browse files
committed
Rename variable
1 parent 1c8e69d commit 05aae50

File tree

9 files changed

+59
-144
lines changed

9 files changed

+59
-144
lines changed

base/src/main/java/com/github/skjolber/jsonfilter/base/AbstractMultiPathJsonFilter.java

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -86,65 +86,4 @@ public AbstractMultiPathJsonFilter(int maxStringLength, int maxSize, int maxPath
8686

8787
this.pathItem = FACTORY.create(expressionNode);
8888
}
89-
90-
91-
/**
92-
* Note that the order or the filters establishes precedence (prune over anon).
93-
*
94-
* @param chars JSON characters
95-
* @return the matching filter type, or null if none
96-
*/
97-
98-
protected FilterType matchAnyElements(final String chars) {
99-
return anyPathFilters.matchPath(chars);
100-
}
101-
102-
/**
103-
* Match a char range against any-type expressions.
104-
*
105-
* Note that the order or the filters establishes precedence (prune over anon).
106-
*
107-
* @param chars JSON characters
108-
* @param start JSON characters start position
109-
* @param end JSON characters end position
110-
* @return the matching filter type, or null if none
111-
*/
112-
113-
protected FilterType matchAnyElements(final char[] chars, int start, int end) {
114-
return anyPathFilters.matchPath(chars, start, end);
115-
}
116-
117-
protected static FilterType matchAnyElements(AnyPathFilter[][] anyElementFiltersChars, final char[] chars, int start, int end) {
118-
int length = end - start;
119-
if(length >= anyElementFiltersChars.length || anyElementFiltersChars[length] == null) {
120-
return null;
121-
}
122-
return matchAnyElements(anyElementFiltersChars[length], chars, start, end);
123-
}
124-
125-
protected static FilterType matchAnyElements(AnyPathFilter[] anyElementFilters, final char[] chars, int start, int end) {
126-
for(int i = 0; i < anyElementFilters.length; i++) {
127-
if(AbstractPathJsonFilter.matchPath(chars, start, end, anyElementFilters[i].pathChars)) {
128-
return anyElementFilters[i].getFilterType();
129-
}
130-
}
131-
return null;
132-
}
133-
134-
/**
135-
* Match a byte range against any-type expressions.
136-
*
137-
* Note that the order or the filters establishes precedence (prune over anon).
138-
*
139-
* @param chars JSON characters
140-
* @param start JSON characters start position
141-
* @param end JSON characters end position
142-
* @return the matching filter type, or null if none
143-
*/
144-
145-
protected FilterType matchAnyElements(final byte[] chars, int start, int end) {
146-
return anyPathFilters.matchPath(chars, start, end);
147-
}
148-
149-
15089
}

base/src/main/java/com/github/skjolber/jsonfilter/base/path/any/AnyPathFilters.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,31 +177,31 @@ public FilterType matchPath(final char[] chars, int start, int end) {
177177
}
178178

179179

180-
protected static FilterType unencodedMatchAnyElements(AnyPathFilter[] anyElementFilters, final byte[] chars, int start, int end) {
180+
protected static FilterType unencodedMatchAnyElements(AnyPathFilter[] anyPathFilters, final byte[] chars, int start, int end) {
181181
main:
182-
for(int i = 0; i < anyElementFilters.length; i++) {
183-
byte[] pathBytes = anyElementFilters[i].pathBytes;
182+
for(int i = 0; i < anyPathFilters.length; i++) {
183+
byte[] pathBytes = anyPathFilters[i].pathBytes;
184184
for(int k = 0; k < pathBytes.length; k++) {
185185
if(pathBytes[k] != chars[start + k]) {
186186
continue main;
187187
}
188188
}
189-
return anyElementFilters[i].filterType;
189+
return anyPathFilters[i].filterType;
190190
}
191191
return null;
192192
}
193193

194-
protected static FilterType unencodedMatchAnyElements(AnyPathFilter[] anyElementFilters, final char[] chars, int start, int end) {
194+
protected static FilterType unencodedMatchAnyElements(AnyPathFilter[] anyPathFilters, final char[] chars, int start, int end) {
195195

196196
main:
197-
for(int i = 0; i < anyElementFilters.length; i++) {
198-
char[] pathBytes = anyElementFilters[i].pathChars;
197+
for(int i = 0; i < anyPathFilters.length; i++) {
198+
char[] pathBytes = anyPathFilters[i].pathChars;
199199
for(int k = 0; k < pathBytes.length; k++) {
200200
if(pathBytes[k] != chars[start + k]) {
201201
continue main;
202202
}
203203
}
204-
return anyElementFilters[i].filterType;
204+
return anyPathFilters[i].filterType;
205205
}
206206
return null;
207207
}

base/src/test/java/com/github/skjolber/jsonfilter/base/AbstractMultiPathJsonFilterTest.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,5 @@ public void testConstructor() {
5252
MyAbstractMultiPathJsonFilter filter = new MyAbstractMultiPathJsonFilter(127, 127, new String[] {"/abc/def/ghi", "/def", "/ghi", "/abc/yyy", "/abc/zzz"}, null, "pruneMessage", "anonymizeMessage", "truncateMessage");
5353
}
5454

55-
@Test
56-
public void testMatchAny() {
57-
AbstractMultiPathJsonFilter filter = new MyAbstractMultiPathJsonFilter(127, 127, new String[] {"/abc/def", "//def"}, null, "pruneMessage", "anonymizeMessage", "truncateMessage");
58-
59-
String def = "def";
60-
assertEquals(filter.matchAnyElements(def), FilterType.ANON);
61-
assertEquals(filter.matchAnyElements(def.toCharArray(), 0, 3), FilterType.ANON);
62-
assertEquals(filter.matchAnyElements(def.getBytes(StandardCharsets.UTF_8), 0, 3), FilterType.ANON);
63-
64-
String de = "de";
65-
assertNull(filter.matchAnyElements(de));
66-
assertNull(filter.matchAnyElements(de.toCharArray(), 0, 2));
67-
assertNull(filter.matchAnyElements(de.getBytes(StandardCharsets.UTF_8), 0, 2));
68-
69-
String defgh = "defgh";
70-
assertNull(filter.matchAnyElements(defgh));
71-
assertNull(filter.matchAnyElements(defgh.toCharArray(), 0, 5));
72-
assertNull(filter.matchAnyElements(defgh.getBytes(StandardCharsets.UTF_8), 0, 5));
73-
74-
String fgh = "fgh";
75-
assertNull(filter.matchAnyElements(fgh));
76-
assertNull(filter.matchAnyElements(fgh.toCharArray(), 0, 3));
77-
assertNull(filter.matchAnyElements(fgh.getBytes(StandardCharsets.UTF_8), 0, 3));
78-
}
7955

8056
}

impl/core/src/main/java/com/github/skjolber/jsonfilter/core/AnyPathJsonFilter.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ protected AnyPathJsonFilter(int maxStringLength, int maxSize, int maxPathMatches
2727
public CharArrayRangesFilter ranges(final char[] chars, int offset, int length) {
2828
final CharArrayRangesFilter filter = getCharArrayRangesFilter(maxPathMatches, length);
2929
try {
30-
AnyPathFilters anyElementFilters = this.anyPathFilters;
30+
AnyPathFilters anyPathFilters = this.anyPathFilters;
3131
if(maxPathMatches != -1) {
32-
rangesAnyPath(chars, offset, offset + length, maxPathMatches, anyElementFilters, filter);
32+
rangesAnyPath(chars, offset, offset + length, maxPathMatches, anyPathFilters, filter);
3333
} else {
34-
rangesAnyPath(chars, offset, offset + length, anyElementFilters, filter);
34+
rangesAnyPath(chars, offset, offset + length, anyPathFilters, filter);
3535
}
3636
return filter;
3737
} catch(Exception e) {
@@ -44,19 +44,19 @@ public CharArrayRangesFilter ranges(final char[] chars, int offset, int length)
4444
public ByteArrayRangesFilter ranges(final byte[] chars, int offset, int length) {
4545
final ByteArrayRangesFilter filter = getByteArrayRangesFilter(maxPathMatches, length);
4646
try {
47-
AnyPathFilters anyElementFilters = this.anyPathFilters;
47+
AnyPathFilters anyPathFilters = this.anyPathFilters;
4848
if(maxPathMatches != -1) {
49-
rangesAnyPath(chars, offset, offset + length, maxPathMatches, anyElementFilters, filter);
49+
rangesAnyPath(chars, offset, offset + length, maxPathMatches, anyPathFilters, filter);
5050
} else {
51-
rangesAnyPath(chars, offset, offset + length, anyElementFilters, filter);
51+
rangesAnyPath(chars, offset, offset + length, anyPathFilters, filter);
5252
}
5353
return filter;
5454
} catch(Exception e) {
5555
return null;
5656
}
5757
}
5858

59-
public static void rangesAnyPath(final char[] chars, int offset, int limit, int pathMatches, AnyPathFilters anyElementFilters, CharArrayRangesFilter filter) {
59+
public static void rangesAnyPath(final char[] chars, int offset, int limit, int pathMatches, AnyPathFilters anyPathFilters, CharArrayRangesFilter filter) {
6060
while(offset < limit) {
6161
if(chars[offset] != '"') {
6262
offset++;
@@ -93,7 +93,7 @@ public static void rangesAnyPath(final char[] chars, int offset, int limit, int
9393
// skip whitespace after colon
9494
while(chars[++nextOffset] <= 0x20);
9595

96-
FilterType filterType = anyElementFilters.matchPath(chars, offset + 1, quoteIndex);
96+
FilterType filterType = anyPathFilters.matchPath(chars, offset + 1, quoteIndex);
9797

9898
if(filterType != null) {
9999
switch(chars[nextOffset]) {
@@ -166,7 +166,7 @@ public static void rangesAnyPath(final char[] chars, int offset, int limit, int
166166
}
167167
}
168168

169-
public static void rangesAnyPath(final byte[] chars, int offset, int limit, int pathMatches, AnyPathFilters anyElementFilters, ByteArrayRangesFilter filter) {
169+
public static void rangesAnyPath(final byte[] chars, int offset, int limit, int pathMatches, AnyPathFilters anyPathFilters, ByteArrayRangesFilter filter) {
170170
while(offset < limit) {
171171
if(chars[offset] != '"') {
172172
offset++;
@@ -203,7 +203,7 @@ public static void rangesAnyPath(final byte[] chars, int offset, int limit, int
203203
// skip whitespace after colon
204204
while(chars[++nextOffset] <= 0x20);
205205

206-
FilterType filterType = anyElementFilters.matchPath(chars, offset + 1, quoteIndex);
206+
FilterType filterType = anyPathFilters.matchPath(chars, offset + 1, quoteIndex);
207207
if(filterType != null) {
208208
switch(chars[nextOffset]) {
209209
case '[':
@@ -275,7 +275,7 @@ public static void rangesAnyPath(final byte[] chars, int offset, int limit, int
275275
}
276276
}
277277

278-
public static void rangesAnyPath(final char[] chars, int offset, int limit, AnyPathFilters anyElementFilters, CharArrayRangesFilter filter) {
278+
public static void rangesAnyPath(final char[] chars, int offset, int limit, AnyPathFilters anyPathFilters, CharArrayRangesFilter filter) {
279279
while(offset < limit) {
280280
if(chars[offset] == '"') {
281281
int nextOffset = CharArrayRangesFilter.scanQuotedValue(chars, offset);
@@ -309,7 +309,7 @@ public static void rangesAnyPath(final char[] chars, int offset, int limit, AnyP
309309
// skip whitespace after colon
310310
while(chars[++nextOffset] <= 0x20);
311311

312-
FilterType filterType = anyElementFilters.matchPath(chars, offset + 1, quoteIndex);
312+
FilterType filterType = anyPathFilters.matchPath(chars, offset + 1, quoteIndex);
313313

314314
if(filterType != null) {
315315
switch(chars[nextOffset]) {
@@ -379,7 +379,7 @@ public static void rangesAnyPath(final char[] chars, int offset, int limit, AnyP
379379
}
380380
}
381381

382-
public static void rangesAnyPath(final byte[] chars, int offset, int limit, AnyPathFilters anyElementFilters, ByteArrayRangesFilter filter) {
382+
public static void rangesAnyPath(final byte[] chars, int offset, int limit, AnyPathFilters anyPathFilters, ByteArrayRangesFilter filter) {
383383
while(offset < limit) {
384384
if(chars[offset] == '"') {
385385
int nextOffset = ByteArrayRangesFilter.scanQuotedValue(chars, offset);
@@ -413,7 +413,7 @@ public static void rangesAnyPath(final byte[] chars, int offset, int limit, AnyP
413413
// skip whitespace after colon
414414
while(chars[++nextOffset] <= 0x20);
415415

416-
FilterType filterType = anyElementFilters.matchPath(chars, offset + 1, quoteIndex);
416+
FilterType filterType = anyPathFilters.matchPath(chars, offset + 1, quoteIndex);
417417
if(filterType != null) {
418418
switch(chars[nextOffset]) {
419419
case '[':

impl/core/src/main/java/com/github/skjolber/jsonfilter/core/AnyPathMaxSizeJsonFilter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public ByteArrayRangesFilter ranges(final byte[] chars, int offset, int length)
4646
}
4747
}
4848

49-
protected static CharArrayRangesSizeFilter rangesAnyPathMaxSize(final char[] chars, int offset, int maxReadLimit, int maxSizeLimit, AnyPathFilters anyElementFilters, int pathMatches, CharArrayRangesSizeFilter filter) {
49+
protected static CharArrayRangesSizeFilter rangesAnyPathMaxSize(final char[] chars, int offset, int maxReadLimit, int maxSizeLimit, AnyPathFilters anyPathFilters, int pathMatches, CharArrayRangesSizeFilter filter) {
5050

5151
boolean[] squareBrackets = filter.getSquareBrackets();
5252
int bracketLevel = filter.getLevel();
@@ -112,7 +112,7 @@ protected static CharArrayRangesSizeFilter rangesAnyPathMaxSize(final char[] cha
112112
// skip colon
113113
while(chars[++nextOffset] <= 0x20);
114114

115-
FilterType filterType = anyElementFilters.matchPath(chars, offset + 1, quoteEndIndex);
115+
FilterType filterType = anyPathFilters.matchPath(chars, offset + 1, quoteEndIndex);
116116
if(filterType != null) {
117117
int removedLength = filter.getRemovedLength();
118118

@@ -222,7 +222,7 @@ protected static CharArrayRangesSizeFilter rangesAnyPathMaxSize(final char[] cha
222222
// filtering only for path, i.e. keep the rest of the document
223223
filter.setLevel(0);
224224

225-
rangesAnyPath(chars, offset, maxReadLimit, pathMatches, anyElementFilters, filter);
225+
rangesAnyPath(chars, offset, maxReadLimit, pathMatches, anyPathFilters, filter);
226226
return filter;
227227
}
228228
} else {
@@ -324,7 +324,7 @@ protected static CharArrayRangesSizeFilter rangesMaxSize(final char[] chars, int
324324
return filter;
325325
}
326326

327-
protected static ByteArrayRangesSizeFilter rangesAnyPathMaxSize(final byte[] chars, int offset, int maxReadLimit, int maxSizeLimit, AnyPathFilters anyElementFilters, int pathMatches, ByteArrayRangesSizeFilter filter) {
327+
protected static ByteArrayRangesSizeFilter rangesAnyPathMaxSize(final byte[] chars, int offset, int maxReadLimit, int maxSizeLimit, AnyPathFilters anyPathFilters, int pathMatches, ByteArrayRangesSizeFilter filter) {
328328

329329
boolean[] squareBrackets = filter.getSquareBrackets();
330330
int bracketLevel = filter.getLevel();
@@ -387,7 +387,7 @@ protected static ByteArrayRangesSizeFilter rangesAnyPathMaxSize(final byte[] cha
387387
// skip colon
388388
while(chars[++nextOffset] <= 0x20);
389389

390-
FilterType filterType = anyElementFilters.matchPath(chars, offset + 1, quoteEndIndex);
390+
FilterType filterType = anyPathFilters.matchPath(chars, offset + 1, quoteEndIndex);
391391
if(filterType != null) {
392392
int removedLength = filter.getRemovedLength();
393393

@@ -496,7 +496,7 @@ protected static ByteArrayRangesSizeFilter rangesAnyPathMaxSize(final byte[] cha
496496
// filtering only for path, i.e. keep the rest of the document
497497
filter.setLevel(0);
498498

499-
rangesAnyPath(chars, offset, maxReadLimit, pathMatches, anyElementFilters, filter);
499+
rangesAnyPath(chars, offset, maxReadLimit, pathMatches, anyPathFilters, filter);
500500
return filter;
501501
}
502502
} else {

impl/core/src/main/java/com/github/skjolber/jsonfilter/core/MultiPathJsonFilter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public MultiPathJsonFilter(int maxPathMatches, String[] anonymizes, String[] pru
1919
public CharArrayRangesFilter ranges(final char[] chars, int offset, int length) {
2020
int pathMatches = this.maxPathMatches;
2121

22-
AnyPathFilters anyElementFilters = this.anyPathFilters;
22+
AnyPathFilters anyPathFilters = this.anyPathFilters;
2323

2424
final CharArrayRangesFilter filter = getCharArrayRangesFilter(maxPathMatches, length);
2525

@@ -35,7 +35,7 @@ public CharArrayRangesFilter ranges(final char[] chars, int offset, int length)
3535
case '{' :
3636
level++;
3737

38-
if(anyElementFilters == null && level > pathItem.getLevel()) {
38+
if(anyPathFilters == null && level > pathItem.getLevel()) {
3939
offset = CharArrayRangesFilter.skipObject(chars, offset);
4040

4141
level--;
@@ -90,8 +90,8 @@ public CharArrayRangesFilter ranges(final char[] chars, int offset, int length)
9090
pathItem = pathItem.constrain(level);
9191
}
9292

93-
if(anyElementFilters != null && type == null) {
94-
type = anyElementFilters.matchPath(chars, offset + 1, quoteIndex);
93+
if(anyPathFilters != null && type == null) {
94+
type = anyPathFilters.matchPath(chars, offset + 1, quoteIndex);
9595
}
9696

9797
// skip whitespace
@@ -152,7 +152,7 @@ public CharArrayRangesFilter ranges(final char[] chars, int offset, int length)
152152
public ByteArrayRangesFilter ranges(final byte[] chars, int offset, int length) {
153153
int pathMatches = this.maxPathMatches;
154154

155-
AnyPathFilters anyElementFilters = this.anyPathFilters;
155+
AnyPathFilters anyPathFilters = this.anyPathFilters;
156156

157157
length += offset;
158158

@@ -167,7 +167,7 @@ public ByteArrayRangesFilter ranges(final byte[] chars, int offset, int length)
167167
switch(chars[offset]) {
168168
case '{' :
169169
level++;
170-
if(anyElementFilters == null && level > pathItem.getLevel()) {
170+
if(anyPathFilters == null && level > pathItem.getLevel()) {
171171
offset = ByteArrayRangesFilter.skipObject(chars, offset);
172172

173173
level--;
@@ -223,8 +223,8 @@ public ByteArrayRangesFilter ranges(final byte[] chars, int offset, int length)
223223
pathItem = pathItem.constrain(level);
224224
}
225225

226-
if(anyElementFilters != null && type == null) {
227-
type = anyElementFilters.matchPath(chars, offset + 1, quoteIndex);
226+
if(anyPathFilters != null && type == null) {
227+
type = anyPathFilters.matchPath(chars, offset + 1, quoteIndex);
228228
}
229229

230230
// skip whitespace

0 commit comments

Comments
 (0)