use of org.apache.oro.text.regex.PatternMatcherInput in project tdi-studio-se by Talend.
the class DataMapExpressionParser 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 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(locationPattern);
while (matcher.contains(patternMatcherInput, pattern)) {
MatchResult matchResult = matcher.getMatch();
resultList.add(new TableEntryLocation(matchResult.group(1), matchResult.group(2)));
}
}
return resultList.toArray(new TableEntryLocation[0]);
}
use of org.apache.oro.text.regex.PatternMatcherInput in project tdi-studio-se by Talend.
the class DataMapExpressionParserTest method main.
public static void main(String[] args) throws Exception {
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
// String PATTERN_STR = "\\s*(\\w+)\\s*(\\.\\s*(\\w+)\\s*)+"; // can't get correct group count.
String PATTERN_STR = "(\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*)" + "|(\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*)" + "|(\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*)" + "|(\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*)";
String expression = "context. schema. context .table.column";
// String expression = "context.schema.table.column";
// String expression = "schema.table.column";
// String expression = "table.column";
matcher.setMultiline(true);
PatternMatcherInput patternMatcherInput = new PatternMatcherInput(expression);
Pattern pattern = compiler.compile(PATTERN_STR);
while (matcher.contains(patternMatcherInput, pattern)) {
MatchResult matchResult = matcher.getMatch();
System.out.println("group count:" + matchResult.groups());
for (int i = 1; i <= matchResult.groups(); i++) {
System.out.println("group[" + i + "] content:" + matchResult.group(i));
}
}
}
use of org.apache.oro.text.regex.PatternMatcherInput in project tdi-studio-se by Talend.
the class WebServiceExpressionParser method parseOutTableEntryLocations.
public Set<String> parseOutTableEntryLocations(String expression) {
Set<String> set = new HashSet<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();
String columnName = matchResult.group(0);
set.add(columnName);
}
}
return set;
}
use of org.apache.oro.text.regex.PatternMatcherInput in project tdi-studio-se by Talend.
the class XmlMapExpressionManager method parseTableEntryLocation.
public List<TableEntryLocation> parseTableEntryLocation(String expression) {
List<TableEntryLocation> locations = new ArrayList<TableEntryLocation>();
recompilePatternIfNecessary(EXPRESSION_PATTERN);
patternMatcherInput = new PatternMatcherInput(expression);
while (matcher.contains(patternMatcherInput, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult.group(1) != null) {
TableEntryLocation location = new TableEntryLocation(matchResult.group(1), matchResult.group(2), matchResult.group(3), matchResult.group(6));
locations.add(location);
} else if (matchResult.group(matchResult.groups() - 1) != null) {
TableEntryLocation location = new TableEntryLocation(matchResult.group(matchResult.groups() - 2), matchResult.group(matchResult.groups() - 1));
locations.add(location);
}
}
return locations;
}
Aggregations