use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.
the class TestingOpModelEvent method getNewImage.
@Override
protected OpModelImage getNewImage() {
/* this code mostly taken from OpxmlRunner */
OpModelImage parsedImage = null;
try {
XMLReader reader = null;
parsedImage = new OpModelImage();
ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
// Create XMLReader
SAXParserFactory factory = SAXParserFactory.newInstance();
reader = factory.newSAXParser().getXMLReader();
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
String filePath = FileLocator.toFileURL(FileLocator.find(TestPlugin.getDefault().getBundle(), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
return parsedImage;
}
use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.
the class TestingOpModelEvent3 method getNewImage.
@Override
protected OpModelImage getNewImage() {
/* this code mostly taken from OpxmlRunner */
OpModelImage parsedImage = null;
try {
XMLReader reader = null;
parsedImage = new OpModelImage();
ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
// Create XMLReader
SAXParserFactory factory = SAXParserFactory.newInstance();
reader = factory.newSAXParser().getXMLReader();
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
String filePath = FileLocator.toFileURL(FileLocator.find(TestPlugin.getDefault().getBundle(), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
return parsedImage;
}
use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.
the class TestCheckEventsParse method setUpHelper.
// helper
private void setUpHelper(String fileToParse, final int[] resultArray) throws Exception {
/* this code mostly taken from OpxmlRunner */
XMLReader reader = null;
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(resultArray);
// Create XMLReader
SAXParserFactory factory = SAXParserFactory.newInstance();
reader = factory.newSAXParser().getXMLReader();
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
String filePath = FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(fileToParse), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
}
use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.
the class TestModelDataParse method setUp.
@Before
public void setUp() throws Exception {
/* this code mostly taken from OpxmlRunner */
XMLReader reader = null;
parsedImage = new OpModelImage();
ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
// Create XMLReader
SAXParserFactory factory = SAXParserFactory.newInstance();
reader = factory.newSAXParser().getXMLReader();
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
String filePath = FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
// 2nd test image
parsedErrorImage = new OpModelImage();
ModelDataProcessor.CallData errorImage = new ModelDataProcessor.CallData(parsedErrorImage);
handler = OprofileSAXHandler.getInstance(errorImage);
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
filePath = FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(REL_PATH_TO_TEST_XML_MULTI_IMAGE), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
}
use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.
the class TestSessionsParse method setUp.
@Before
public void setUp() throws Exception {
/* this code mostly taken from OpxmlRunner */
XMLReader reader = null;
eventList = new ArrayList<>();
SessionsProcessor.SessionInfo sessioninfo = new SessionsProcessor.SessionInfo(eventList);
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(sessioninfo);
// Create XMLReader
SAXParserFactory factory = SAXParserFactory.newInstance();
reader = factory.newSAXParser().getXMLReader();
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
String filePath = FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
}
Aggregations