diff --git a/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/Parser.java b/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/Parser.java index c5d2a70f3..a11849af1 100644 --- a/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/Parser.java +++ b/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/Parser.java @@ -21,19 +21,19 @@ class Parser { private static final JsonNodeFactory factory = new JsonNodeFactoryImpl(); private final JacksonTomlParseException.ErrorContext errorContext; - private final ParserOptions options; + private final int options; private final Lexer lexer; private TomlToken next; - private Parser(JacksonTomlParseException.ErrorContext errorContext, ParserOptions options, Reader reader) throws IOException { + private Parser(JacksonTomlParseException.ErrorContext errorContext, int options, Reader reader) throws IOException { this.errorContext = errorContext; this.options = options; this.lexer = new Lexer(reader, errorContext); this.next = lexer.yylex(); } - public static ObjectNode parse(JacksonTomlParseException.ErrorContext errorContext, ParserOptions options, Reader reader) throws IOException { + public static ObjectNode parse(JacksonTomlParseException.ErrorContext errorContext, int options, Reader reader) throws IOException { return new Parser(errorContext, options, reader).parse(); } @@ -191,7 +191,7 @@ private JsonNode parseDateTime(int nextState) throws IOException { text = text.substring(0, 10) + 'T' + text.substring(11); } - if (options.parseTemporalAsJavaTime) { + if (TomlReadFeature.PARSE_JAVA_TIME.enabledIn(options)) { Temporal value; if (token == TomlToken.LOCAL_DATE) { value = LocalDate.parse(text); diff --git a/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/ParserOptions.java b/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/ParserOptions.java deleted file mode 100644 index c0ae73e78..000000000 --- a/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/ParserOptions.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.fasterxml.jackson.dataformat.toml; - -class ParserOptions { - final boolean parseTemporalAsJavaTime; - - public ParserOptions(boolean parseTemporalAsJavaTime) { - this.parseTemporalAsJavaTime = parseTemporalAsJavaTime; - } -} diff --git a/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/TomlFactory.java b/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/TomlFactory.java index 1e508fd84..5fce148fd 100644 --- a/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/TomlFactory.java +++ b/toml/src/main/java/com/fasterxml/jackson/dataformat/toml/TomlFactory.java @@ -201,16 +201,13 @@ protected Writer _createWriter(IOContext ioCtxt, OutputStream out, JsonEncoding private ObjectNode parse(ObjectReadContext readCtxt, IOContext ctxt, Reader r0) { JacksonTomlParseException.ErrorContext errorContext = new JacksonTomlParseException.ErrorContext(ctxt.sourceReference(), null); int readFeatures = readCtxt.getFormatReadFeatures(DEFAULT_TOML_PARSER_FEATURE_FLAGS); - ParserOptions options = new ParserOptions( - TomlReadFeature.PARSE_JAVA_TIME.enabledIn(readFeatures) - ); try { if (ctxt.isResourceManaged() || isEnabled(StreamReadFeature.AUTO_CLOSE_SOURCE)) { try (Reader r = r0) { - return Parser.parse(errorContext, options, r); + return Parser.parse(errorContext, readFeatures, r); } } else { - return Parser.parse(errorContext, options, r0); + return Parser.parse(errorContext, readFeatures, r0); } } catch (IOException e) { throw _wrapIOFailure(e); diff --git a/toml/src/test/java/com/fasterxml/jackson/dataformat/toml/ParserTest.java b/toml/src/test/java/com/fasterxml/jackson/dataformat/toml/ParserTest.java index 59d4921f9..6d3394d56 100644 --- a/toml/src/test/java/com/fasterxml/jackson/dataformat/toml/ParserTest.java +++ b/toml/src/test/java/com/fasterxml/jackson/dataformat/toml/ParserTest.java @@ -22,7 +22,6 @@ @SuppressWarnings("OctalInteger") public class ParserTest { - private final ParserOptions testOptions = new ParserOptions(false); private final ObjectMapper jsonMapper = JsonMapper.builder() .enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) .enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS) @@ -33,10 +32,10 @@ private ObjectNode json(@Language("json") String json) { } private ObjectNode toml(@Language("toml") String toml) throws IOException { - return toml(testOptions, toml); + return toml(0, toml); } - private ObjectNode toml(ParserOptions opts, @Language("toml") String toml) throws IOException { + private ObjectNode toml(int opts, @Language("toml") String toml) throws IOException { return Parser.parse(new JacksonTomlParseException.ErrorContext(null, null), opts, new StringReader(toml)); } @@ -896,7 +895,7 @@ public void intTypes() throws IOException { .put("int1", 99) .put("int2", 4242424242L) .put("int3", new BigInteger("171717171717171717171717")), - toml(new ParserOptions(false), "int1 = +99\n" + + toml("int1 = +99\n" + "int2 = 4242424242\n" + "int3 = 171717171717171717171717") ); @@ -911,7 +910,7 @@ public void longBase() throws IOException { .put("hex3", 0xddead_beefL) .put("oct1", 01234567777777L) .put("bin1", 0b11010110101010101010101010101010101010L), - toml(new ParserOptions(false), "hex1 = 0xdDEADBEEF\n" + + toml("hex1 = 0xdDEADBEEF\n" + "hex2 = 0xddeadbeef\n" + "hex3 = 0xddead_beef\n" + "oct1 = 0o1234567777777\n" + @@ -928,7 +927,7 @@ public void bigintBase() throws IOException { .put("hex3", new BigInteger("DDEADBEEFDDEADBEEF", 16)) .put("oct1", new BigInteger("12345677777771234567777777", 8)) .put("bin1", new BigInteger("1101011010101010101010101010101010101011010110101010101010101010101010101010", 2)), - toml(new ParserOptions(false), "hex1 = 0xDDEADBEEFDDEADBEEF\n" + + toml("hex1 = 0xDDEADBEEFDDEADBEEF\n" + "hex2 = 0xddeadbeefddeadbeef\n" + "hex3 = 0xddead_beefddead_beef\n" + "oct1 = 0o12345677777771234567777777\n" + @@ -939,7 +938,7 @@ public void bigintBase() throws IOException { @Test public void javaTimeDeser() throws IOException { // this is the same test as above, except with explicit java.time deserialization - ParserOptions options = new ParserOptions(true); + int options = TomlReadFeature.PARSE_JAVA_TIME.getMask(); Assert.assertEquals( JsonNodeFactory.instance.objectNode()