use of org.revapi.configuration.XmlToJson in project revapi by revapi.
the class Analyzer method mergeXmlConfigFile.
private void mergeXmlConfigFile(AnalysisContext.Builder ctxBld, ConfigurationFile configFile, Reader rdr) throws IOException, XmlPullParserException {
XmlToJson<PlexusConfiguration> conv = new XmlToJson<>(revapi, PlexusConfiguration::getName, PlexusConfiguration::getValue, PlexusConfiguration::getAttribute, x -> Arrays.asList(x.getChildren()));
PlexusConfiguration xml = new XmlPlexusConfiguration(Xpp3DomBuilder.build(rdr));
String[] roots = configFile.getRoots();
if (roots == null) {
ctxBld.mergeConfiguration(conv.convert(xml));
} else {
roots: for (String r : roots) {
PlexusConfiguration root = xml;
boolean first = true;
String[] rootPath = r.split("/");
for (String name : rootPath) {
if (first) {
first = false;
if (!name.equals(root.getName())) {
continue roots;
}
} else {
root = root.getChild(name);
if (root == null) {
continue roots;
}
}
}
ctxBld.mergeConfiguration(conv.convert(root));
}
}
}
Aggregations