Package org.apache.commons.text.lookup
Class FileStringLookup
java.lang.Object
org.apache.commons.text.lookup.AbstractStringLookup
org.apache.commons.text.lookup.AbstractPathFencedLookup
org.apache.commons.text.lookup.FileStringLookup
- All Implemented Interfaces:
Function<String,,String> UnaryOperator<String>,StringLookup
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 Summary
FieldsModifier and TypeFieldDescription(package private) static final AbstractStringLookupDefines the singleton for this class.Fields inherited from class org.apache.commons.text.lookup.AbstractPathFencedLookup
fenceFields inherited from class org.apache.commons.text.lookup.AbstractStringLookup
SPLIT_CH, SPLIT_STR -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.commons.text.lookup.AbstractPathFencedLookup
getPathMethods inherited from class org.apache.commons.text.lookup.AbstractStringLookup
substringAfter, substringAfter, substringAfterLast, toLookupKey, toLookupKeyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.text.lookup.StringLookup
apply
-
Field Details
-
INSTANCE
Defines the singleton for this class.
-
-
Constructor Details
-
FileStringLookup
FileStringLookup(Path... fences) Constructs a new instance.- Parameters:
fences- The fences guarding Path resolution.
-
-
Method Details
-
lookup
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.
-