1
/*******************************************************************************
2
* Copyright (c) 2013 Red Hat.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Red Hat - Andrew Ferrazzutti
10
*******************************************************************************/
12
package org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.row;
14
import java.util.regex.Matcher;
15
import java.util.regex.Pattern;
17
import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataEntry;
18
import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSetParser;
21
* A DataSetParser for parsing a string, line-by-line, with a preconstructed
22
* single-line regex string.
28
public class LineParser implements IDataSetParser {
29
public LineParser(String regEx) {
30
wholePattern = Pattern.compile(regEx, Pattern.MULTILINE);
34
public IDataEntry parse(StringBuilder s) {
40
Matcher wholeMatcher = wholePattern.matcher(s);
42
if(wholeMatcher.find()) {
44
int groupCount = wholeMatcher.groupCount();
45
Object[] data = new Object[groupCount];
47
for(int i = 0; i < groupCount; i++) {
48
data[i] = wholeMatcher.group(i+1);
51
s.delete(0, s.length());
57
private Pattern wholePattern;