/** * Extract the the uptime from the XML document, reusing the XML provider * utilites * * @param xmlstarter * @param d * @return */ protected long findUptime(XmlProvider xmlstarter, Document d) { String upTimePath = getPd().getSpecific("upTimePath"); if(upTimePath != null) { return xmlstarter.findUptime(d, upTimePath); } else if(getPd().getSpecific("nouptime") != null) { return Long.MAX_VALUE; } else { String startTimePath = getPd().getSpecific("startTimePath"); String currentTimePath = getPd().getSpecific("currentTimePath"); String timePattern = getPd().getSpecific("timePattern"); if(startTimePath != null && currentTimePath != null && timePattern != null) { DateFormat df = new SimpleDateFormat(timePattern); return xmlstarter.findUptimeByDate(d, startTimePath, currentTimePath, df); } else { log(Level.ERROR, "No xpath for the uptime"); return 0; } } }
@Override protected boolean finishConfigure(List<Object> args) { log(Level.TRACE, "Configuring collect xpath with %s", args); CollectResolver<XPathExpression> cr = new XmlProvider.XmlResolver(); collectKeys = new HashMap<>(getPd().getCollectMapping().size()); for(Map.Entry<String, String> e: getPd().getCollectMapping().entrySet()) { String solved = Util.parseTemplate(String.format(e.getKey(), args != null ? args.toArray() : null), this, args); XPathExpression xpath = cr.resolve(solved); if (xpath == null) { log(Level.DEBUG, "unparsed xpath: %s", e.getKey()); continue; } else { collectKeys.put(xpath, solved); } } collectKeys = Collections.unmodifiableMap(collectKeys); log(Level.TRACE, "collect xpath mapping %s", collectKeys); return super.finishConfigure(args); }