use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu in project tracecompass by tracecompass.
the class TmfXmlTestUtils method getModuleInFile.
/**
* Get the XML analysis module in the file. It will return either a pattern
* or state provider, if there is one in the file
*
* @param xmlFilePath
* The absolute file path to the XML file
* @param analysisId
* The ID of the analysis to get
* @return The analysis module
*/
public static TmfAbstractAnalysisModule getModuleInFile(String xmlFilePath, @NonNull String analysisId) {
// Look for a pattern element
Element element = TmfXmlUtils.getElementInFile(xmlFilePath, TmfXmlStrings.PATTERN, analysisId);
if (element != null) {
TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(element);
if (patternCu == null) {
return null;
}
XmlPatternAnalysis module = new XmlPatternAnalysis(analysisId, patternCu);
module.setName(analysisId);
return module;
}
// Look for a state provider
element = TmfXmlUtils.getElementInFile(xmlFilePath, TmfXmlStrings.STATE_PROVIDER, analysisId);
if (element != null) {
TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(Paths.get(xmlFilePath), analysisId);
assertNotNull(compile);
DataDrivenAnalysisModule module = new DataDrivenAnalysisModule(analysisId, compile);
module.setName(analysisId);
return module;
}
throw new NullPointerException("No module named " + analysisId + " in file " + xmlFilePath);
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu in project tracecompass by tracecompass.
the class XmlUtilsTest method initializeModule.
/**
* Initialize a new module using the xml file
*
* @param xmlAnalysisFile
* The xml file used to initialize the module
* @return The module
*/
@NonNull
public static DataDrivenAnalysisModule initializeModule(TmfXmlTestFiles xmlAnalysisFile) {
/* Initialize the state provider module */
Document doc = xmlAnalysisFile.getXmlDocument();
assertNotNull(doc);
List<@NonNull Element> childElements = TmfXmlUtils.getChildElements(doc.getDocumentElement(), TmfXmlStrings.STATE_PROVIDER);
assertFalse(childElements.isEmpty());
Element element = childElements.get(0);
String moduleId = element.getAttribute(TmfXmlStrings.ID);
TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(xmlAnalysisFile.getFile().toPath(), moduleId);
assertNotNull(compile);
DataDrivenAnalysisModule module = new DataDrivenAnalysisModule(moduleId, compile);
return module;
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu in project tracecompass by tracecompass.
the class StateProviderTest method testInvalidInput.
/**
* Test an invalid instantiation
*/
@Test
public void testInvalidInput() {
TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(Paths.get(""), "test");
assertNull(compile);
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu in project tracecompass by tracecompass.
the class XmlModuleTestBase method createModule.
private void createModule(@NonNull Element element) {
String analysisId = element.getAttribute(TmfXmlStrings.ID);
switch(getAnalysisNodeName()) {
case TmfXmlStrings.PATTERN:
TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(element);
assertNotNull(patternCu);
fModule = new XmlPatternAnalysis(analysisId, patternCu);
fModule.setName(getName(element));
break;
case TmfXmlStrings.STATE_PROVIDER:
TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(getXmlFile().getFile().toPath(), analysisId);
assertNotNull(compile);
fModule = new DataDrivenAnalysisModule(analysisId, compile);
fModule.setName(getName(element));
break;
default:
fail();
}
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu in project tracecompass by tracecompass.
the class TmfAnalysisModuleHelperXml method newModule.
@Override
@Nullable
public final IAnalysisModule newModule(ITmfTrace trace) throws TmfAnalysisException {
String analysisid = getId();
IAnalysisModule module = null;
switch(fType) {
case STATE_SYSTEM:
TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(fSourceFile.toPath(), analysisid);
if (compile == null) {
return null;
}
module = new DataDrivenAnalysisModule(analysisid, compile);
module.setName(getName());
break;
case PATTERN:
TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(fSourceFile.toPath(), analysisid);
if (patternCu == null) {
return null;
}
module = new XmlPatternAnalysis(analysisid, patternCu);
module.setName(getName());
XmlPatternAnalysis paModule = (XmlPatternAnalysis) module;
paModule.setViewLabelPrefix(getViewLabelPrefix());
break;
case OTHER:
String name = getName();
module = createOtherModule(analysisid, name);
break;
default:
break;
}
if (module != null) {
if (module.setTrace(trace)) {
TmfAnalysisManager.analysisModuleCreated(module);
} else {
/*
* The analysis does not apply to the trace, dispose of the
* module
*/
module.dispose();
module = null;
}
}
return module;
}
Aggregations