use of org.apache.oro.text.regex.Perl5Matcher 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.Perl5Matcher 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.Perl5Matcher 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.Perl5Matcher 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;
}
use of org.apache.oro.text.regex.Perl5Matcher in project tdi-studio-se by Talend.
the class VarsTable method validateColumnName.
/**
*
* DOC amaumont Comment method "validateColumnName".
*
* @param columnName
* @return true if columnName has a valid value
*/
public String validateColumnName(String columnName, int beanPosition) {
if (columnName == null) {
//$NON-NLS-1$
return Messages.getString("VarsTable.columnNameIsNull");
}
Pattern validPatternColumnNameRegexp = null;
if (validPatternColumnNameRegexp == null) {
try {
validPatternColumnNameRegexp = COMPILER.compile(VALID_PATTERN_COLUMN_NAME);
} catch (MalformedPatternException e) {
throw new RuntimeException(e);
}
}
Perl5Matcher matcher = new Perl5Matcher();
boolean match = matcher.matches(columnName, validPatternColumnNameRegexp);
// System.out.println(columnName + " -> "+ match);
if (!match) {
//$NON-NLS-1$ //$NON-NLS-2$
return Messages.getString("VarsTable.columnNameTip") + columnName + Messages.getString("VarsTable.invalidTip");
}
int lstSize = dataMapTableEntries.size();
for (int i = 0; i < lstSize; i++) {
if (columnName.equals(dataMapTableEntries.get(i).getName()) && i != beanPosition) {
//$NON-NLS-1$ //$NON-NLS-2$
return Messages.getString("VarsTable.columnNameTip") + columnName + Messages.getString("VarsTable.existTip");
}
}
return null;
}
Aggregations