From commits-return-61405-archive-asf-public=cust-asf.ponee.io@commons.apache.org Sun Feb 11 19:15:40 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id DDFDD18064E for ; Sun, 11 Feb 2018 19:15:40 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CDA5E160C4E; Sun, 11 Feb 2018 18:15:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EB191160C2E for ; Sun, 11 Feb 2018 19:15:39 +0100 (CET) Received: (qmail 26323 invoked by uid 500); 11 Feb 2018 18:15:39 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 26309 invoked by uid 99); 11 Feb 2018 18:15:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Feb 2018 18:15:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CC693E0A04; Sun, 11 Feb 2018 18:15:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ggregory@apache.org To: commits@commons.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [text] [TEXT-113] Add an interpolator string lookup. No long needs to subclass StrLookup. Fix Checkstyle errors. Add Javadoc comments. Clean ups. Date: Sun, 11 Feb 2018 18:15:37 +0000 (UTC) Repository: commons-text Updated Branches: refs/heads/master 388fa72c1 -> 1de362f43 [TEXT-113] Add an interpolator string lookup. No long needs to subclass StrLookup. Fix Checkstyle errors. Add Javadoc comments. Clean ups. Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/1de362f4 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/1de362f4 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/1de362f4 Branch: refs/heads/master Commit: 1de362f43968de500c4ef5a80672b4efbb27ae49 Parents: 388fa72 Author: Gary Gregory Authored: Sun Feb 11 11:15:35 2018 -0700 Committer: Gary Gregory Committed: Sun Feb 11 11:15:35 2018 -0700 ---------------------------------------------------------------------- .../commons/text/lookup/AbstractStringLookup.java | 2 +- .../text/lookup/InterpolatorStringLookup.java | 1 - .../commons/text/lookup/MapStringLookup.java | 4 ++-- .../apache/commons/text/StrSubstitutorTest.java | 17 ++++++++--------- 4 files changed, 11 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-text/blob/1de362f4/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java b/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java index 563d165..bb43e96 100644 --- a/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java @@ -26,6 +26,6 @@ package org.apache.commons.text.lookup; * * @since 1.3 */ -public abstract class AbstractStringLookup implements StringLookup { +abstract class AbstractStringLookup implements StringLookup { // nothing yet } http://git-wip-us.apache.org/repos/asf/commons-text/blob/1de362f4/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java index ccf823b..1eddf43 100644 --- a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java @@ -69,7 +69,6 @@ class InterpolatorStringLookup extends AbstractStringLookup { */ InterpolatorStringLookup(final Map defaultMap) { this(MapStringLookup.on(defaultMap == null ? new HashMap() : defaultMap)); - // TODO: Use a service loader stringLookupMap.put("sys", SystemPropertyStringLookup.INSTANCE); stringLookupMap.put("env", EnvironmentVariableStringLookup.INSTANCE); stringLookupMap.put("java", JavaPlatformStringLookup.INSTANCE); http://git-wip-us.apache.org/repos/asf/commons-text/blob/1de362f4/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java b/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java index b85bcf5..dedd77a 100644 --- a/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java @@ -26,7 +26,7 @@ import java.util.Map; * * @since 1.3 */ -public final class MapStringLookup implements StringLookup { +final class MapStringLookup implements StringLookup { /** * Creates a new instance backed by a Map. Used by the default lookup. @@ -37,7 +37,7 @@ public final class MapStringLookup implements StringLookup { * the map of keys to values, may be null. * @return a new instance backed by the given map. */ - public static MapStringLookup on(final Map map) { + static MapStringLookup on(final Map map) { return new MapStringLookup<>(map); } http://git-wip-us.apache.org/repos/asf/commons-text/blob/1de362f4/src/test/java/org/apache/commons/text/StrSubstitutorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/text/StrSubstitutorTest.java b/src/test/java/org/apache/commons/text/StrSubstitutorTest.java index 8cd435a..4ab52ed 100644 --- a/src/test/java/org/apache/commons/text/StrSubstitutorTest.java +++ b/src/test/java/org/apache/commons/text/StrSubstitutorTest.java @@ -29,7 +29,6 @@ import java.util.Map; import java.util.Properties; import org.apache.commons.lang3.mutable.MutableObject; -import org.apache.commons.text.lookup.MapStringLookup; import org.apache.commons.text.lookup.StringLookup; import org.apache.commons.text.lookup.StringLookupFactory; import org.junit.After; @@ -770,10 +769,10 @@ public class StrSubstitutorTest { @Test public void testReplaceInTakingTwoAndThreeIntsReturningFalse() { final Map hashMap = new HashMap<>(); - final MapStringLookup strLookupMapStrLookup = MapStringLookup.on(hashMap); + final StringLookup mapStringLookup = StringLookupFactory.INSTANCE.mapStringLookup(hashMap); final StrMatcher strMatcher = StrMatcher.tabMatcher(); final StrSubstitutor strSubstitutor = - new StrSubstitutor(strLookupMapStrLookup, strMatcher, strMatcher, 'b', strMatcher); + new StrSubstitutor(mapStringLookup, strMatcher, strMatcher, 'b', strMatcher); assertFalse(strSubstitutor.replaceIn((StringBuilder) null, 1315, (-1369))); assertEquals('b', strSubstitutor.getEscapeChar()); @@ -783,10 +782,10 @@ public class StrSubstitutorTest { @Test public void testReplaceInTakingTwoAndThreeIntsReturningFalse_deprecated() { final Map hashMap = new HashMap<>(); - final StrLookup.MapStrLookup strLookupMapStrLookup = new StrLookup.MapStrLookup<>(hashMap); + final StrLookup.MapStrLookup mapStrLookup = new StrLookup.MapStrLookup<>(hashMap); final StrMatcher strMatcher = StrMatcher.tabMatcher(); final StrSubstitutor strSubstitutor = - new StrSubstitutor(strLookupMapStrLookup, strMatcher, strMatcher, 'b', strMatcher); + new StrSubstitutor(mapStrLookup, strMatcher, strMatcher, 'b', strMatcher); assertFalse(strSubstitutor.replaceIn((StringBuilder) null, 1315, (-1369))); assertEquals('b', strSubstitutor.getEscapeChar()); @@ -826,8 +825,8 @@ public class StrSubstitutorTest { @Test public void testCreatesStrSubstitutorTakingStrLookupAndCallsReplaceTakingTwoAndThreeInts() { final Map map = new HashMap<>(); - final MapStringLookup strLookupMapStrLookup = MapStringLookup.on(map); - final StrSubstitutor strSubstitutor = new StrSubstitutor(strLookupMapStrLookup); + final StringLookup mapStringLookup = StringLookupFactory.INSTANCE.mapStringLookup(map); + final StrSubstitutor strSubstitutor = new StrSubstitutor(mapStringLookup); assertNull(strSubstitutor.replace((CharSequence) null, 0, 0)); assertEquals('$', strSubstitutor.getEscapeChar()); @@ -836,8 +835,8 @@ public class StrSubstitutorTest { @Test public void testCreatesStrSubstitutorTakingStrLookupAndCallsReplaceTakingTwoAndThreeInts_deprecated() { final Map map = new HashMap<>(); - final StrLookup.MapStrLookup strLookupMapStrLookup = new StrLookup.MapStrLookup<>(map); - final StrSubstitutor strSubstitutor = new StrSubstitutor(strLookupMapStrLookup); + final StrLookup.MapStrLookup mapStrLookup = new StrLookup.MapStrLookup<>(map); + final StrSubstitutor strSubstitutor = new StrSubstitutor(mapStrLookup); assertNull(strSubstitutor.replace((CharSequence) null, 0, 0)); assertEquals('$', strSubstitutor.getEscapeChar());