use of org.apache.oro.text.regex.MatchResult in project jmeter by apache.
the class TestHTTPSamplersAgainstHttpMirrorServer method getBoundaryStringFromContentType.
private String getBoundaryStringFromContentType(String requestHeaders) {
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
String regularExpression = "^" + HTTPConstants.HEADER_CONTENT_TYPE + ": multipart/form-data; boundary=(.+)$";
Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
if (localMatcher.contains(requestHeaders, pattern)) {
MatchResult match = localMatcher.getMatch();
String matchString = match.group(1);
// Header may contain ;charset= , regexp extracts it so computed boundary is wrong
int indexOf = matchString.indexOf(';');
if (indexOf >= 0) {
return matchString.substring(0, indexOf);
} else {
return matchString;
}
} else {
return null;
}
}
use of org.apache.oro.text.regex.MatchResult in project intellij-plugins by JetBrains.
the class GherkinPsiUtil method buildParameterRanges.
@Nullable
public static List<TextRange> buildParameterRanges(@NotNull GherkinStep step, @NotNull AbstractStepDefinition definition, final int shiftOffset) {
final List<TextRange> parameterRanges = new ArrayList<>();
final Pattern pattern = definition.getPattern();
if (pattern == null)
return null;
final Perl5Matcher matcher = new Perl5Matcher();
if (matcher.contains(step.getStepName(), pattern)) {
final MatchResult match = matcher.getMatch();
final int groupCount = match.groups();
for (int i = 1; i < groupCount; i++) {
final int start = match.beginOffset(i);
final int end = match.endOffset(i);
if (start >= 0 && end >= 0) {
parameterRanges.add(new TextRange(start, end).shiftRight(shiftOffset));
}
}
}
int k = step.getText().indexOf(step.getStepName());
k += step.getStepName().length();
if (k < step.getText().length() - 1) {
String text = step.getText().substring(k + 1);
boolean inParam = false;
int paramStart = 0;
int i = 0;
while (i < text.length()) {
if (text.charAt(i) == '<') {
paramStart = i;
inParam = true;
}
if (text.charAt(i) == '>' && inParam) {
parameterRanges.add(new TextRange(paramStart, i + 1).shiftRight(shiftOffset + step.getStepName().length() + 1));
inParam = false;
}
i++;
}
}
return parameterRanges;
}
use of org.apache.oro.text.regex.MatchResult in project tdi-studio-se by Talend.
the class MapExpressionParser method parseInTableEntryLocations.
public List<Map<String, String>> parseInTableEntryLocations(String expression) {
List<Map<String, String>> result = new ArrayList<Map<String, String>>();
if (expression != null) {
matcher.setMultiline(true);
if (patternMatcherInput == null) {
patternMatcherInput = new PatternMatcherInput(expression);
} else {
patternMatcherInput.setInput(expression);
}
recompilePatternIfNecessary(locationPattern);
while (matcher.contains(patternMatcherInput, pattern)) {
MatchResult matchResult = matcher.getMatch();
Map<String, String> map = new HashMap<String, String>();
if (matchResult.group(3) != null && !"".equals(matchResult.group(3))) {
map.put(matchResult.group(3), matchResult.group(1) + "." + matchResult.group(2));
} else {
map.put(matchResult.group(2), matchResult.group(1));
}
result.add(map);
}
}
// .toArray(new TableEntryLocation[0]);
return result;
}
use of org.apache.oro.text.regex.MatchResult in project tdi-studio-se by Talend.
the class DataMapExpressionParser method parseTableEntryLocations.
public TableEntryLocation[] parseTableEntryLocations(String expression) {
resultList.clear();
if (expression != null) {
matcher.setMultiline(true);
if (patternMatcherInput == null) {
patternMatcherInput = new PatternMatcherInput(expression);
} else {
patternMatcherInput.setInput(expression);
}
recompilePatternIfNecessary(EXPRESSION_PATTERN);
while (matcher.contains(patternMatcherInput, pattern)) {
MatchResult matchResult = matcher.getMatch();
TableEntryLocation location = null;
if (matchResult.group(1) != null) {
// context.schema.context.table.comlumn
location = new TableEntryLocation(matchResult.group(2) + DOT_STR + matchResult.group(3) + DOT_STR + matchResult.group(4) + DOT_STR + matchResult.group(5), matchResult.group(6));
} else if (matchResult.group(7) != null) {
// context.schema.table.comlumn | schema.context.table.comlumn
location = new TableEntryLocation(matchResult.group(8) + DOT_STR + matchResult.group(9) + DOT_STR + matchResult.group(10), matchResult.group(11));
} else if (matchResult.group(12) != null) {
// schema.table.column
location = new TableEntryLocation(matchResult.group(13) + DOT_STR + matchResult.group(14), matchResult.group(15));
} else if (matchResult.group(16) != null) {
// table.column
location = new TableEntryLocation(matchResult.group(17), matchResult.group(18));
}
if (location != null) {
resultList.add(location);
}
}
}
return resultList.toArray(new TableEntryLocation[resultList.size()]);
}
use of org.apache.oro.text.regex.MatchResult in project tdi-studio-se by Talend.
the class XmlMapExpressionManager method getMatchedExpression.
public List<String> getMatchedExpression(String expression) {
List<String> matched = new ArrayList<String>();
if (expression == null) {
return matched;
}
recompilePatternIfNecessary(EXPRESSION_PATTERN);
patternMatcherInput = new PatternMatcherInput(expression);
while (matcher.contains(patternMatcherInput, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult.group(0) != null) {
matched.add(matchResult.group(0).trim());
}
}
return matched;
}
Aggregations