Java Code Examples for com.google.gwt.regexp.shared.RegExp#compile()
The following examples show how to use
com.google.gwt.regexp.shared.RegExp#compile() .
These examples are extracted from open source projects.
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 Project: proarc File: ImportTreeDataSource.java License: 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 Project: putnami-web-toolkit File: MessageHelper.java License: GNU Lesser General Public License v3.0 | 5 votes |
public static String replaceParams(String pMessage, Object... parameters) { int i = 0; String message = pMessage; if (message != null && parameters != null && parameters.length > 0) { for (Object param : parameters) { RegExp pattern = RegExp.compile("\\{" + i + "\\}"); String stringParam = param + ""; message = pattern.replace(message, stringParam); i++; } } return message; }
Example 3
Source Project: putnami-web-toolkit File: AbstractTextRendererAspect.java License: 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 4
Source Project: core File: ActivemqMetricPresenter.java License: 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 Project: gwt-material File: RegExValidator.java License: Apache License 2.0 | 4 votes |
public RegExValidator(String pattern) { super(Keys.REGEX, new Object[0]); regex = RegExp.compile(pattern); }
Example 6
Source Project: gwt-material File: RegExValidator.java License: Apache License 2.0 | 4 votes |
public RegExValidator(String pattern, String invalidMessageOverride) { super(invalidMessageOverride); regex = RegExp.compile(pattern); }
Example 7
Source Project: actor-platform File: JsPattern.java License: GNU Affero General Public License v3.0 | 4 votes |
public JsPattern(String pattern) { super(pattern); this.compiled = RegExp.compile(pattern); }
Example 8
Source Project: geofence File: EditRuleWidget.java License: 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 9
Source Project: putnami-web-toolkit File: PatternValidator.java License: GNU Lesser General Public License v3.0 | 4 votes |
public PatternValidator(String message, String regexp) { super(message); String flagString = ""; this.pattern = RegExp.compile(regexp, flagString); this.regexp = regexp; }
Example 10
Source Project: putnami-web-toolkit File: InputSuggest.java License: GNU Lesser General Public License v3.0 | 4 votes |
@Override public String highlight(T value, String query) { RegExp pattern = RegExp.compile("(" + query + ")", "ig"); return pattern.replace(getRenderer().render(value), "<strong>$1</strong>"); }
Example 11
Source Project: putnami-web-toolkit File: RegExpWordMatcher.java License: GNU Lesser General Public License v3.0 | 4 votes |
public RegExpWordMatcher(TokenContent tokenContent, String regExpPattern) { super(tokenContent); Preconditions.checkArgument(regExpPattern != null, "The RegExp pattern can not be null"); String fullWordPattern = this.completePattern(regExpPattern); this.regexp = RegExp.compile(fullWordPattern); }