public void addTimer(Timer timer, DroolsAction action) { if (timers == null) { timers = new HashMap<Timer, DroolsAction>(); } if (timer.getId() == 0) { long id = 0; for (Timer t: timers.keySet()) { if (t.getId() > id) { id = t.getId(); } } timer.setId(++id); } timers.put(timer, action); }
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { Element element = parser.endElementBuilder(); StateBasedNode parent = (StateBasedNode) parser.getParent(); String id = element.getAttribute("id"); emptyAttributeCheck( localName, "id", id, parser ); String delay = element.getAttribute("delay"); String period = element.getAttribute("period"); Timer timer = new Timer(); timer.setId(new Long(id)); if (delay != null && delay.length() != 0 ) { timer.setDelay(delay); } if (period != null && period.length() != 0 ) { timer.setPeriod(period); } org.w3c.dom.Node xmlNode = element.getFirstChild(); DroolsAction action = null; if (xmlNode instanceof Element) { Element actionXml = (Element) xmlNode; action = AbstractNodeHandler.extractAction(actionXml); } parent.addTimer(timer, action); return null; }
public void addTimer(Timer timer, DroolsAction action) { if (timers == null) { timers = new HashMap<Timer, DroolsAction>(); } if (timer.getId() == 0) { long id = 0; for (Timer t: timers.keySet()) { if (t.getId() > id) { id = t.getId(); } } timer.setId(++id); } timers.put(timer, action); }
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { Element element = parser.endElementBuilder(); StateBasedNode parent = (StateBasedNode) parser.getParent(); String id = element.getAttribute("id"); emptyAttributeCheck( localName, "id", id, parser ); String delay = element.getAttribute("delay"); String period = element.getAttribute("period"); Timer timer = new Timer(); timer.setId(new Long(id)); if (delay != null && delay.length() != 0 ) { timer.setDelay(delay); } if (period != null && period.length() != 0 ) { timer.setPeriod(period); } org.w3c.dom.Node xmlNode = element.getFirstChild(); DroolsAction action = null; if (xmlNode instanceof Element) { Element actionXml = (Element) xmlNode; action = AbstractNodeHandler.extractAction(actionXml); } parent.addTimer(timer, action); return null; }