Search in sources :

Example 51 with Matcher

use of java.util.regex.Matcher in project elasticsearch by elastic.

the class KoelnerPhonetik method getVariations.

private List<String> getVariations(String str) {
    int position = 0;
    List<String> variations = new ArrayList<>();
    variations.add("");
    while (position < str.length()) {
        int i = 0;
        int substPos = -1;
        while (substPos < position && i < getPatterns().length) {
            Matcher m = variationsPatterns[i].matcher(str);
            while (substPos < position && m.find()) {
                substPos = m.start();
            }
            i++;
        }
        if (substPos >= position) {
            i--;
            List<String> varNew = new ArrayList<>();
            String prevPart = str.substring(position, substPos);
            for (int ii = 0; ii < variations.size(); ii++) {
                String tmp = variations.get(ii);
                varNew.add(tmp.concat(prevPart + getReplacements()[i]));
                variations.set(ii, variations.get(ii) + prevPart + getPatterns()[i]);
            }
            variations.addAll(varNew);
            position = substPos + getPatterns()[i].length();
        } else {
            for (int ii = 0; ii < variations.size(); ii++) {
                variations.set(ii, variations.get(ii) + str.substring(position, str.length()));
            }
            position = str.length();
        }
    }
    return variations;
}
Also used : Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList)

Example 52 with Matcher

use of java.util.regex.Matcher in project che by eclipse.

the class TestExtensionManagerGenerator method matchExtensions.

/**
     * Checks that Extension Pattern matches or not @Extension annotations
     *
     * @param strings
     *         the collection of strings to test
     * @param expected
     *         expected result
     */
protected void matchExtensions(List<String> strings, boolean expected) {
    for (String matchingString : strings) {
        Matcher matcher = ExtensionManagerGenerator.EXT_PATTERN.matcher(matchingString);
        assertEquals(matcher.matches(), expected);
    }
}
Also used : Matcher(java.util.regex.Matcher)

Example 53 with Matcher

use of java.util.regex.Matcher in project che by eclipse.

the class TestGeneratorUtils method shouldMatchPackage.

/** Should match package name */
@Test
public void shouldMatchPackage() {
    String packageString = "package org.eclipse.che.ide.util;" + "import junit.framework.Assert;";
    Matcher matcher = GeneratorUtils.PACKAGE_PATTERN.matcher(packageString);
    assertTrue(matcher.matches());
    assertEquals(matcher.groupCount(), 1);
    String group = matcher.group(1);
    assertEquals(group, "org.eclipse.che.ide.util");
}
Also used : Matcher(java.util.regex.Matcher) Test(org.testng.annotations.Test)

Example 54 with Matcher

use of java.util.regex.Matcher in project che by eclipse.

the class GdbBreak method parse.

/**
     * Factory method.
     */
public static GdbBreak parse(GdbOutput gdbOutput) throws GdbParseException {
    String output = gdbOutput.getOutput();
    Matcher matcher = GDB_BREAK.matcher(output);
    if (matcher.find()) {
        String address = matcher.group(2);
        String file = matcher.group(3);
        String lineNumber = matcher.group(4);
        return new GdbBreak(address, file, lineNumber);
    }
    throw new GdbParseException(GdbBreak.class, output);
}
Also used : Matcher(java.util.regex.Matcher) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 55 with Matcher

use of java.util.regex.Matcher in project che by eclipse.

the class GdbClear method parse.

/**
     * Factory method.
     */
public static GdbClear parse(GdbOutput gdbOutput) throws GdbParseException {
    String output = gdbOutput.getOutput();
    Matcher matcher = GDB_CLEAR.matcher(output);
    if (matcher.find()) {
        return new GdbClear();
    }
    throw new GdbParseException(GdbClear.class, output);
}
Also used : Matcher(java.util.regex.Matcher) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Aggregations

Matcher (java.util.regex.Matcher)12473 Pattern (java.util.regex.Pattern)5010 ArrayList (java.util.ArrayList)1516 IOException (java.io.IOException)904 HashMap (java.util.HashMap)565 File (java.io.File)487 Test (org.junit.Test)442 BufferedReader (java.io.BufferedReader)428 Map (java.util.Map)363 List (java.util.List)287 InputStreamReader (java.io.InputStreamReader)266 HashSet (java.util.HashSet)236 MalformedURLException (java.net.MalformedURLException)163 URL (java.net.URL)155 Date (java.util.Date)152 InputStream (java.io.InputStream)147 Field (java.lang.reflect.Field)130 PatternSyntaxException (java.util.regex.PatternSyntaxException)128 ParseException (java.text.ParseException)127 LinkedHashMap (java.util.LinkedHashMap)120