Repository: commons-text Updated Branches: refs/heads/master 93e4a94f0 -> 2f9ba5529
[TEXT-113] Add an interpolator string lookup: StringLookupFactory#interpolatorStringLookup(). Better Javadoc. Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/2f9ba552 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/2f9ba552 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/2f9ba552 Branch: refs/heads/master Commit: 2f9ba552989497f0b8a87483666b7e31a1fa6d51 Parents: 93e4a94 Author: Gary Gregory <garydgreg...@gmail.com> Authored: Mon Feb 12 13:24:03 2018 -0700 Committer: Gary Gregory <garydgreg...@gmail.com> Committed: Mon Feb 12 13:24:03 2018 -0700 ---------------------------------------------------------------------- .../commons/text/lookup/DateStringLookup.java | 6 ++- .../text/lookup/InterpolatorStringLookup.java | 25 ++++++---- .../commons/text/lookup/MapStringLookup.java | 2 +- .../text/lookup/ResourceBundleStringLookup.java | 6 +++ .../text/lookup/StringLookupFactory.java | 48 +++++++++++++++++--- .../text/lookup/SystemPropertyStringLookup.java | 6 +-- 6 files changed, 73 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-text/blob/2f9ba552/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java b/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java index 513b113..cb4908a 100644 --- a/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java @@ -23,7 +23,8 @@ import java.util.Date; import org.apache.commons.lang3.time.FastDateFormat; /** - * Formats the current date or the date in the LogEvent. The "key" is used as the format String. + * Formats the current date with the format given in the key in a format compatible with + * {@link java.text.SimpleDateFormat}. */ final class DateStringLookup extends AbstractStringLookup { @@ -64,7 +65,8 @@ final class DateStringLookup extends AbstractStringLookup { } /** - * Looks up the value of the environment variable. + * Formats the current date with the format given in the key in a format compatible with + * {@link java.text.SimpleDateFormat}. * * @param key * the format to use. If null, the default {@link DateFormat} will be used. http://git-wip-us.apache.org/repos/asf/commons-text/blob/2f9ba552/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 1eddf43..0a7b1b2 100644 --- a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java @@ -22,6 +22,15 @@ import java.util.Map; /** * Proxies other {@link StringLookup}s using a keys within ${} markers using the format "${StringLookup:Key}". + * <p> + * The following lookups are used by default: + * </p> + * <ul> + * <li>"sys" for the {@link SystemPropertyStringLookup}.</li> + * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li> + * <li>"java" for the {@link JavaPlatformStringLookup}.</li> + * <li>"date" for the {@link DateStringLookup}.</li> + * </ul> */ class InterpolatorStringLookup extends AbstractStringLookup { @@ -40,10 +49,10 @@ class InterpolatorStringLookup extends AbstractStringLookup { * The following lookups are installed: * </p> * <ul> - * <li>"sys" for the SystemPropertyStringLookup.</li> - * <li>"env" for the EnvironmentVariableStringLookup.</li> - * <li>"java" for the JavaPlatformStringLookup.</li> - * <li>"date" for the DateStringLookup.</li> + * <li>"sys" for the {@link SystemPropertyStringLookup}.</li> + * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li> + * <li>"java" for the {@link JavaPlatformStringLookup}.</li> + * <li>"date" for the {@link DateStringLookup}.</li> * </ul> */ InterpolatorStringLookup() { @@ -56,10 +65,10 @@ class InterpolatorStringLookup extends AbstractStringLookup { * The following lookups are installed: * </p> * <ul> - * <li>"sys" for the SystemPropertyStringLookup.</li> - * <li>"env" for the EnvironmentVariableStringLookup.</li> - * <li>"java" for the JavaPlatformStringLookup.</li> - * <li>"date" for the DateStringLookup.</li> + * <li>"sys" for the {@link SystemPropertyStringLookup}.</li> + * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li> + * <li>"java" for the {@link JavaPlatformStringLookup}.</li> + * <li>"date" for the {@link DateStringLookup}.</li> * </ul> * * @param <V> http://git-wip-us.apache.org/repos/asf/commons-text/blob/2f9ba552/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 dedd77a..ecb57c6 100644 --- a/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/MapStringLookup.java @@ -19,7 +19,7 @@ package org.apache.commons.text.lookup; import java.util.Map; /** - * A map-based lookup. + * A map-based lookup where the request for a lookup is answered with the value for that key. * * @param <V> * A map's value type http://git-wip-us.apache.org/repos/asf/commons-text/blob/2f9ba552/src/main/java/org/apache/commons/text/lookup/ResourceBundleStringLookup.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/lookup/ResourceBundleStringLookup.java b/src/main/java/org/apache/commons/text/lookup/ResourceBundleStringLookup.java index 2ef3112..e5ae494 100644 --- a/src/main/java/org/apache/commons/text/lookup/ResourceBundleStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/ResourceBundleStringLookup.java @@ -21,6 +21,12 @@ import java.util.ResourceBundle; /** * Looks up keys from resource bundles. + * <p> + * Looks up the value for a given key in the format "BundleName:BundleKey". + * </p> + * <p> + * For example: "com.domain.messages:MyKey". + * </p> * * @see ResourceBundle * @since 1.3 http://git-wip-us.apache.org/repos/asf/commons-text/blob/2f9ba552/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java b/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java index b1f3700..ce63ba8 100644 --- a/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java +++ b/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java @@ -39,7 +39,8 @@ public final class StringLookupFactory { } /** - * Returns the DateStringLookup singleton instance. + * Returns the DateStringLookup singleton instance to format the current date with the format given in the key in a + * format compatible with {@link java.text.SimpleDateFormat}. * * @return the DateStringLookup singleton instance. */ @@ -58,6 +59,15 @@ public final class StringLookupFactory { /** * Returns a new InterpolatorStringLookup. + * <p> + * The following lookups are used by default: + * </p> + * <ul> + * <li>"sys" for the {@link SystemPropertyStringLookup}.</li> + * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li> + * <li>"java" for the {@link JavaPlatformStringLookup}.</li> + * <li>"date" for the {@link DateStringLookup}.</li> + * </ul> * * @return a new InterpolatorStringLookup. */ @@ -67,8 +77,18 @@ public final class StringLookupFactory { /** * Returns a new InterpolatorStringLookup. + * <p> + * The following lookups are used by default: + * </p> + * <ul> + * <li>"sys" for the {@link SystemPropertyStringLookup}.</li> + * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li> + * <li>"java" for the {@link JavaPlatformStringLookup}.</li> + * <li>"date" for the {@link DateStringLookup}.</li> + * </ul> * - * @param <V> the value type the default string lookup's map. + * @param <V> + * the value type the default string lookup's map. * @param map * the default map for string lookups. * @return a new InterpolatorStringLookup. @@ -79,6 +99,15 @@ public final class StringLookupFactory { /** * Returns a new InterpolatorStringLookup. + * <p> + * The following lookups are used by default: + * </p> + * <ul> + * <li>"sys" for the {@link SystemPropertyStringLookup}.</li> + * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li> + * <li>"java" for the {@link JavaPlatformStringLookup}.</li> + * <li>"date" for the {@link DateStringLookup}.</li> + * </ul> * * @param defaultStringLookup * the default string lookup. @@ -98,9 +127,10 @@ public final class StringLookupFactory { } /** - * Returns a new MapStringLookup. + * 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 <V> + * the map value type. * @param map * the map. * @return a new MapStringLookup. @@ -110,7 +140,7 @@ public final class StringLookupFactory { } /** - * Returns the NullStringLookup singleton instance. + * Returns the NullStringLookup singleton instance which always returns null. * * @return the NullStringLookup singleton instance. */ @@ -120,6 +150,12 @@ public final class StringLookupFactory { /** * Returns the ResourceBundleStringLookup singleton instance. + * <p> + * Looks up the value for a given key in the format "BundleName:BundleKey". + * </p> + * <p> + * For example: "com.domain.messages:MyKey". + * </p> * * @return the ResourceBundleStringLookup singleton instance. */ @@ -128,7 +164,7 @@ public final class StringLookupFactory { } /** - * Returns the SystemPropertyStringLookup singleton instance. + * Returns the SystemPropertyStringLookup singleton instance where the key is a system property name. * * @return the SystemPropertyStringLookup singleton instance. */ http://git-wip-us.apache.org/repos/asf/commons-text/blob/2f9ba552/src/main/java/org/apache/commons/text/lookup/SystemPropertyStringLookup.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/lookup/SystemPropertyStringLookup.java b/src/main/java/org/apache/commons/text/lookup/SystemPropertyStringLookup.java index d0ed869..9d84da6 100644 --- a/src/main/java/org/apache/commons/text/lookup/SystemPropertyStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/SystemPropertyStringLookup.java @@ -17,7 +17,7 @@ package org.apache.commons.text.lookup; /** - * Looks up keys from system properties. + * Looks up keys from system properties where the key is a system property name. * * @since 1.3 */ @@ -36,10 +36,10 @@ final class SystemPropertyStringLookup extends AbstractStringLookup { } /** - * Looks up the value for the key from system properties. + * Looks up the value for the key from system properties where the key is a system property name. * * @param key - * the key to be looked up, may be null + * the key to be looked up where the key is a system property name, may be null * @return The value associated with the key. * @see System#getProperty(String) */