import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
/** Path to the XML definitions file */
protected static final String CUSTOM_XML_TRACE_DEFINITIONS_DEFAULT_PATH_NAME =
- Platform.getInstallLocation().getURL().getPath() +
- "templates/org.eclipse.linuxtools.tmf.core/" + //$NON-NLS-1$
- CUSTOM_XML_TRACE_DEFINITIONS_DEFAULT_FILE_NAME;
+ Platform.getInstallLocation().getURL().getPath() + "templates/org.eclipse.linuxtools.tmf.core/" + //$NON-NLS-1$
+ CUSTOM_XML_TRACE_DEFINITIONS_DEFAULT_FILE_NAME;
/** Path to the XML definitions file */
protected static final String CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME =
Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME).toString();
- /** Legacy path to the XML definitions file (in the UI plug-in)
- * TODO Remove once we feel the transition phase is over. */
+ /**
+ * Legacy path to the XML definitions file (in the UI plug-in) TODO Remove
+ * once we feel the transition phase is over.
+ */
private static final String CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME_LEGACY =
Activator.getDefault().getStateLocation().removeLastSegments(1).addTrailingSeparator()
.append("org.eclipse.linuxtools.tmf.ui") //$NON-NLS-1$
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver() {
- @Override
- public InputSource resolveEntity(String publicId, String systemId) {
- String empty = ""; //$NON-NLS-1$
- ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
- return new InputSource(bais);
- }
- };
- db.setEntityResolver(resolver);
+ db.setEntityResolver(createEmptyEntityResolver());
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler() {
- @Override
- public void error(SAXParseException saxparseexception) throws SAXException {
- }
-
- @Override
- public void warning(SAXParseException saxparseexception) throws SAXException {
- }
-
- @Override
- public void fatalError(SAXParseException saxparseexception) throws SAXException {
- throw saxparseexception;
- }
- });
+ db.setErrorHandler(createErrorHandler());
Document doc = null;
File file = new File(path);
TmfTraceType.addCustomTraceType(TmfTraceType.CUSTOM_XML_CATEGORY, definitionName);
- } catch (ParserConfigurationException e) {
- Activator.logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
- } catch (TransformerConfigurationException e) {
- Activator.logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
- } catch (TransformerFactoryConfigurationError e) {
- Activator.logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
- } catch (TransformerException e) {
- Activator.logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
- } catch (IOException e) {
- Activator.logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
- } catch (SAXException e) {
+ } catch (ParserConfigurationException | TransformerFactoryConfigurationError | TransformerException | IOException | SAXException e) {
Activator.logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
}
}
DocumentBuilder db = dbf.newDocumentBuilder();
// The following allows xml parsing without access to the dtd
- EntityResolver resolver = new EntityResolver() {
- @Override
- public InputSource resolveEntity(String publicId, String systemId) {
- String empty = ""; //$NON-NLS-1$
- ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
- return new InputSource(bais);
- }
- };
- db.setEntityResolver(resolver);
+ db.setEntityResolver(createEmptyEntityResolver());
// The following catches xml parsing exceptions
- db.setErrorHandler(new ErrorHandler() {
- @Override
- public void error(SAXParseException saxparseexception) throws SAXException {
- }
-
- @Override
- public void warning(SAXParseException saxparseexception) throws SAXException {
- }
-
- @Override
- public void fatalError(SAXParseException saxparseexception) throws SAXException {
- throw saxparseexception;
- }
- });
+ db.setErrorHandler(createErrorHandler());
File file = new File(path);
if (!file.canRead()) {
}
}
return defList.toArray(new CustomXmlTraceDefinition[0]);
- } catch (ParserConfigurationException e) {
- Activator.logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
- } catch (SAXException e) {
- Activator.logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
- } catch (IOException e) {
+ } catch (ParserConfigurationException | SAXException | IOException e) {
Activator.logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
}
return new CustomXmlTraceDefinition[0];
value = lookupXmlDefinition(definitionName, db, CUSTOM_XML_TRACE_DEFINITIONS_DEFAULT_PATH_NAME);
}
return value;
- } catch (ParserConfigurationException e) {
- Activator.logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
- } catch (SAXException e) {
- Activator.logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
- } catch (IOException e) {
+ } catch (ParserConfigurationException | SAXException | IOException e) {
Activator.logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
}
return null;
// Check if default definition needs to be reloaded
TmfTraceType.addCustomTraceType(TmfTraceType.CUSTOM_XML_CATEGORY, definitionName);
- } catch (ParserConfigurationException e) {
- Activator.logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
- } catch (SAXException e) {
- Activator.logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
- } catch (IOException e) {
- Activator.logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
- } catch (TransformerConfigurationException e) {
- Activator.logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
- } catch (TransformerFactoryConfigurationError e) {
- Activator.logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
- } catch (TransformerException e) {
+ } catch (ParserConfigurationException | SAXException | IOException | TransformerFactoryConfigurationError | TransformerException e) {
Activator.logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
}
}