Package org.apache.commons.text.lookup

## Class StringLookupFactory

- java.lang.Object
- - org.apache.commons.text.lookup.StringLookupFactory

-     public final class StringLookupFactory
      extends Object

  Provides access to lookups defined in this package.
  Since:
    1.3

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static StringLookupFactory` | `INSTANCE` | Defines the singleton for this class.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addDefaultStringLookups​(Map<String,StringLookup> stringLookupMap)` | The following lookups are installed: "sys" for the `SystemPropertyStringLookup`. "env" for the `EnvironmentVariableStringLookup`. "java" for the `JavaPlatformStringLookup`. "date" for the `DateStringLookup`. "localhost" for the `LocalHostStringLookup` since 1.3. "xml" for the `XmlStringLookup` since 1.5. "properties" for the `PropertiesStringLookup` since 1.5. "script" for the `ScriptStringLookup` since 1.5. "file" for the `FileStringLookup` since 1.5. "url" for the `UrlStringLookup` since 1.5. "base64" for the `Base64StringLookup` since 1.5. "urlEncode" for the `UrlEncoderStringLookup` since 1.5. "urlDecode" for the `UrlDecoderStringLookup` since 1.5. "const" for the `ConstantStringLookup` since 1.5.
    `StringLookup` | `base64StringLookup()` | Returns the DateStringLookup singleton instance to format the current date with the format given in the key in a format compatible with `SimpleDateFormat`.
    `static void` | `clear()` | Clears any static resources.
    `StringLookup` | `constantStringLookup()` | Returns the ConstantStringLookup singleton instance to get the value of a fully-qualified static final value.
    `StringLookup` | `dateStringLookup()` | Returns the DateStringLookup singleton instance to format the current date with the format given in the key in a format compatible with `SimpleDateFormat`.
    `StringLookup` | `environmentVariableStringLookup()` | Returns the EnvironmentVariableStringLookup singleton instance where the lookup key is an environment variable name.
    `StringLookup` | `fileStringLookup()` | Returns the FileStringLookup singleton instance.
    `StringLookup` | `interpolatorStringLookup()` | Returns a new InterpolatorStringLookup.
    `StringLookup` | `interpolatorStringLookup​(Map<String,StringLookup> stringLookupMap, StringLookup defaultStringLookup, boolean addDefaultLookups)` | Returns a new InterpolatorStringLookup.
    `<V> StringLookup` | `interpolatorStringLookup​(Map<String,V> map)` | Returns a new InterpolatorStringLookup.
    `StringLookup` | `interpolatorStringLookup​(StringLookup defaultStringLookup)` | Returns a new InterpolatorStringLookup.
    `StringLookup` | `javaPlatformStringLookup()` | Returns the JavaPlatformStringLookup singleton instance.
    `StringLookup` | `localHostStringLookup()` | Returns the LocalHostStringLookup singleton instance where the lookup key is one of: name: for the local host name, for example `EXAMPLE`. canonical-name: for the local canonical host name, for example `EXAMPLE.apache.org`. address: for the local host address, for example `192.168.56.1`.
    `<V> StringLookup` | `mapStringLookup​(Map<String,V> map)` | Returns a new map-based lookup where the request for a lookup is answered with the value for that key.
    `StringLookup` | `nullStringLookup()` | Returns the NullStringLookup singleton instance which always returns null.
    `StringLookup` | `propertiesStringLookup()` | Returns the PropertiesStringLookup singleton instance.
    `StringLookup` | `resourceBundleStringLookup()` | Returns the ResourceBundleStringLookup singleton instance.
    `StringLookup` | `resourceBundleStringLookup​(String bundleName)` | Returns a ResourceBundleStringLookup instance for the given bundle name.
    `StringLookup` | `scriptStringLookup()` | Returns the ScriptStringLookup singleton instance.
    `StringLookup` | `systemPropertyStringLookup()` | Returns the SystemPropertyStringLookup singleton instance where the lookup key is a system property name.
    `StringLookup` | `urlStringLookup()` | Returns the UrlStringLookup singleton instance.
    `StringLookup` | `xmlStringLookup()` | Returns the XmlStringLookup singleton instance.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INSTANCE

          public static final StringLookupFactory INSTANCE

      Defines the singleton for this class.

  - ### Method Detail

    - #### clear

          public static void clear()

      Clears any static resources.
      Since:
        1.5

    - #### addDefaultStringLookups

          public void addDefaultStringLookups​(Map<String,StringLookup> stringLookupMap)

      The following lookups are installed:
      - "sys" for the `SystemPropertyStringLookup`.
      - "env" for the `EnvironmentVariableStringLookup`.
      - "java" for the `JavaPlatformStringLookup`.
      - "date" for the `DateStringLookup`.
      - "localhost" for the `LocalHostStringLookup` since 1.3.
      - "xml" for the `XmlStringLookup` since 1.5.
      - "properties" for the `PropertiesStringLookup` since 1.5.
      - "script" for the `ScriptStringLookup` since 1.5.
      - "file" for the `FileStringLookup` since 1.5.
      - "url" for the `UrlStringLookup` since 1.5.
      - "base64" for the `Base64StringLookup` since 1.5.
      - "urlEncode" for the `UrlEncoderStringLookup` since 1.5.
      - "urlDecode" for the `UrlDecoderStringLookup` since 1.5.
      - "const" for the `ConstantStringLookup` since 1.5.
      Parameters:
        `stringLookupMap` - the map of string lookups.
      Since:
        1.5

    - #### base64StringLookup

          public StringLookup base64StringLookup()

      Returns the DateStringLookup singleton instance to format the current date with the format given in the key in a format compatible with `SimpleDateFormat`.
      Returns:
        the DateStringLookup singleton instance.

    - #### constantStringLookup

          public StringLookup constantStringLookup()

      Returns the ConstantStringLookup singleton instance to get the value of a fully-qualified static final value.
      Returns:
        the DateStringLookup singleton instance.
      Since:
        1.5

    - #### dateStringLookup

          public StringLookup dateStringLookup()

      Returns the DateStringLookup singleton instance to format the current date with the format given in the key in a format compatible with `SimpleDateFormat`.
      Returns:
        the DateStringLookup singleton instance.

    - #### environmentVariableStringLookup

          public StringLookup environmentVariableStringLookup()

      Returns the EnvironmentVariableStringLookup singleton instance where the lookup key is an environment variable name.
      Returns:
        the EnvironmentVariableStringLookup singleton instance.

    - #### fileStringLookup

          public StringLookup fileStringLookup()

      Returns the FileStringLookup singleton instance.

      Looks up the value for the key in the format "CharsetName:Path".

      For example: "UTF-8:com/domain/document.properties".

      Returns:
        the FileStringLookup singleton instance.
      Since:
        1.5

    - #### interpolatorStringLookup

          public StringLookup interpolatorStringLookup()

      Returns a new InterpolatorStringLookup.

      The following lookups are used by default:

      - "sys" for the `SystemPropertyStringLookup`.
      - "env" for the `EnvironmentVariableStringLookup`.
      - "java" for the `JavaPlatformStringLookup`.
      - "date" for the `DateStringLookup`.
      - "localhost" for the `LocalHostStringLookup`, see `localHostStringLookup()` for key names; since 1.3.
      - "xml" for the `XmlStringLookup` since 1.5.
      - "properties" for the `PropertiesStringLookup` since 1.5.
      - "script" for the `ScriptStringLookup` since 1.5.
      - "file" for the `FileStringLookup` since 1.5.
      - "url" for the `UrlStringLookup` since 1.5.
      - "base64" for the `Base64StringLookup` since 1.5.
      - "urlEncode" for the `UrlEncoderStringLookup` since 1.5.
      - "urlDecode" for the `UrlDecoderStringLookup` since 1.5.
      - "const" for the `ConstantStringLookup` since 1.5.
      Returns:
        a new InterpolatorStringLookup.

    - #### interpolatorStringLookup

          public StringLookup interpolatorStringLookup​(Map<String,StringLookup> stringLookupMap,
                                                       StringLookup defaultStringLookup,
                                                       boolean addDefaultLookups)

      Returns a new InterpolatorStringLookup.

      If `addDefaultLookups` is true, the following lookups are used in addition to the ones provided in `stringLookupMap`:

      - "sys" for the `SystemPropertyStringLookup`.
      - "env" for the `EnvironmentVariableStringLookup`.
      - "java" for the `JavaPlatformStringLookup`.
      - "date" for the `DateStringLookup`.
      - "localhost" for the `LocalHostStringLookup`, see `localHostStringLookup()` for key names; since 1.3.
      - "xml" for the `XmlStringLookup` since 1.5.
      - "properties" for the `PropertiesStringLookup` since 1.5.
      - "script" for the `ScriptStringLookup` since 1.5.
      - "file" for the `FileStringLookup` since 1.5.
      - "url" for the `UrlStringLookup` since 1.5.
      - "base64" for the `Base64StringLookup` since 1.5.
      - "urlEncode" for the `UrlEncoderStringLookup` since 1.5.
      - "urlDecode" for the `UrlDecoderStringLookup` since 1.5.
      - "const" for the `ConstantStringLookup` since 1.5.
      Parameters:
        `stringLookupMap` - the map of string lookups.
        `defaultStringLookup` - the default string lookup.
        `addDefaultLookups` - whether to use lookups as described above.
      Returns:
        a new InterpolatorStringLookup.
      Since:
        1.4

    - #### interpolatorStringLookup

          public <V> StringLookup interpolatorStringLookup​(Map<String,V> map)

      Returns a new InterpolatorStringLookup.

      The following lookups are used by default:

      - "sys" for the `SystemPropertyStringLookup`.
      - "env" for the `EnvironmentVariableStringLookup`.
      - "java" for the `JavaPlatformStringLookup`.
      - "date" for the `DateStringLookup`.
      - "localhost" for the `LocalHostStringLookup`, see `localHostStringLookup()` for key names; since 1.3.
      - "xml" for the `XmlStringLookup` since 1.5.
      - "properties" for the `PropertiesStringLookup` since 1.5.
      - "script" for the `ScriptStringLookup` since 1.5.
      - "file" for the `FileStringLookup` since 1.5.
      - "url" for the `UrlStringLookup` since 1.5.
      - "base64" for the `Base64StringLookup` since 1.5.
      - "urlEncode" for the `UrlEncoderStringLookup` since 1.5.
      - "urlDecode" for the `UrlDecoderStringLookup` since 1.5.
      - "const" for the `ConstantStringLookup` since 1.5.
      Type Parameters:
        `V` - the value type the default string lookup's map.
      Parameters:
        `map` - the default map for string lookups.
      Returns:
        a new InterpolatorStringLookup.

    - #### interpolatorStringLookup

          public StringLookup interpolatorStringLookup​(StringLookup defaultStringLookup)

      Returns a new InterpolatorStringLookup.

      The following lookups are used by default:

      - "sys" for the `SystemPropertyStringLookup`.
      - "env" for the `EnvironmentVariableStringLookup`.
      - "java" for the `JavaPlatformStringLookup`.
      - "date" for the `DateStringLookup`.
      - "localhost" for the `LocalHostStringLookup`, see `localHostStringLookup()` for key names; since 1.3.
      - "xml" for the `XmlStringLookup` since 1.5.
      - "properties" for the `PropertiesStringLookup` since 1.5.
      - "script" for the `ScriptStringLookup` since 1.5.
      - "file" for the `FileStringLookup` since 1.5.
      - "url" for the `UrlStringLookup` since 1.5.
      - "base64" for the `Base64StringLookup` since 1.5.
      - "urlEncode" for the `UrlEncoderStringLookup` since 1.5.
      - "urlDecode" for the `UrlDecoderStringLookup` since 1.5.
      - "const" for the `ConstantStringLookup` since 1.5.
      Parameters:
        `defaultStringLookup` - the default string lookup.
      Returns:
        a new InterpolatorStringLookup.

    - #### javaPlatformStringLookup

          public StringLookup javaPlatformStringLookup()

      Returns the JavaPlatformStringLookup singleton instance. Looks up keys related to Java: Java version, JRE version, VM version, and so on.

      The lookup keys with examples are:

      - version: "Java version 1.8.0_181"
      - runtime: "Java(TM) SE Runtime Environment (build 1.8.0_181-b13) from Oracle Corporation"
      - vm: "Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)"
      - os: "Windows 10 10.0, architecture: amd64-64"
      - hardware: "processors: 4, architecture: amd64-64, instruction sets: amd64"
      - locale: "default locale: en_US, platform encoding: iso-8859-1"
      Returns:
        the JavaPlatformStringLookup singleton instance.

    - #### localHostStringLookup

          public StringLookup localHostStringLookup()

      Returns the LocalHostStringLookup singleton instance where the lookup key is one of:
      - name: for the local host name, for example `EXAMPLE`.
      - canonical-name: for the local canonical host name, for example `EXAMPLE.apache.org`.
      - address: for the local host address, for example `192.168.56.1`.
      Returns:
        the DateStringLookup singleton instance.

    - #### mapStringLookup

          public <V> StringLookup mapStringLookup​(Map<String,V> map)

      Returns a new map-based lookup where the request for a lookup is answered with the value for that key.
      Type Parameters:
        `V` - the map value type.
      Parameters:
        `map` - the map.
      Returns:
        a new MapStringLookup.

    - #### nullStringLookup

          public StringLookup nullStringLookup()

      Returns the NullStringLookup singleton instance which always returns null.
      Returns:
        the NullStringLookup singleton instance.

    - #### propertiesStringLookup

          public StringLookup propertiesStringLookup()

      Returns the PropertiesStringLookup singleton instance.

      Looks up the value for the key in the format "DocumentPath:Key".

      For example: "com/domain/document.properties:Key".

      Returns:
        the PropertiesStringLookup singleton instance.
      Since:
        1.5

    - #### resourceBundleStringLookup

          public StringLookup resourceBundleStringLookup()

      Returns the ResourceBundleStringLookup singleton instance.

      Looks up the value for a given key in the format "BundleName:BundleKey".

      For example: "com.domain.messages:MyKey".

      Returns:
        the ResourceBundleStringLookup singleton instance.

    - #### resourceBundleStringLookup

          public StringLookup resourceBundleStringLookup​(String bundleName)

      Returns a ResourceBundleStringLookup instance for the given bundle name.

      Looks up the value for a given key in the format "BundleKey".

      For example: "MyKey".

      Parameters:
        `bundleName` - Only lookup in this bundle.
      Returns:
        a ResourceBundleStringLookup instance for the given bundle name.
      Since:
        1.5

    - #### scriptStringLookup

          public StringLookup scriptStringLookup()

      Returns the ScriptStringLookup singleton instance.

      Looks up the value for the key in the format "ScriptEngineName:Script".

      For example: "javascript:\"HelloWorld\"".

      Returns:
        the ScriptStringLookup singleton instance.
      Since:
        1.5

    - #### systemPropertyStringLookup

          public StringLookup systemPropertyStringLookup()

      Returns the SystemPropertyStringLookup singleton instance where the lookup key is a system property name.
      Returns:
        the SystemPropertyStringLookup singleton instance.

    - #### urlStringLookup

          public StringLookup urlStringLookup()

      Returns the UrlStringLookup singleton instance.

      Looks up the value for the key in the format "CharsetName:URL".

      For example, using the HTTP scheme: "UTF-8:http://www.google.com"

      For example, using the file scheme: "UTF-8:file:///C:/somehome/commons/commons-text/src/test/resources/document.properties"

      Returns:
        the UrlStringLookup singleton instance.
      Since:
        1.5

    - #### xmlStringLookup

          public StringLookup xmlStringLookup()

      Returns the XmlStringLookup singleton instance.

      Looks up the value for the key in the format "DocumentPath:XPath".

      For example: "com/domain/document.xml:/path/to/node".

      Returns:
        the XmlStringLookup singleton instance.
      Since:
        1.5

Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.