com.google.gwt.regexp.shared.MatchResult Java Examples
The following examples show how to use
com.google.gwt.regexp.shared.MatchResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImportTreeDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
@Override protected void transformResponse(DSResponse response, DSRequest request, Object data) { if (RestConfig.isStatusOk(response)) { for (Record record : response.getData()) { String path = record.getAttribute(FIELD_PATH); RegExp pathRegExp = RegExp.compile("(.*/)?(.*)/$"); MatchResult mr = pathRegExp.exec(path); String parent = mr.getGroup(1); String name = mr.getGroup(2); // System.out.println("## ITRDS.path: " + path); // System.out.println("## ITRDS.parent: " + parent); // System.out.println("## ITRDS.name: " + name); record.setAttribute(FIELD_NAME, name); record.setAttribute(FIELD_PARENT, parent); } } super.transformResponse(response, request, data); }
Example #2
Source File: DefaultConnectionStateHandler.java From flow with Apache License 2.0 | 6 votes |
@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); } }
Example #3
Source File: CourseNumbersSuggestBox.java From unitime with Apache License 2.0 | 6 votes |
private String getConfiguration() { String conf = iConfiguration; for (MatchResult matcher = iRegExp.exec(conf); matcher != null; matcher = iRegExp.exec(conf)) { Element element = DOM.getElementById(matcher.getGroup(1)); String value = ""; if ("select".equalsIgnoreCase(element.getTagName())) { ListBox list = ListBox.wrap(element); for (int i = 0; i < list.getItemCount(); i++) { if (list.isItemSelected(i)) value += (value.isEmpty() ? "" : ",") + list.getValue(i); } } else if ("input".equalsIgnoreCase(element.getTagName())) { TextBox text = TextBox.wrap(element); value = text.getText(); } else { Hidden hidden = Hidden.wrap(element); value = hidden.getValue(); } conf = conf.replace("${" + matcher.getGroup(1) + "}", value); } return conf; }
Example #4
Source File: ActivemqMetricPresenter.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private List<PreparedTransaction> parseTransactions(List<ModelNode> transactions) { RegExp transactionPattern = RegExp.compile("^(.*) base64: ([^ ]*)"); List<PreparedTransaction> preparedTransactions = new ArrayList<>(); for(ModelNode t : transactions) { MatchResult match = transactionPattern.exec(t.asString()); if (match == null) { Console.error("Error parsing prepared transactions"); break; } preparedTransactions.add(new PreparedTransaction(match.getGroup(2), match.getGroup(1))); } return preparedTransactions; }
Example #5
Source File: AuditLogItemDataProvider.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private AuditLogItem parseItem(final MatchResult match) { String date = match.getGroup(1); AutoBean<AuditLogItem> itemBean = AutoBeanCodex.decode(beanFactory, AuditLogItem.class, match.getGroup(2)); AuditLogItem item = itemBean.as(); item.setId(idCounter++); item.setDate(date); return item; }
Example #6
Source File: AuditLogItemDataProvider.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseItems() { idCounter = 0; SplitResult result = ITEMS.split(RESOURCES.auditLog().getText()); for (int i = 0; i < result.length(); i++) { String nextResult = result.get(i); if (nextResult != null && nextResult.length() != 0) { String itemText = nextResult.trim() + "\n}"; MatchResult match = ITEM.exec(itemText); if (match != null) { store.add(parseItem(match)); } } } }
Example #7
Source File: AbstractTextRendererAspect.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void splitTokenAndAddEOL(List<Token<?>> tokenizedValue, List<Token<?>> resultTokenizedValue, Iterator<Token<?>> tokenIterator, int lastMatchEndIndex, MatchResult eolMatcher, Token<?> currToken) { Token<?> tonken = currToken; if (tonken.getTokenStart() == eolMatcher.getIndex()) { String eolStr = ""; // MultiChar EOL while (this.getTokenEnd(tonken) < lastMatchEndIndex) { eolStr += tonken.getText(); tonken = tokenIterator.next(); tokenIterator.remove(); } if (this.getTokenEnd(tonken) == lastMatchEndIndex) { eolStr += tonken.getText(); } else { eolStr += tonken.getText().substring(0, lastMatchEndIndex - tonken.getTokenStart()); // Nead to go out of the iterator (in the call) after because of // ConcurrentModificationException tokenizedValue.add(0, new SimpleToken<TokenContent>(lastMatchEndIndex, tonken.getText() .substring(lastMatchEndIndex - tonken.getTokenStart()), tonken.getContent())); } resultTokenizedValue.add(SimpleToken.createNewlineToken(eolMatcher.getIndex(), eolStr)); } else { // We extract the first part of token and recall the method to go on the first condition resultTokenizedValue.add(new SimpleToken<TokenContent>(tonken.getTokenStart(), tonken .getText().substring(0, lastMatchEndIndex - tonken.getTokenStart() - 1), tonken .getContent())); tonken = new SimpleToken<TokenContent>(eolMatcher.getIndex(), tonken.getText().substring( lastMatchEndIndex - tonken.getTokenStart() - 1), tonken.getContent()); this.splitTokenAndAddEOL(tokenizedValue, resultTokenizedValue, tokenIterator, lastMatchEndIndex, eolMatcher, tonken); } }
Example #8
Source File: AbstractTextRendererAspect.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private List<Token<?>> addEOLToken(String value, List<Token<?>> tokenList) { List<Token<?>> resultTokenList = Lists.newArrayList(); // add EOL Tokens RegExp regExp = RegExp.compile(CharacterUtil.END_OF_LINE_PATTERN, "g"); MatchResult eolMatcher = regExp.exec(value); while (eolMatcher != null) { for (Iterator<Token<?>> it = tokenList.iterator(); it.hasNext();) { Token<?> currToken = it.next(); if (currToken.getTokenStart() >= regExp.getLastIndex()) { // current token is after last EL match break; } if (this.getTokenEnd(currToken) <= eolMatcher.getIndex()) { // current token is before last EL match resultTokenList.add(currToken); it.remove(); } else { // current token contains last EOL match it.remove(); this.splitTokenAndAddEOL(tokenList, resultTokenList, it, regExp.getLastIndex(), eolMatcher, currToken); break; } } eolMatcher = regExp.exec(value); } resultTokenList.addAll(tokenList); return resultTokenList; }
Example #9
Source File: EmailValidator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected boolean isValid(String value) { if (value == null || value.length() == 0) { return true; } MatchResult match = EmailValidator.EMAIL_PATTERN.exec(value); if (match == null) { return false; } return match.getGroup(0).length() == value.length(); }
Example #10
Source File: PatternValidator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private boolean regExMatch(String value) { MatchResult match = this.pattern.exec(value); if (match == null) { return false; } return match.getGroup(0).length() == value.length(); }
Example #11
Source File: FilterBox.java From unitime with Apache License 2.0 | 5 votes |
private void parse(final List<Chip> chips, final String text, final Collection<Filter> filters, final AsyncCallback<Parser.Results> callback) { if (text.isEmpty()) { callback.onSuccess(new Parser.Results(text, chips)); } else { for (RegExp regExp: sRegExps) { final MatchResult r = regExp.exec(text); if (r == null) continue; for (Filter filter: filters) { if (filter.getCommand().equals(r.getGroup(1))) { filter.validate(r.getGroup(2), new AsyncCallback<Chip>() { @Override public void onFailure(Throwable caught) { callback.onSuccess(new Parser.Results(text, chips)); } @Override public void onSuccess(Chip result) { if (result == null) { callback.onSuccess(new Parser.Results(text, chips)); } else { chips.add(result); if (r.getGroupCount() > 3) { parse(chips, r.getGroup(3).trim(), filters, callback); } else { callback.onSuccess(new Parser.Results("", chips)); } } } }); return; } } } callback.onSuccess(new Parser.Results(text, chips)); } }
Example #12
Source File: ClassAssignmentInterface.java From unitime with Apache License 2.0 | 5 votes |
public float[] guessCreditRange() { if (!hasCredit()) return new float[] {0f, 0f}; MatchResult r = RegExp.compile("(\\d+\\.?\\d*)-(\\d+\\.?\\d*)").exec(getCreditAbbv()); if (r != null) return new float[] {Float.parseFloat(r.getGroup(1)), Float.parseFloat(r.getGroup(2))}; float credit = guessCreditCount(); return new float[] { credit, credit }; }
Example #13
Source File: UniTimeHeaderPanel.java From unitime with Apache License 2.0 | 4 votes |
public static String stripAccessKey(String name) { if (name == null || name.isEmpty()) return ""; MatchResult result = sStripAcessKeyRegExp.exec(name); return (result == null ? name : result.getGroup(1) + result.getGroup(2) + result.getGroup(3)); }
Example #14
Source File: EditRuleWidget.java From geofence with GNU General Public License v2.0 | 4 votes |
public boolean checkIpRange(String s) { if(s == null || s.trim().equals("")) return true; RegExp regExp = RegExp.compile(CIDR_FORMAT); MatchResult matcher = regExp.exec(s); boolean matchFound = (matcher != null); // equivalent to regExp.test(inputStr); if (! matchFound) { Dispatcher.forwardEvent(GeofenceEvents.SEND_ALERT_MESSAGE, new String[] { "Input error", "Bad Range format" }); return false; } // Get address bytes for (int i=1; i<5; i++) { String groupStr = matcher.getGroup(i); int b = Integer.parseInt(groupStr); if(b>255) { Dispatcher.forwardEvent(GeofenceEvents.SEND_ALERT_MESSAGE, new String[] { "Input error", "Range bytes should be 0..255" }); return false; } } int size = Integer.parseInt(matcher.getGroup(5)); if(size > 32) { Dispatcher.forwardEvent(GeofenceEvents.SEND_ALERT_MESSAGE, new String[] { "Input error", "Bad CIDR block size" }); return false; } return true; }
Example #15
Source File: UniTimeHeaderPanel.java From unitime with Apache License 2.0 | 4 votes |
public static Character guessAccessKey(String name) { if (name == null || name.isEmpty()) return null; MatchResult result = sAcessKeyRegExp.exec(name); return (result == null ? null : result.getGroup(1).toLowerCase().charAt(0)); }
Example #16
Source File: AriaTabBar.java From unitime with Apache License 2.0 | 4 votes |
public String getTabLabel(int index) { String html = getTabHTML(index); if (html == null || html.isEmpty()) return ""; MatchResult result = sStripAcessKeyRegExp.exec(html); return (result == null ? html : result.getGroup(1) + result.getGroup(2) + result.getGroup(3)); }
Example #17
Source File: ClassAssignmentInterface.java From unitime with Apache License 2.0 | 4 votes |
public float guessCreditCount() { if (!hasCredit()) return 0f; MatchResult m = RegExp.compile("\\d+\\.?\\d*").exec(getCredit()); if (m != null) return Float.parseFloat(m.getGroup(0)); return 0f; }
Example #18
Source File: ClassAssignmentInterface.java From unitime with Apache License 2.0 | 4 votes |
public float guessCreditCount() { if (!hasCredit()) return 0f; MatchResult m = RegExp.compile("\\d+\\.?\\d*").exec(getCreditAbbv()); if (m != null) return Float.parseFloat(m.getGroup(0)); return 0f; }
Example #19
Source File: JsMatcher.java From actor-platform with GNU Affero General Public License v3.0 | 4 votes |
public JsMatcher(MatchResult matchResult) { this.matchResult = matchResult; }
Example #20
Source File: CustomUUIDValidator.java From proarc with GNU General Public License v3.0 | 4 votes |
@Override protected boolean condition(Object value) { //empty UUID is valid - will be created random new if (value == null) { return true; } String line = value.toString(); //full check if (UUID_PATTERN.test(line)) { return true; } String errorMessage = INVALID_UUID_FORMAT; //enable empty UUID - will be randomly generated if (line.length() == 0) { return true; } //check prefix if (!line.startsWith(UUID_PREFIX)) { errorMessage += INVALID_UUID_MISSING_PREFIX; reportMessage(errorMessage); return false; } //check invalid characters MatchResult matcher = UUID_INVALID_CHAR_PATTERN.exec(line); if (matcher != null) { char invalidChar = matcher.getGroup(1).charAt(matcher.getGroup(1).length() - 1); errorMessage += i18n.Validation_UUID_Invalid_Character(String.valueOf(invalidChar)); } //check length if (line.length() != UUID_LENGTH + UUID_PREFIX_LENGTH + UUID_DASH_COUNT) { if (line.length() < UUID_LENGTH + UUID_PREFIX_LENGTH + UUID_DASH_COUNT) { errorMessage += INVALID_UUID_LENGTH_SHORT; } else if (line.length() > UUID_LENGTH + UUID_PREFIX_LENGTH + UUID_DASH_COUNT) { errorMessage += INVALID_UUID_LENGTH_LONG; } } //check dash count List<Integer> pos = new ArrayList<>(); for (int i = 0; i < line.length(); i++) { //note: char == char does not work if (line.charAt(i) == '-' ) { pos.add(i); } } if (pos.size() != UUID_DASH_COUNT) { errorMessage += i18n.Validation_UUID_Invalid_Dash_Count(Integer.toString(pos.size()), Integer.toString(UUID_DASH_COUNT)); } //add EoL for last segment validation pos.add(line.length()); //check segment sizes int lastPos = 5; for (int i = 0; i < UUID_DASH_COUNT + 1; i++) { if (i >= pos.size()) { reportMessage(errorMessage); return false; } int segmentLength = line.substring(lastPos, pos.get(i)).length(); if (segmentLength != UUID_SEGMENT_LENGTHS[i]) { errorMessage += i18n.Validation_UUID_Invalid_Segment_Length(Integer.toString(i+1), Integer.toString(segmentLength), Integer.toString(UUID_SEGMENT_LENGTHS[i])); } lastPos = pos.get(i) + 1; } reportMessage(errorMessage); return false; }