~ubuntu-branches/ubuntu/vivid/eclipse-linuxtools/vivid-proposed

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.graphingapi.core/src/org/eclipse/linuxtools/systemtap/graphingapi/core/datasets/row/LineParser.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam, Jakub Adam, tony mancill
  • Date: 2014-10-11 11:44:05 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20141011114405-yazjvxfzzhmi5sgj
Tags: 3.1.0-1
[ Jakub Adam ]
* New upstream release (Closes: #761524).
* Refreshed d/patches.
* Don't build removed feature org.eclipse.linuxtools.tools.launch
  - merged into org.eclipse.linuxtools.profiling.
* Use javac target 1.7.
* Build new feature org.eclipse.linuxtools.dataviewers.feature
  - required by Valgrind integration.
* Build-depend on eclipse-remote-services-api and eclipse-cdt-autotools.
* Bump Standards-Version to 3.9.6.
* Override incompatible-java-bytecode-format - linuxtools needs Java 7.
* Remove unused codeless-jar override.

[ tony mancill ]
* Tweak short package description to make lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
7
 
 *
8
 
 * Contributors:
9
 
 *     Red Hat - Andrew Ferrazzutti
10
 
 *******************************************************************************/
11
 
 
12
 
package org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.row;
13
 
 
14
 
import java.util.regex.Matcher;
15
 
import java.util.regex.Pattern;
16
 
 
17
 
import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataEntry;
18
 
import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSetParser;
19
 
 
20
 
/**
21
 
 * A DataSetParser for parsing a string, line-by-line, with a preconstructed
22
 
 * single-line regex string.
23
 
 * 
24
 
 * @author aferrazz
25
 
 * @since 1.1
26
 
 *
27
 
 */
28
 
public class LineParser implements IDataSetParser {
29
 
        public LineParser(String regEx) {
30
 
                wholePattern = Pattern.compile(regEx, Pattern.MULTILINE);
31
 
        }
32
 
 
33
 
        @Override
34
 
        public IDataEntry parse(StringBuilder s) {
35
 
                if(null == s) {
36
 
                        return null;
37
 
                }
38
 
 
39
 
                RowEntry e = null;
40
 
                Matcher wholeMatcher = wholePattern.matcher(s);
41
 
 
42
 
                if(wholeMatcher.find()) {
43
 
                        e = new RowEntry();
44
 
                        int groupCount = wholeMatcher.groupCount();
45
 
                        Object[] data = new Object[groupCount];
46
 
 
47
 
                        for(int i = 0; i < groupCount; i++) {
48
 
                                data[i] = wholeMatcher.group(i+1);
49
 
                        }
50
 
                        e.putRow(0, data);
51
 
                        s.delete(0, s.length());
52
 
                }
53
 
 
54
 
                return e;
55
 
        }
56
 
 
57
 
        private Pattern wholePattern;
58
 
}