use of org.apache.commons.lang3.text.StrSubstitutor in project solr-cmd-utils by tblsoft.
the class AbstractFilter method getProperty.
public String getProperty(String name, String defaultValue) {
if (filter.getProperty() == null) {
return defaultValue;
}
String value = (String) filter.getProperty().get(name);
if (value != null) {
StrSubstitutor strSubstitutor = new StrSubstitutor(variables);
value = strSubstitutor.replace(value);
return value;
}
return defaultValue;
}
use of org.apache.commons.lang3.text.StrSubstitutor in project solr-cmd-utils by tblsoft.
the class AbstractReader method getProperty.
public String getProperty(String name, String defaultValue) {
String value = (String) reader.getProperty().get(name);
if (value != null) {
StrSubstitutor strSubstitutor = new StrSubstitutor(variables);
value = strSubstitutor.replace(value);
return value;
}
return defaultValue;
}
use of org.apache.commons.lang3.text.StrSubstitutor in project solr-cmd-utils by tblsoft.
the class FieldJoiner method document.
@Override
public void document(Document document) {
Map<String, String> documentMap = new HashMap<String, String>();
for (Field field : document.getFields()) {
documentMap.put(field.getName(), field.getValue());
}
StrSubstitutor sub = new StrSubstitutor(documentMap);
String value = sub.replace(output);
document.addField(outputField, value);
super.document(document);
}
use of org.apache.commons.lang3.text.StrSubstitutor in project solr-cmd-utils by tblsoft.
the class MappingFilter method document.
@Override
public void document(Document document) {
Document mappedDocument;
if (!appendFields) {
mappedDocument = new Document();
} else {
mappedDocument = new Document();
mappedDocument.getFields().addAll(document.getFields());
}
for (Field f : document.getFields()) {
List<String> mappedNameList = mapping.get(f.getName());
if (mappedNameList == null) {
continue;
}
for (String mappedName : mappedNameList) {
List<String> mappedFunctions = mappingFunctions.get(mappedName);
if (!Strings.isNullOrEmpty(mappedName)) {
List<String> newValues = new ArrayList<String>();
for (String value : f.getValues()) {
String newValue = value;
for (String function : mappedFunctions) {
newValue = simpleMapping.executeFunction(function, newValue);
}
newValues.add(newValue);
}
mappedDocument.addField(mappedName, newValues);
Field mappedField = mappedDocument.getField(mappedName);
for (String function : mappedFunctions) {
simpleMapping.executeFieldFunction(function, mappedField);
}
}
}
}
for (Map.Entry<String, String> entry : joins.entrySet()) {
Map<String, String> documentMap = new HashMap<String, String>();
for (Field field : document.getFields()) {
documentMap.put(field.getName(), field.getValue());
}
StrSubstitutor sub = new StrSubstitutor(documentMap);
String value = sub.replace(entry.getValue());
mappedDocument.addField(entry.getKey(), value);
}
if (mappedDocument.getFields().size() != 0) {
addMissingFields(mappedDocument);
sortFieldsByName(mappedDocument);
super.document(mappedDocument);
}
}
use of org.apache.commons.lang3.text.StrSubstitutor in project fabric8 by fabric8io.
the class Support method createStrSubstitutor.
public static StrSubstitutor createStrSubstitutor(String prefix, String suffix, StrLookup<String> lookup) {
StrSubstitutor substitutor = new StrSubstitutor();
substitutor.setEnableSubstitutionInVariables(true);
substitutor.setVariablePrefix(prefix);
substitutor.setVariableSuffix(suffix);
substitutor.setVariableResolver(lookup);
return substitutor;
}
Aggregations