@Override protected ElementPath initialElementPath() { return new ElementPath("configuration"); }
private void addStartElement(XMLEvent xmlEvent) { StartElement se = xmlEvent.asStartElement(); String tagName = se.getName().getLocalPart(); globalElementPath.push(tagName); ElementPath current = globalElementPath.duplicate(); StartEvent startEvent = new StartEvent(current, tagName, se.getAttributes(), se.getLocation()); eventList.add(startEvent); }
@Override public boolean equals(Object o) { if ((o == null) || !(o instanceof ElementPath)) { return false; } ElementPath r = (ElementPath) o; if (r.size() != size()) { return false; } int len = size(); for (int i = 0; i < len; i++) { if (!equalityCheck(get(i), r.get(i))) { return false; } } // if everything matches, then the two patterns are equal return true; }
private void endElement(String namespaceURI, String localName, String qName) { // given that an action list is always pushed for every startElement, we // need // to always pop for every endElement List<Action> applicableActionList = (List<Action>) actionListStack.pop(); if (skip != null) { if (skip.equals(elementPath)) { skip = null; } } else if (applicableActionList != EMPTY_LIST) { callEndAction(applicableActionList, getTagName(localName, qName)); } // given that we always push, we must also pop the pattern elementPath.pop(); }
@Override public String toString() { return toStableString(); } }
String nestedElementTagName = elementPath.peekLast();
private void addEndEvent(XMLEvent xmlEvent) { EndElement ee = xmlEvent.asEndElement(); String tagName = ee.getName().getLocalPart(); EndEvent endEvent = new EndEvent(tagName, ee.getLocation()); eventList.add(endEvent); globalElementPath.pop(); }
private void startElement(String namespaceURI, String localName, String qName, Attributes atts) { String tagName = getTagName(localName, qName); elementPath.push(tagName); if (skip != null) { // every startElement pushes an action list pushEmptyActionList(); return; } List<Action> applicableActionList = getApplicableActionList(elementPath, atts); if (applicableActionList != null) { actionListStack.add(applicableActionList); callBeginAction(applicableActionList, tagName, atts); } else { // every startElement pushes an action list pushEmptyActionList(); String errMsg = "no applicable action for [" + tagName + "], current ElementPath is [" + elementPath + "]"; cai.addError(errMsg); } }
void callBeginAction(List<Action> applicableActionList, String tagName, Attributes atts) { if (applicableActionList == null) { return; } Iterator<Action> i = applicableActionList.iterator(); while (i.hasNext()) { Action action = (Action) i.next(); // now let us invoke the action. We catch and report any eventual // exceptions try { action.begin(interpretationContext, tagName, atts); } catch (ActionException e) { skip = elementPath.duplicate(); cai.addError("ActionException in Action for tag [" + tagName + "]", e); } catch (RuntimeException e) { skip = elementPath.duplicate(); cai.addError("RuntimeException in Action for tag [" + tagName + "]", e); } } }
private void endElement(String namespaceURI, String localName, String qName) { // given that an action list is always pushed for every startElement, we // need // to always pop for every endElement List<Action> applicableActionList = (List<Action>) actionListStack.pop(); if (skip != null) { if (skip.equals(elementPath)) { skip = null; } } else if (applicableActionList != EMPTY_LIST) { callEndAction(applicableActionList, getTagName(localName, qName)); } // given that we always push, we must also pop the pattern elementPath.pop(); }
public boolean isContainedIn(ElementPath p) { if(p == null) { return false; } return p.toStableString().contains(toStableString()); }
public boolean isApplicable(ElementPath elementPath, Attributes attributes, InterpretationContext ic) { String nestedElementTagName = elementPath.peekLast(); // calling ic.peekObject with an empty stack will throw an exception if (ic.isEmpty()) { return false; } Object o = ic.peekObject(); PropertySetter parentBean = new PropertySetter(o); parentBean.setContext(context); AggregationType aggregationType = parentBean .computeAggregationType(nestedElementTagName); switch (aggregationType) { case NOT_FOUND: case AS_BASIC_PROPERTY: case AS_BASIC_PROPERTY_COLLECTION: return false; // we only push action data if NestComponentIA is applicable case AS_COMPLEX_PROPERTY_COLLECTION: case AS_COMPLEX_PROPERTY: IADataForComplexProperty ad = new IADataForComplexProperty(parentBean, aggregationType, nestedElementTagName); actionDataStack.push(ad); return true; default: addError("PropertySetter.computeAggregationType returned " + aggregationType); return false; } }
public void endElement(String namespaceURI, String localName, String qName) { saxEventList .add(new EndEvent(namespaceURI, localName, qName, getLocator())); globalElementPath.pop(); }
private void startElement(String namespaceURI, String localName, String qName, Attributes atts) { String tagName = getTagName(localName, qName); elementPath.push(tagName); if (skip != null) { // every startElement pushes an action list pushEmptyActionList(); return; } List<Action> applicableActionList = getApplicableActionList(elementPath, atts); if (applicableActionList != null) { actionListStack.add(applicableActionList); callBeginAction(applicableActionList, tagName, atts); } else { // every startElement pushes an action list pushEmptyActionList(); String errMsg = "no applicable action for [" + tagName + "], current ElementPath is [" + elementPath + "]"; cai.addError(errMsg); } }
void callBeginAction(List<Action> applicableActionList, String tagName, Attributes atts) { if (applicableActionList == null) { return; } Iterator<Action> i = applicableActionList.iterator(); while (i.hasNext()) { Action action = (Action) i.next(); // now let us invoke the action. We catch and report any eventual // exceptions try { action.begin(interpretationContext, tagName, atts); } catch (ActionException e) { skip = elementPath.duplicate(); cai.addError("ActionException in Action for tag [" + tagName + "]", e); } catch (RuntimeException e) { skip = elementPath.duplicate(); cai.addError("RuntimeException in Action for tag [" + tagName + "]", e); } } }
@Override public boolean equals(Object o) { if ((o == null) || !(o instanceof ElementPath)) { return false; } ElementPath r = (ElementPath) o; if (r.size() != size()) { return false; } int len = size(); for (int i = 0; i < len; i++) { if (!equalityCheck(get(i), r.get(i))) { return false; } } // if everything matches, then the two patterns are equal return true; }
@Override protected ElementPath initialElementPath() { return new ElementPath("configuration"); }
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) { String tagName = getTagName(localName, qName); globalElementPath.push(tagName); ElementPath current = globalElementPath.duplicate(); saxEventList.add(new StartEvent(current, namespaceURI, localName, qName, atts, getLocator())); }