public void play(List<SaxEvent> aSaxEventList) { eventList = aSaxEventList; SaxEvent se; for(currentIndex = 0; currentIndex < eventList.size(); currentIndex++) { se = eventList.get(currentIndex); if(se instanceof StartEvent) { interpreter.startElement((StartEvent) se); // invoke fireInPlay after startElement processing interpreter.getInterpretationContext().fireInPlay(se); } if(se instanceof BodyEvent) { // invoke fireInPlay before characters processing interpreter.getInterpretationContext().fireInPlay(se); interpreter.characters((BodyEvent) se); } if(se instanceof EndEvent) { // invoke fireInPlay before endElement processing interpreter.getInterpretationContext().fireInPlay(se); interpreter.endElement((EndEvent) se); } } }
@Override protected void addImplicitRules(Interpreter interpreter) { // The following line adds the capability to parse nested components NestedComplexPropertyIA nestedComplexPropertyIA = new NestedComplexPropertyIA(); nestedComplexPropertyIA.setContext(context); interpreter.addImplicitAction(nestedComplexPropertyIA); NestedBasicPropertyIA nestedBasicIA = new NestedBasicPropertyIA(); nestedBasicIA.setContext(context); interpreter.addImplicitAction(nestedBasicIA); }
private void addEventsToPlayer(InterpretationContext ic) { Interpreter interpreter = ic.getJoranInterpreter(); this.events.remove(0); this.events.remove(this.events.size() - 1); interpreter.getEventPlayer().addEventsDynamically(this.events, 1); }
@Override protected void buildInterpreter() { super.buildInterpreter(); Map<String, Object> omap = interpreter.getInterpretationContext().getObjectMap(); omap.put(ActionConst.APPENDER_BAG, new HashMap<String, Appender<?>>()); //omap.put(ActionConst.FILTER_CHAIN_BAG, new HashMap()); Map<String, String> propertiesMap = new HashMap<String, String>(); propertiesMap.putAll(parentPropertyMap); propertiesMap.put(key, value); interpreter.setInterpretationContextPropertiesMap(propertiesMap); }
public void endElement(EndEvent endEvent) { setDocumentLocator(endEvent.locator); endElement(endEvent.namespaceURI, endEvent.localName, endEvent.qName); }
public void characters(BodyEvent be) { setDocumentLocator(be.locator); String body = be.getText(); List<Action> applicableActionList = actionListStack.peek(); if (body != null) { body = body.trim(); if (body.length() > 0) { // System.out.println("calling body method with ["+body+ "]"); callBodyAction(applicableActionList, body); } } }
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); } }
protected void buildInterpreter() { RuleStore rs = new SimpleRuleStore(context); addInstanceRules(rs); this.interpreter = new Interpreter(context, rs, initialElementPath()); InterpretationContext interpretationContext = interpreter.getInterpretationContext(); interpretationContext.setContext(context); addImplicitRules(interpreter); addDefaultNestedComponentRegistryRules(interpretationContext.getDefaultNestedComponentRegistry()); }
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(); }
@SuppressWarnings("unchecked") public Appender<ILoggingEvent> getAppender() { Map<String, Object> omap = interpreter.getInterpretationContext().getObjectMap(); HashMap<String, Appender<?>> appenderMap = (HashMap<String, Appender<?>>) omap.get(ActionConst.APPENDER_BAG); oneAndOnlyOneCheck(appenderMap); Collection<Appender<?>> values = appenderMap.values(); if (values.size() == 0) { return null; } return (Appender<ILoggingEvent>) values.iterator().next(); } }
addInfo("About to add new Joran parsing rule [" + pattern + "," + actionClass + "]."); ec.getJoranInterpreter().getRuleStore().addRule(new ElementSelector(pattern), actionClass); } catch (Exception oops) {
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); } }
/** * Builds a generic configuration-XML interpreter */ protected void buildInterpreter() { RuleStore rs = new SimpleRuleStore(context); addInstanceRules(rs); this.interpreter = new Interpreter(context, rs, initialElementPath()); InterpretationContext interpretationContext = interpreter.getInterpretationContext(); interpretationContext.setContext(context); addImplicitRules(interpreter); addDefaultNestedComponentRegistryRules(interpretationContext.getDefaultNestedComponentRegistry()); }
public void characters(BodyEvent be) { setDocumentLocator(be.locator); String body = be.getText(); List<Action> applicableActionList = actionListStack.peek(); if (body != null) { body = body.trim(); if (body.length() > 0) { // System.out.println("calling body method with ["+body+ "]"); callBodyAction(applicableActionList, body); } } }
public void endElement(EndEvent endEvent) { setDocumentLocator(endEvent.locator); endElement(endEvent.namespaceURI, endEvent.localName, endEvent.qName); }
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 applicableActionList = (List) actionListStack.pop(); if (skip != null) { if (skip.equals(pattern)) { skip = null; } } else if (applicableActionList != EMPTY_LIST) { callEndAction(applicableActionList, getTagName(localName, qName)); } // given that we always push, we must also pop the pattern pattern.pop(); }
/** * @deprecated replaced by {@link #getInterpretationContext()} */ public InterpretationContext getExecutionContext() { return getInterpretationContext(); }
@Override protected void buildInterpreter() { super.buildInterpreter(); RuleStore ruleStore = interpreter.getRuleStore(); ruleStore.addRule(new Pattern("configuration/contextName"), new ContextConfigAction(cConf)); ruleStore.addRule(new Pattern("configuration/appender"), new WrapAppenderAction<ILoggingEvent>()); }
@Override protected void buildInterpreter() { super.buildInterpreter(); Map<String, Object> omap = interpreter.getInterpretationContext().getObjectMap(); omap.put(ActionConst.APPENDER_BAG, new HashMap()); omap.put(ActionConst.FILTER_CHAIN_BAG, new HashMap()); Map<String, String> propertiesMap = new HashMap<String, String>(); propertiesMap.putAll(parentPropertyMap); propertiesMap.put(key, value); interpreter.setInterpretationContextPropertiesMap(propertiesMap); }
public void play(List<SaxEvent> aSaxEventList) { eventList = aSaxEventList; SaxEvent se; for(currentIndex = 0; currentIndex < eventList.size(); currentIndex++) { se = eventList.get(currentIndex); if(se instanceof StartEvent) { interpreter.startElement((StartEvent) se); // invoke fireInPlay after startElement processing interpreter.getInterpretationContext().fireInPlay(se); } if(se instanceof BodyEvent) { // invoke fireInPlay before characters processing interpreter.getInterpretationContext().fireInPlay(se); interpreter.characters((BodyEvent) se); } if(se instanceof EndEvent) { // invoke fireInPlay before endElement processing interpreter.getInterpretationContext().fireInPlay(se); interpreter.endElement((EndEvent) se); } } }