use of com.google.gwt.regexp.shared.MatchResult in project flow by vaadin.
the class DefaultConnectionStateHandler method xhrInvalidContent.
@Override
public void xhrInvalidContent(XhrConnectionError xhrConnectionError) {
debug("xhrInvalidContent");
endRequest();
String responseText = xhrConnectionError.getXhr().getResponseText();
/*
* A servlet filter or equivalent may have intercepted the request and
* served non-UIDL content (for instance, a login page if the session
* has expired.) If the response contains a magic substring, do a
* synchronous refresh. See #8241.
*/
MatchResult refreshToken = RegExp.compile(UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)").exec(responseText);
if (refreshToken != null) {
WidgetUtil.redirect(refreshToken.getGroup(2));
} else {
handleUnrecoverableCommunicationError("Invalid JSON response from server: " + responseText, xhrConnectionError);
}
}
use of com.google.gwt.regexp.shared.MatchResult in project ovirt-engine by oVirt.
the class FormatterJava method parse.
// Look for format specifiers in the format string.
private FormatString[] parse(String s) {
ArrayList<FormatString> al = new ArrayList<>();
while (s.length() > 0) {
MatchResult m = fsPattern.exec(s);
if (m != null) {
int i = m.getIndex();
if (i > 0) {
// Anything between the start of the string and the beginning
// of the format specifier is either fixed text or contains
// an invalid format string.
String staticText = s.substring(0, i);
// Make sure we didn't miss any invalid format specifiers
checkText(staticText);
// Assume previous characters were fixed text
al.add(new FixedString(staticText));
}
// Expect 6 groups in regular expression
String[] sa = new String[6];
for (int j = 1; j < m.getGroupCount(); j++) {
sa[j - 1] = m.getGroup(j);
// System.out.print(sa[j] + " ");
}
// System.out.println();
al.add(new FormatSpecifier(this, sa));
// trim parsed string
s = s.substring(i + m.getGroup(0).length(), s.length());
} else {
// No more valid format specifiers. Check for possible invalid
// format specifiers.
checkText(s);
// The rest of the string is fixed text
al.add(new FixedString(s));
break;
}
}
// System.out.println(((FormatString) al.get(j)).toString());
return al.toArray(new FormatString[0]);
}
use of com.google.gwt.regexp.shared.MatchResult in project perun by CESNET.
the class RegistrarFormItemGenerator method checkValueRegex.
protected boolean checkValueRegex() {
if (item.getRegex() != null && !("".equals(item.getRegex()))) {
// Compile and use regular expression
RegExp regExp = RegExp.compile(item.getRegex());
MatchResult matcher = regExp.exec(strValueBox.getValue());
// equivalent to regExp.test(inputStr);
boolean matchFound = (matcher != null);
if (!matchFound) {
String errorMessage = ApplicationMessages.INSTANCE.incorrectFormat();
// does a custom message exist?
ItemTexts it = item.getItemTexts(locale);
if (it != null) {
if (it.getErrorMessage() != null && !it.getErrorMessage().equals("")) {
errorMessage = it.getErrorMessage();
}
}
statusCellWrapper.setWidget(new FormInputStatusWidget(errorMessage, Status.ERROR));
return false;
}
}
return true;
}
Aggregations