use of org.apache.oro.text.regex.MalformedPatternException in project tdi-studio-se by Talend.
the class VirtualRowGeneratorNode method valueContains.
// add for bug 9471
private boolean valueContains(String value, String toTest) {
if (value.contains(toTest)) {
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern;
try {
//$NON-NLS-1$ //$NON-NLS-2$
pattern = compiler.compile("\\b(" + UpdateContextVariablesHelper.replaceSpecialChar(toTest) + ")(\\b|\\_)");
if (matcher.contains(value, pattern)) {
return true;
}
} catch (MalformedPatternException e) {
throw new RuntimeException(e);
}
}
return false;
}
use of org.apache.oro.text.regex.MalformedPatternException in project tdi-studio-se by Talend.
the class ConnectionAddUniqueNameMigrationTask method checkValidConnectionName.
public boolean checkValidConnectionName(String connectionName) {
if (checkIgnoreCase(connectionName)) {
return false;
}
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern;
try {
//$NON-NLS-1$
pattern = compiler.compile("^[A-Za-z_][A-Za-z0-9_]*$");
if (!matcher.matches(connectionName, pattern)) {
return false;
}
} catch (MalformedPatternException e) {
throw new RuntimeException(e);
}
return !KeywordsValidator.isKeyword(connectionName);
}
use of org.apache.oro.text.regex.MalformedPatternException in project tdi-studio-se by Talend.
the class NodeQueryCheckUtil method apacheRegexMatch.
/**
* See bug 5836. java.util.regex works too slow here. Use apache oro regex library instead.
* <p>
* DOC xye Comment method "apacheRegexMatch".
*
* @param patternString
* @param flag
* @param input
* @return
*/
private static boolean apacheRegexMatch(final String patternString, final int flag, final String input) {
PatternCompiler pc = new Perl5Compiler();
org.apache.oro.text.regex.Pattern pattern = null;
try {
pattern = pc.compile(patternString, flag);
PatternMatcher columnMatcher = new Perl5Matcher();
return columnMatcher.matches(input, pattern);
} catch (MalformedPatternException e) {
return false;
}
}
use of org.apache.oro.text.regex.MalformedPatternException in project tdi-studio-se by Talend.
the class DowngradeParameterHelper method hasParent.
/*
* check the parent form name
*/
private static boolean hasParent(final String name, final String parent) {
if (name == null) {
return false;
}
if (parent != null) {
final String parentExp = parent + COLON;
if (name.contains(parentExp)) {
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern;
try {
//$NON-NLS-1$ //$NON-NLS-2$
pattern = compiler.compile("\\b(" + parentExp + ")\\b");
if (matcher.contains(name, pattern)) {
return true;
}
} catch (MalformedPatternException e) {
//
}
}
}
return false;
}
use of org.apache.oro.text.regex.MalformedPatternException in project tdi-studio-se by Talend.
the class VarsTable method checkValidColumnName.
/**
* Check if the given name will be unique in the process. If another link already exists with that name, false will
* be returned.
*
* @param uniqueName
* @return true if the name is unique
*/
public boolean checkValidColumnName(String connectionName) {
for (ITableEntry entry : dataMapTableEntries) {
if (entry.getName().equals(connectionName)) {
return false;
}
}
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern;
try {
//$NON-NLS-1$
pattern = compiler.compile("^[A-Za-z_][A-Za-z0-9_]*$");
if (!matcher.matches(connectionName, pattern)) {
return false;
}
} catch (MalformedPatternException e) {
throw new RuntimeException(e);
}
return true;
}
Aggregations