use of com.google.gwt.regexp.shared.MatchResult in project opennms by OpenNMS.
the class MarkerFilterImpl method matches.
@Override
public boolean matches(final NodeMarker marker) {
if (marker == null)
return false;
final AlarmSeverity severity;
if (marker.getSeverity() == null) {
severity = AlarmSeverity.NORMAL;
} else {
severity = AlarmSeverity.get(marker.getSeverity());
}
if (severity.isLessThan(m_minimumSeverity))
return false;
if (m_searchString == null || "".equals(m_searchString))
return true;
final String searchProperty;
final MatchType matchType;
final List<String> searchFor = new ArrayList<>();
final MatchResult m = m_searchPattern.exec(m_searchString);
if (m != null) {
searchProperty = m.getGroup(1);
matchType = MatchType.fromToken(m.getGroup(2));
final String searchCriteria = m.getGroup(3);
if (matchType == MatchType.IN) {
final String ignoreParens = searchCriteria.replaceAll("^\\s*\\(\\s*(.*)\\s*\\)\\s*$", "$1");
for (final String s : ignoreParens.split("\\s*,\\s*")) {
searchFor.add(s);
}
} else {
searchFor.add(searchCriteria);
}
} else {
searchProperty = null;
matchType = MatchType.SUBSTRING;
searchFor.add(m_searchString);
}
final Map<String, String> markerProperties = marker.getProperties();
if (searchProperty != null) {
return matchProperty(matchType, searchProperty, searchFor, markerProperties);
} else {
for (final String key : markerProperties.keySet()) {
if (matchProperty(matchType, key, searchFor, markerProperties)) {
return true;
}
}
}
return false;
}
use of com.google.gwt.regexp.shared.MatchResult 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.MatchResult in project webprotege by protegeproject.
the class ProjectTagsPlaceTokenizer method getPlace.
@Override
public ProjectTagsPlace getPlace(String token) {
MatchResult matchResult = regExp.exec(token);
if (matchResult == null) {
return null;
}
String projectIdString = matchResult.getGroup(1);
if (ProjectId.isWelFormedProjectId(projectIdString)) {
ProjectId projectId = ProjectId.get(projectIdString);
return new ProjectTagsPlace(projectId, Optional.empty());
} else {
return null;
}
}
use of com.google.gwt.regexp.shared.MatchResult in project webprotege by protegeproject.
the class ProjectViewPlaceTokenizer method getPlace.
public ProjectViewPlace getPlace(String token) {
GWT.log("[ProjectViewPlaceTokenizer] Parsing: " + token);
token = URL.decode(token);
GWT.log("[ProjectViewPlaceTokenizer] Decoded: " + token);
MatchResult result = regExp.exec(token);
GWT.log("[ProjectViewPlaceTokenizer] MatchResult: " + result);
String projectId = result.getGroup(1);
String perspectiveId = result.getGroup(2);
String selectionString = result.getGroup(4);
GWT.log("[ProjectViewPlaceTokenizer] Parsed: ProjectId: " + projectId);
GWT.log("[ProjectViewPlaceTokenizer] Parsed: PerspectiveId: " + perspectiveId);
GWT.log("[ProjectViewPlaceTokenizer] Parsed: Selection: " + selectionString);
ProjectViewPlace.Builder builder = new ProjectViewPlace.Builder(ProjectId.get(projectId), new PerspectiveId(perspectiveId));
if (selectionString != null) {
ItemTokenizer tokenizer = new ItemTokenizer();
List<ItemToken> tokenList = tokenizer.parseTokens(selectionString);
for (ItemToken t : tokenList) {
OWLDataFactoryImpl dataFactory = new OWLDataFactoryImpl();
ItemTokenParser parser = new ItemTokenParser();
DefaultPrefixManager prefixManager = new DefaultPrefixManager();
prefixManager.setPrefix("owl:", Namespaces.OWL.getPrefixIRI());
List<Item<?>> entity = parser.parse(t, new DefaultItemTypeMapper(dataFactory, prefixManager));
for (Item<?> item : entity) {
builder.withSelectedItem(item);
}
}
}
return builder.build();
}
use of com.google.gwt.regexp.shared.MatchResult 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