Class FileStringLookup

All Implemented Interfaces:
Function<String,String>, UnaryOperator<String>, StringLookup

final class FileStringLookup extends AbstractPathFencedLookup
Looks up file contents.

Using a StringLookup from the StringLookupFactory:

StringLookupFactory.INSTANCE.fileStringLookup().lookup("UTF-8:com/domain/document.properties");

The above example converts "UTF-8:com/domain/document.properties" to the UTF-8 contents of the file at com/domain/document.properties.

Using a StringSubstitutor:

StringSubstitutor.createInterpolator().replace("... ${file:UTF-8:com/domain/document.properties} ..."));

The above example converts "UTF-8:SomePath" to the UTF-8 contents of the file at SomePath.

Public access is through StringLookupFactory.

Since:
1.5
See Also:
  • Field Details

  • Constructor Details

    • FileStringLookup

      FileStringLookup(Path... fences)
      Constructs a new instance.
      Parameters:
      fences - The fences guarding Path resolution.
  • Method Details

    • lookup

      public String lookup(String key)
      Looks up the value for the key in the format "charsetName:DocumentPath".

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

      Parameters:
      key - the key to be looked up, may be null
      Returns:
      The value associated with the key.