use of org.apache.oro.text.regex.Perl5Substitution in project tdi-studio-se by Talend.
the class DataMapExpressionParser method addTablePrefixToColumnName.
public String addTablePrefixToColumnName(String expression, TableEntryLocation[] locations) {
String returnedExpression = expression;
for (TableEntryLocation location : locations) {
recompilePatternIfNecessary(StringHelper.replacePrms(language.getSubstPatternForPrefixColumnName(), new Object[] { location.tableName, location.columnName }));
if (returnedExpression != null) {
matcher.setMultiline(true);
Perl5Substitution substitution = new Perl5Substitution(//$NON-NLS-1$
language.getPrefixTableRegexp() + "$1" + language.getPrefixFieldRegexp() + "$1__$2" + language.getSuffixFieldRegexp(), //$NON-NLS-1$
Perl5Substitution.INTERPOLATE_ALL);
returnedExpression = Util.substitute(matcher, pattern, substitution, returnedExpression, Util.SUBSTITUTE_ALL);
}
}
return returnedExpression;
}
use of org.apache.oro.text.regex.Perl5Substitution in project tdi-studio-se by Talend.
the class ReplaceRunJobLabelVariableMigrationTask method replaceValue.
private boolean replaceValue(NodeType node, boolean replace) {
if (node == null) {
return false;
}
//$NON-NLS-1$
ElementParameterType param = ComponentUtilities.getNodeProperty(node, "LABEL");
if (param != null && param.getField().equals(EParameterFieldType.TEXT.getName())) {
String value = param.getValue();
if (value != null) {
PatternCompiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
try {
Pattern pattern = compiler.compile(//$NON-NLS-1$
"\\b(" + "__PROCESS_TYPE_PROCESS__" + //$NON-NLS-1$ //$NON-NLS-2$
")(\\b)");
if (matcher.contains(value, pattern)) {
if (replace) {
// replace
Perl5Substitution substitution = new //$NON-NLS-1$ //$NON-NLS-2$
Perl5Substitution(//$NON-NLS-1$ //$NON-NLS-2$
"__PROCESS__" + "$2", Perl5Substitution.INTERPOLATE_ALL);
String newValue = Util.substitute(matcher, pattern, substitution, value, Util.SUBSTITUTE_ALL);
param.setValue(newValue);
}
return true;
}
} catch (MalformedPatternException e) {
//
}
}
}
return false;
}
use of org.apache.oro.text.regex.Perl5Substitution in project tdi-studio-se by Talend.
the class MapExpressionParser method replaceLocation.
public String replaceLocation(String expression, String tempPattern, String sub) {
String returnedExpression = expression;
recompilePatternIfNecessary(tempPattern);
if (returnedExpression != null) {
matcher.setMultiline(true);
Perl5Substitution substitution = new Perl5Substitution(sub);
returnedExpression = substitute(matcher, pattern, substitution, returnedExpression, Util.SUBSTITUTE_ALL);
}
return returnedExpression;
}
Aggregations