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;
}
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);
}
}
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");
}
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);
}
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);
}
Aggregations