public void endElement(String namespaceURI, String localName, String qName) throws ParserException { { } // System.out.println("end Element"); Caller targeting = (Caller) stack.pop(); try { targeting.process(); } catch (Exception e) { throw new ParserException("Could not place " + qName + " into system!\n" + e.getMessage()); } }
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws ParserException { Caller targeting = (Caller) targetMap.get(qName); if (null == targeting) throw new ParserException("No target found for tag: " + qName + "!"); targeting = (Caller) targeting.duplicate(); XMLOp actor = (XMLOp) actionMap.get(qName); if (null == actor) throw new ParserException("No action found for tag: " + qName + "!"); if (null == targeting.getTargetObject() && 0 < stack.size()) { Caller parent = null; try { parent = (Caller) stack.peek(); } catch (Exception e) { throw new ParserException( "Typecast exception, unknown object placed in stack! " + e.getMessage()); } Object targetObject = parent.parameter(0); int idx = stack.indexOf(parent); // climb stack for next available parent (stack may have no-ops in it. while (null == targetObject && 0 < idx) { { } // System.out.println("Climbing stack for next available parent.."); try { parent = (Caller) stack.get(--idx); } catch (Exception e) { throw new ParserException( "Typecast exception, unknown object placed in stack! " + e.getMessage()); } targetObject = parent.parameter(0); } targeting.setTargetObject(targetObject); } Object o; try { actor.initialize(attributeMap(qName, atts)); o = actor.process(); } catch (Exception e) { try { actor.initialize(attributeMap(qName, atts)); o = actor.process(); } catch (Exception r) { throw new ParserException( "Could not execute action for tag: " + qName + "! " + e.getMessage()); } } targeting.resetParameters(new Object[] {o}); stack.push(targeting); }