use of org.apache.oro.text.regex.PatternMatcherInput 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;
}
use of org.apache.oro.text.regex.PatternMatcherInput 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.PatternMatcherInput in project tdi-studio-se by Talend.
the class MapExpressionParser method substitute.
private String substitute(PatternMatcher matcher, Pattern pattern, Substitution sub, String input, int numSubs) {
StringBuffer buffer = new StringBuffer(input.length());
PatternMatcherInput pinput = new PatternMatcherInput(input);
// are performed,
if (substitute(buffer, matcher, pattern, sub, pinput, numSubs) != 0) {
return buffer.toString();
}
return input;
}
use of org.apache.oro.text.regex.PatternMatcherInput 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.PatternMatcherInput in project Lucee by lucee.
the class Perl5Util method indexOf.
/**
* return index of the first occurence of the pattern in input text
* @param strPattern pattern to search
* @param strInput text to search pattern
* @param offset
* @param caseSensitive
* @return position of the first occurence
* @throws MalformedPatternException
*/
public static int indexOf(String strPattern, String strInput, int offset, boolean caseSensitive) throws MalformedPatternException {
// Perl5Compiler compiler = new Perl5Compiler();
PatternMatcherInput input = new PatternMatcherInput(strInput);
Perl5Matcher matcher = new Perl5Matcher();
int compileOptions = caseSensitive ? 0 : Perl5Compiler.CASE_INSENSITIVE_MASK;
compileOptions += Perl5Compiler.SINGLELINE_MASK;
if (offset < 1)
offset = 1;
Pattern pattern = getPattern(strPattern, compileOptions);
if (offset <= strInput.length())
input.setCurrentOffset(offset - 1);
if (offset <= strInput.length() && matcher.contains(input, pattern)) {
return matcher.getMatch().beginOffset(0) + 1;
}
return 0;
}
Aggregations