Top Description Fields Constructors Methods
org.apache.commons.text.lookup

pack-priv final Class FileStringLookup

extends AbstractPathFencedLookup
Class Inheritance
Imports
java.nio.file.Files, .Path, org.apache.commons.lang3.StringUtils, org.apache.commons.text.StringSubstitutor

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
StringLookupFactory

Field Summary

Modifier and TypeField and Description
pack-priv static final AbstractStringLookup
INSTANCE

Defines the singleton for this class.

Inherited from org.apache.commons.text.lookup.AbstractPathFencedLookup:
fence

Constructor Summary

AccessConstructor and Description
pack-priv
FileStringLookup(final Path...
The fences guarding Path resolution.
fences
)

Constructs a new instance.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The value associated with the key.
lookup
(final String
the key to be looked up, may be null
key
)

Implements org.apache.commons.text.lookup.StringLookup.lookup.

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

Inherited from org.apache.commons.text.lookup.AbstractPathFencedLookup:
getPath

Field Detail

INSTANCEback to summary
pack-priv static final AbstractStringLookup INSTANCE

Defines the singleton for this class.

Constructor Detail

FileStringLookupback to summary
pack-priv FileStringLookup(final Path... fences)

Constructs a new instance.

Parameters
fences:Path[]

The fences guarding Path resolution.

Method Detail

lookupback to summary
public String lookup(final String key)

Implements org.apache.commons.text.lookup.StringLookup.lookup.

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

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

Parameters
key:String

the key to be looked up, may be null

Returns:String

The value associated with the key.

Annotations
@Override