Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / filter / xml / TmfFilterXMLParser.java
CommitLineData
46ab8ce3
FC
1/*******************************************************************************\r
2 * Copyright (c) 2010 Ericsson\r
3 * \r
4 * All rights reserved. This program and the accompanying materials are\r
5 * made available under the terms of the Eclipse Public License v1.0 which\r
6 * accompanies this distribution, and is available at\r
7 * http://www.eclipse.org/legal/epl-v10.html\r
8 * \r
9 * Contributors:\r
10 * Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
11 *******************************************************************************/\r
12\r
13package org.eclipse.linuxtools.tmf.filter.xml;\r
14\r
15import java.io.IOException;\r
16\r
17import javax.xml.parsers.ParserConfigurationException;\r
18import javax.xml.parsers.SAXParserFactory;\r
19\r
20import org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode;\r
21\r
22import org.xml.sax.SAXException;\r
23import org.xml.sax.XMLReader;\r
24\r
25/**\r
26 * <b><u>FilterXMLParser</u></b>\r
27 * <p>\r
28 * This is SAX based XML parser\r
29 * <p>\r
30 */\r
31public class TmfFilterXMLParser {\r
32 \r
33 private static ITmfFilterTreeNode fRoot = null;\r
34 \r
35 /**\r
36 * The XMLParser constructor\r
37 * \r
38 * @param uri The XML file to parse\r
39 */ \r
40 public TmfFilterXMLParser(final String uri) throws SAXException, IOException {\r
41 \r
42 SAXParserFactory m_parserFactory = null;\r
43 if (m_parserFactory == null) { \r
44 m_parserFactory = SAXParserFactory.newInstance(); \r
45 m_parserFactory.setNamespaceAware(true); \r
46 } \r
47\r
48 XMLReader saxReader = null;\r
49 try {\r
50 \r
51 saxReader = m_parserFactory.newSAXParser().getXMLReader();\r
52 saxReader.setContentHandler(new TmfFilterContentHandler());\r
53 saxReader.parse(uri);\r
54 \r
55 fRoot = ((TmfFilterContentHandler) saxReader.getContentHandler()).getTree();\r
56 \r
57 } catch (ParserConfigurationException e) {\r
58 e.printStackTrace();\r
59 }\r
60 }\r
61\r
62 /**\r
63 * Getter of tree\r
64 * \r
65 * @return The builded tree\r
66 */ \r
67 public ITmfFilterTreeNode getTree() {\r
68 return fRoot;\r
69 }\r
70}\r
This page took 0.028087 seconds and 5 git commands to generate.