Package io.goobi.viewer.model.variables
Class VariableReplacer
java.lang.Object
io.goobi.viewer.model.variables.VariableReplacer
- Direct Known Subclasses:
NoopVariableReplacer
Replace variable expression denoted by
{variable-name} in strings. Possible variables are those listed in ReplacerVariables or
any SOLR fields (partially listed in SolrConstants). Values may be taken from configuration and/or solr-derived documents passed in
construction of the VariableReplacer instance
Variables may have more than one value, typically for multivalued metadata fields, for this reason, in general a list of replaced strings is
returned, with one element for each replacement value-
Constructor Summary
ConstructorsConstructorDescriptionVariableReplacer(Configuration configuration) Only replace configuration variablesVariableReplacer(Configuration config, StructElementStub anchor, StructElementStub topStruct, StructElementStub structElement, PhysicalElement page) Take variable values from the given config and structure elements.VariableReplacer(StructElementStub struct) Take variable values from global configuration and the given struct elementVariableReplacer(ViewManager viewManager) Take variable values from current struct element and page of the given navigationHelperSpecifically replace the variables defined in the given replacement map -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReplacement(String s, String value) Add a custom replacement variablede.intranda.metadata.multilanguage.IMetadataValuereplace(de.intranda.metadata.multilanguage.IMetadataValue value) return a newIMetadataValueobject with the replaced values of the given object as valuesde.intranda.metadata.multilanguage.Metadatareplace(de.intranda.metadata.multilanguage.Metadata metadata) return a newMetadataobject with the replaced values of the given metadata object as valuesReplace variables in the given template string.replaceAll(String template, String separator) Concatenate all returned strings ofreplace(String), separated by the given separatorreplaceFirst(String template) Return a single string which only uses the first replacement values for each variable if there is more than one
-
Constructor Details
-
VariableReplacer
Take variable values from current struct element and page of the given navigationHelper- Parameters:
viewManager-- Throws:
IndexUnreachableException
-
VariableReplacer
public VariableReplacer(Configuration config, StructElementStub anchor, StructElementStub topStruct, StructElementStub structElement, PhysicalElement page) Take variable values from the given config and structure elements. Any passed objects may be null, in which case the associated values won't be replaced- Parameters:
config-anchor-topStruct-structElement-page-
-
VariableReplacer
Specifically replace the variables defined in the given replacement map- Parameters:
replacementsMap-
-
VariableReplacer
Only replace configuration variables- Parameters:
configuration-
-
VariableReplacer
Take variable values from global configuration and the given struct element- Parameters:
struct-
-
-
Method Details
-
replace
Replace variables in the given template string. The first element in the returned list will use the first replacement value and so on- Parameters:
template-- Returns:
- A list of strings
-
replaceFirst
Return a single string which only uses the first replacement values for each variable if there is more than one- Parameters:
template-- Returns:
- the string with replaced variables
-
replaceAll
Concatenate all returned strings ofreplace(String), separated by the given separator- Parameters:
template-separator-- Returns:
- The concatenated strings with replaced variables
-
addReplacement
Add a custom replacement variable- Parameters:
s-value-
-
replace
public de.intranda.metadata.multilanguage.Metadata replace(de.intranda.metadata.multilanguage.Metadata metadata) return a newMetadataobject with the replaced values of the given metadata object as values- Parameters:
metadata-- Returns:
- a new metadata object
-
replace
public de.intranda.metadata.multilanguage.IMetadataValue replace(de.intranda.metadata.multilanguage.IMetadataValue value) return a newIMetadataValueobject with the replaced values of the given object as values- Parameters:
value-- Returns:
- a new IMetadata value
-