From 7292fe54689871b11e2056e4b78dbaa9657f0b46 Mon Sep 17 00:00:00 2001 From: "moandji.ezana" Date: Thu, 12 Feb 2015 08:33:43 +0200 Subject: [PATCH] Added Results.Errors to Context constructor and Context.with(Identifier) --- src/main/java/com/moandjiezana/toml/Context.java | 8 +++++++- .../java/com/moandjiezana/toml/InlineTableConverter.java | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moandjiezana/toml/Context.java b/src/main/java/com/moandjiezana/toml/Context.java index 1f41208..6f6b667 100644 --- a/src/main/java/com/moandjiezana/toml/Context.java +++ b/src/main/java/com/moandjiezana/toml/Context.java @@ -5,9 +5,15 @@ import java.util.concurrent.atomic.AtomicInteger; class Context { final Identifier identifier; final AtomicInteger line; + final Results.Errors errors; - public Context(Identifier identifier, AtomicInteger line) { + public Context(Identifier identifier, AtomicInteger line, Results.Errors errors) { this.identifier = identifier; this.line = line; + this.errors = errors; + } + + public Context with(Identifier identifier) { + return new Context(identifier, line, errors); } } diff --git a/src/main/java/com/moandjiezana/toml/InlineTableConverter.java b/src/main/java/com/moandjiezana/toml/InlineTableConverter.java index e72472f..d4e03af 100644 --- a/src/main/java/com/moandjiezana/toml/InlineTableConverter.java +++ b/src/main/java/com/moandjiezana/toml/InlineTableConverter.java @@ -37,7 +37,7 @@ class InlineTableConverter implements ValueConverter { } else if (quoted) { currentKey.append(c); } else if (inValue && !Character.isWhitespace(c)) { - Object converted = CONVERTERS.convert(s, sharedIndex, new Context(new Identifier(currentKey.toString()), context.line)); + Object converted = CONVERTERS.convert(s, sharedIndex, context.with(new Identifier(currentKey.toString()))); if (converted instanceof Results.Errors) { errors.add((Results.Errors) converted); @@ -49,7 +49,7 @@ class InlineTableConverter implements ValueConverter { inValue = false; } else if (c == '{') { sharedIndex.incrementAndGet(); - Object converted = convert(s, sharedIndex, new Context(new Identifier(currentKey.toString()), context.line)); + Object converted = convert(s, sharedIndex, context.with(new Identifier(currentKey.toString()))); if (converted instanceof Results.Errors) { errors.add((Results.Errors) converted);