Skip to content

Commit

Permalink
warnings cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 9, 2020
1 parent 2fa495a commit 9f2ca7f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Expand Up @@ -81,13 +81,20 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
/**********************************************************
*/

/**
* @deprecated since 2.12 Use the constructor that takes {@link TokenFilter.Inclusion}
* argument instead.
*/
@Deprecated
public FilteringGeneratorDelegate(JsonGenerator d, TokenFilter f,
boolean includePath, boolean allowMultipleMatches)
{
this(d, f, includePath ? Inclusion.INCLUDE_ALL_AND_PATH : Inclusion.ONLY_INCLUDE_ALL, allowMultipleMatches);
}

/**
* @since 2.12
*/
public FilteringGeneratorDelegate(JsonGenerator d, TokenFilter f,
TokenFilter.Inclusion inclusion, boolean allowMultipleMatches)
{
Expand Down
Expand Up @@ -334,14 +334,14 @@ public void testMultipleMatchFilteringWithPath1() throws Exception

w = new StringWriter();
gen = new FilteringGeneratorDelegate(_createGenerator(w),
new NameExcludeFilter(true, "ob"), true, true);
new NameExcludeFilter(true, "ob"), Inclusion.INCLUDE_ALL_AND_PATH, true);
writeJsonDoc(JSON_F, JSON, gen);
assertEquals(aposToQuotes("{'a':123,'array':[1,2],'b':true}"), w.toString());

// then excluding them
w = new StringWriter();
gen = new FilteringGeneratorDelegate(_createGenerator(w),
new NameExcludeFilter(false, "ob"), true, true);
new NameExcludeFilter(false, "ob"), Inclusion.INCLUDE_ALL_AND_PATH, true);
writeJsonDoc(JSON_F, JSON, gen);
assertEquals(aposToQuotes("{'a':123,'b':true}"), w.toString());
}
Expand Down Expand Up @@ -472,7 +472,7 @@ public void testMultipleMatchFilteringWithPath4() throws Exception
StringWriter w = new StringWriter();
FilteringGeneratorDelegate gen = new FilteringGeneratorDelegate(_createGenerator(w),
new NameMatchFilter("b0"),
true, true);
Inclusion.INCLUDE_ALL_AND_PATH, true);
final String JSON = "{'root':{'a0':true,'a':{'value':3},'b':{'value':'abc'}},'b0':false}";
writeJsonDoc(JSON_F, JSON, gen);
assertEquals(aposToQuotes("{'b0':false}"), w.toString());
Expand Down Expand Up @@ -526,7 +526,7 @@ public void testIndexMatchWithPath2() throws Exception
w = new StringWriter();
gen = new FilteringGeneratorDelegate(_createGenerator(w),
new IndexMatchFilter(1, 3, 5),
true, true);
Inclusion.INCLUDE_ALL_AND_PATH, true);
JSON = "{'a':123,'misc':[1,2, null, true, false, 'abc', 123],'ob':null,'b':true}";
writeJsonDoc(JSON_F, JSON, gen);
assertEquals(aposToQuotes("{'misc':[2,true,'abc']}"), w.toString());
Expand All @@ -535,7 +535,7 @@ public void testIndexMatchWithPath2() throws Exception
w = new StringWriter();
gen = new FilteringGeneratorDelegate(_createGenerator(w),
new IndexMatchFilter(2,6),
true, true);
Inclusion.INCLUDE_ALL_AND_PATH, true);
JSON = "{'misc':[1,2, null, 0.25, false, 'abc', 11234567890]}";
writeJsonDoc(JSON_F, JSON, gen);
assertEquals(aposToQuotes("{'misc':[null,11234567890]}"), w.toString());
Expand All @@ -544,7 +544,7 @@ public void testIndexMatchWithPath2() throws Exception
w = new StringWriter();
gen = new FilteringGeneratorDelegate(_createGenerator(w),
new IndexMatchFilter(1),
true, true);
Inclusion.INCLUDE_ALL_AND_PATH, true);
JSON = "{'misc':[1,0.25,11234567890]}";
writeJsonDoc(JSON_F, JSON, gen);
assertEquals(aposToQuotes("{'misc':[0.25]}"), w.toString());
Expand Down Expand Up @@ -581,7 +581,7 @@ public void testRawValueDelegationWithArray() throws Exception
{
StringWriter w = new StringWriter();
FilteringGeneratorDelegate gen = new FilteringGeneratorDelegate(_createGenerator(w),
TokenFilter.INCLUDE_ALL, true, true);
TokenFilter.INCLUDE_ALL, Inclusion.INCLUDE_ALL_AND_PATH, true);

gen.writeStartArray();
gen.writeRawValue(new char[] { '1'}, 0, 1);
Expand All @@ -601,7 +601,7 @@ public void testRawValueDelegationWithObject() throws Exception
{
StringWriter w = new StringWriter();
FilteringGeneratorDelegate gen = new FilteringGeneratorDelegate(_createGenerator(w),
TokenFilter.INCLUDE_ALL, true, true);
TokenFilter.INCLUDE_ALL, Inclusion.INCLUDE_ALL_AND_PATH, true);

gen.writeStartObject();
gen.writeNumberField("f1", 1);
Expand Down
Expand Up @@ -3,6 +3,7 @@
import java.io.*;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.filter.TokenFilter.Inclusion;
import com.fasterxml.jackson.core.util.JsonGeneratorDelegate;

// for [core#609]
Expand Down Expand Up @@ -57,13 +58,12 @@ public void writeFieldName(String name) throws IOException {
}

// for [core#609]: will pass in 2.10 for some cases
@SuppressWarnings("resource")
public void testIssue609() throws Exception
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JsonGenerator g = createGenerator(outputStream);
g = new FilteringGeneratorDelegate(
g, NullExcludingTokenFilter.INSTANCE, true, true);
g, NullExcludingTokenFilter.INSTANCE, Inclusion.INCLUDE_ALL_AND_PATH, true);
int maxStringLength = 10;
g = new StringTruncatingGeneratorDelegate(
g, maxStringLength);
Expand All @@ -72,6 +72,7 @@ public void testIssue609() throws Exception
g.writeString("1234567890!");
g.writeEndObject();
g.close();
outputStream.close();

String json = outputStream.toString("US-ASCII");
assertEquals("{\"message\":\"1234567890\"}", json);
Expand Down
Expand Up @@ -131,7 +131,7 @@ private void _testArrayFiltering582(int mode) throws IOException
JsonGenerator jg = JSON_F.createGenerator(output);

FilteringGeneratorDelegate gen = new FilteringGeneratorDelegate(jg,
new JsonPointerBasedFilter("/noMatch"), true, true);
new JsonPointerBasedFilter("/noMatch"), Inclusion.INCLUDE_ALL_AND_PATH, true);
final String[] stuff = new String[] { "foo", "bar" };

switch (mode) {
Expand Down

0 comments on commit 9f2ca7f

Please sign in to comment.