Search in sources :

Example 6 with MalformedPatternException

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;
}
Also used : Perl5Compiler(org.apache.oro.text.regex.Perl5Compiler) Pattern(org.apache.oro.text.regex.Pattern) Perl5Matcher(org.apache.oro.text.regex.Perl5Matcher) MalformedPatternException(org.apache.oro.text.regex.MalformedPatternException)

Example 7 with MalformedPatternException

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);
}
Also used : Perl5Compiler(org.apache.oro.text.regex.Perl5Compiler) Pattern(org.apache.oro.text.regex.Pattern) Perl5Matcher(org.apache.oro.text.regex.Perl5Matcher) MalformedPatternException(org.apache.oro.text.regex.MalformedPatternException)

Example 8 with MalformedPatternException

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;
    }
}
Also used : Perl5Compiler(org.apache.oro.text.regex.Perl5Compiler) PatternCompiler(org.apache.oro.text.regex.PatternCompiler) Perl5Matcher(org.apache.oro.text.regex.Perl5Matcher) MalformedPatternException(org.apache.oro.text.regex.MalformedPatternException) PatternMatcher(org.apache.oro.text.regex.PatternMatcher)

Example 9 with MalformedPatternException

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;
}
Also used : Perl5Compiler(org.apache.oro.text.regex.Perl5Compiler) Pattern(org.apache.oro.text.regex.Pattern) Perl5Matcher(org.apache.oro.text.regex.Perl5Matcher) MalformedPatternException(org.apache.oro.text.regex.MalformedPatternException)

Example 10 with MalformedPatternException

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;
}
Also used : Perl5Compiler(org.apache.oro.text.regex.Perl5Compiler) Pattern(org.apache.oro.text.regex.Pattern) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) Perl5Matcher(org.apache.oro.text.regex.Perl5Matcher) MalformedPatternException(org.apache.oro.text.regex.MalformedPatternException)

Aggregations

MalformedPatternException (org.apache.oro.text.regex.MalformedPatternException)24 Perl5Compiler (org.apache.oro.text.regex.Perl5Compiler)22 Pattern (org.apache.oro.text.regex.Pattern)20 Perl5Matcher (org.apache.oro.text.regex.Perl5Matcher)19 PatternCompiler (org.apache.oro.text.regex.PatternCompiler)8 PatternMatcher (org.apache.oro.text.regex.PatternMatcher)5 IOException (java.io.IOException)3 MatchResult (org.apache.oro.text.regex.MatchResult)3 Perl5Substitution (org.apache.oro.text.regex.Perl5Substitution)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 BufferedReader (java.io.BufferedReader)2 EOFException (java.io.EOFException)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStreamReader (java.io.InputStreamReader)2 MalformedURLException (java.net.MalformedURLException)2 Charset (java.nio.charset.Charset)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2