You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/08/04 15:36:11 UTC

[commons-text] 04/05: [TEXT-170] Add String lookup for host names and IP addresses (#118)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 3ba2268249138c597f8eb071c25fceeb717ae144
Merge: 7576289 d81879e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 4 11:34:31 2019 -0400

    [TEXT-170] Add String lookup for host names and IP addresses (#118)
    
    Merge remote-tracking branch 'origin/master'.

 src/changes/changes.xml                            |  1 +
 .../commons/text/lookup/DefaultStringLookup.java   |  7 ++
 .../commons/text/lookup/DnsStringLookup.java       | 85 ++++++++++++++++++++++
 .../commons/text/lookup/InetAddressKeys.java       | 44 +++++++++++
 .../commons/text/lookup/LocalHostStringLookup.java |  6 +-
 .../commons/text/lookup/StringLookupFactory.java   | 28 +++++++
 ...ubstitutorWithInterpolatorStringLookupTest.java | 67 +++++++++++++----
 .../text/lookup/DefaultStringLookupTest.java       |  1 +
 .../commons/text/lookup/DnsStringLookupTest.java   | 71 ++++++++++++++++++
 .../text/lookup/StringLookupFactoryTest.java       |  2 +
 10 files changed, 295 insertions(+), 17 deletions(-)

diff --cc src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java
index 693eedb,8fbf9b4..7cfc90b
--- a/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java
+++ b/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java
@@@ -592,10 -468,27 +605,25 @@@ public final class StringLookupFactory 
      }
  
      /**
+      * Returns the DnsStringLookup singleton instance where the lookup key is one of:
+      * <ul>
+      * <li><b>name</b>: for the local host name, for example {@code EXAMPLE} but also {@code EXAMPLE.apache.org}.</li>
+      * <li><b>canonical-name</b>: for the local canonical host name, for example {@code EXAMPLE.apache.org}.</li>
+      * <li><b>address</b>: for the local host address, for example {@code 192.168.56.1}.</li>
+      * </ul>
+      *
+      * @return the DateStringLookup singleton instance.
+      * @since 1.8
+      */
+     public StringLookup dnsStringLookup() {
+         return DnsStringLookup.INSTANCE;
+     }
+ 
+     /**
       * Returns a new map-based lookup where the request for a lookup is answered with the value for that key.
       *
 -     * @param <V>
 -     *            the map value type.
 -     * @param map
 -     *            the map.
 +     * @param <V> the map value type.
 +     * @param map the map.
       * @return a new MapStringLookup.
       */
      public <V> StringLookup mapStringLookup(final Map<String, V> map) {