use of com.google.gwt.regexp.shared.RegExp in project rstudio by rstudio.
the class NewConnectionSnippetHost method parseSnippet.
private ArrayList<NewConnectionSnippetParts> parseSnippet(String input) {
ArrayList<NewConnectionSnippetParts> parts = new ArrayList<NewConnectionSnippetParts>();
RegExp regExp = RegExp.compile(pattern_, "g");
for (MatchResult matcher = regExp.exec(input); matcher != null; matcher = regExp.exec(input)) {
if (matcher.getGroupCount() >= 2) {
int order = 0;
try {
order = Integer.parseInt(matcher.getGroup(1));
} catch (NumberFormatException e) {
}
String key = matcher.getGroup(2);
String value = matcher.getGroupCount() >= 4 ? matcher.getGroup(4) : null;
String connStringField = matcher.getGroupCount() >= 6 ? matcher.getGroup(6) : null;
if (value != null) {
value = value.replaceAll("\\$colon\\$", ":");
value = value.replaceAll("\\$equal\\$", "=");
}
parts.add(new NewConnectionSnippetParts(order, key, value, connStringField));
}
}
Collections.sort(parts, new Comparator<NewConnectionSnippetParts>() {
@Override
public int compare(NewConnectionSnippetParts p1, NewConnectionSnippetParts p2) {
return p1.getOrder() - p2.getOrder();
}
});
return parts;
}
use of com.google.gwt.regexp.shared.RegExp in project kie-wb-common by kiegroup.
the class AssignmentListItemWidgetTest method testInitWidget.
@Test
public void testInitWidget() {
widget.init();
verify(widget, times(1)).init();
verify(dataTypeComboBox, times(1)).init(widget, false, dataType, customDataType, false, true, AssignmentListItemWidgetView.CUSTOM_PROMPT, AssignmentListItemWidgetView.ENTER_TYPE_PROMPT);
verify(processVarComboBox, times(1)).init(widget, false, processVar, constant, true, true, AssignmentListItemWidgetView.CONSTANT_PROMPT, AssignmentListItemWidgetView.ENTER_CONSTANT_PROMPT);
verify(name, times(1)).setRegExp(regExpCaptor.capture(), anyString(), anyString());
RegExp regExp = RegExp.compile(regExpCaptor.getValue());
assertEquals(false, regExp.test("a 1"));
assertEquals(false, regExp.test("a@1"));
assertEquals(true, regExp.test("a1"));
verify(customDataType, times(1)).addKeyDownHandler(any(KeyDownHandler.class));
verify(name, times(1)).addBlurHandler(any(BlurHandler.class));
}
use of com.google.gwt.regexp.shared.RegExp in project kie-wb-common by kiegroup.
the class VariableListItemWidgetTest method testInitWidget.
@Test
public void testInitWidget() {
widget.init();
verify(widget, times(1)).init();
verify(dataTypeComboBox, times(1)).init(widget, true, dataType, customDataType, false, true, VariableListItemWidgetView.CUSTOM_PROMPT, VariableListItemWidgetView.ENTER_TYPE_PROMPT);
verify(name, times(1)).setRegExp(regExpCaptor.capture(), anyString(), anyString());
RegExp regExp = RegExp.compile(regExpCaptor.getValue());
assertEquals(false, regExp.test("a 1"));
assertEquals(false, regExp.test("a@1"));
assertEquals(true, regExp.test("a1"));
verify(customDataType, times(1)).addKeyDownHandler(any(KeyDownHandler.class));
verify(name, times(1)).addBlurHandler(any(BlurHandler.class));
}
use of com.google.gwt.regexp.shared.RegExp in project webprotege by protegeproject.
the class TextFieldEditor method validateInput.
private void validateInput() {
GWT.log("[TextFieldEditor] Validating input.");
GWT.log("[TextFieldEditor] Pattern: " + pattern);
if (pattern.isPresent()) {
RegExp regExp = RegExp.compile(pattern.get());
String value = editor.getText().trim();
GWT.log("[TextFieldEditor] Value: " + value);
MatchResult mr = regExp.exec(value);
GWT.log("[TextFieldEditor] Match: " + mr);
if (mr == null) {
GWT.log("[TextFieldEditor] Input is not valid");
if (patternViolationErrorMessage.isPresent()) {
editor.setTitle(patternViolationErrorMessage.get());
}
displayErrorBorder();
} else {
GWT.log("[TextFieldEditor] Input is valid");
clearErrorBorder();
}
}
}
use of com.google.gwt.regexp.shared.RegExp in project webprotege by protegeproject.
the class ItemTokenizer method parseTokens.
public List<ItemToken> parseTokens(String buffer) {
List<ItemToken> result = Lists.newArrayList();
RegExp regExp = RegExp.compile(REGEX);
List<String> tokens = getSeparatedTokens(buffer);
for (String token : tokens) {
MatchResult matchResult = regExp.exec(token);
if (matchResult != null) {
String type = matchResult.getGroup(TYPE_GROUP);
String content = matchResult.getGroup(CONTENT_GROUP);
result.add(new ItemToken(type, content));
}
}
return result;
}
Aggregations