ch.qos.logback.core.joran.spi.Interpreter类的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(524)

本文整理了Java中ch.qos.logback.core.joran.spi.Interpreter类的一些代码示例,展示了Interpreter类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Interpreter类的具体详情如下:
包路径:ch.qos.logback.core.joran.spi.Interpreter
类名称:Interpreter

Interpreter介绍

[英]Interpreter is Joran's main driving class. It extends SAX org.xml.sax.helpers.DefaultHandler which invokes various Action according to predefined patterns.

Patterns are kept in a RuleStore which is programmed to store and then later produce the applicable actions for a given pattern.

The pattern corresponding to a top level <a> element is the string "a".

The pattern corresponding to an element <b> embedded within a top level <a> element is the string "a/b".

The pattern corresponding to an <b> and any level of nesting is "/b. Thus, the * character placed at the beginning of a pattern serves as a wildcard for the level of nesting. Conceptually, this is very similar to the API of commons-digester. Joran offers several small advantages. First and foremost, it offers support for implicit actions which result in a significant leap in flexibility. Second, in our opinion better error reporting capability. Third, it is self-reliant. It does not depend on other APIs, in particular commons-logging which is too unreliable. Last but not least, Joran is quite tiny and is expected to remain so.
[中]Interpreter是Joran的主要驾驶课程。它扩展了SAX组织。xml。萨克斯。帮手。DefaultHandler,它根据预定义的模式调用各种操作。
模式保存在一个规则库中,该规则库被编程为存储,然后为给定的模式生成适用的操作。
与顶级<a>元素对应的模式是字符串"a"
与嵌入顶层<a>元素中的元素<b>对应的模式是字符串"a/b"
对应于<b>和任何嵌套级别的模式是“
/b。因此,放置在模式开头的*字符用作嵌套级别的通配符。从概念上讲,这与commons digester的API非常相似。Joran提供了几个小优势。首先,它支持隐式操作,这导致灵活性的显著飞跃。其次,在我们看来n更好的错误报告功能。第三,它是自力更生的。它不依赖于其他API,尤其是commons日志,因为它太不可靠了。最后但并非最不重要的一点是,乔兰身材矮小,预计将继续如此。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

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);
  }
 
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@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);
}

代码示例来源:origin: org.springframework.boot/spring-boot

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);
}

代码示例来源:origin: ch.qos.logback/logback-classic

@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);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void endElement(EndEvent endEvent) {
 setDocumentLocator(endEvent.locator);
 endElement(endEvent.namespaceURI, endEvent.localName, endEvent.qName);
}

代码示例来源:origin: camunda/camunda-bpm-platform

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);
  }
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

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);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

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());
}

代码示例来源:origin: camunda/camunda-bpm-platform

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();
}

代码示例来源:origin: ch.qos.logback/logback-classic

@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();
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

addInfo("About to add new Joran parsing rule [" + pattern + ","
   + actionClass + "].");
 ec.getJoranInterpreter().getRuleStore().addRule(new ElementSelector(pattern),
   actionClass);
} catch (Exception oops) {

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

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);
  }
}

代码示例来源:origin: tony19/logback-android

/**
 * 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());
}

代码示例来源:origin: tony19/logback-android

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);
  }
 }
}

代码示例来源:origin: tony19/logback-android

public void endElement(EndEvent endEvent) {
 setDocumentLocator(endEvent.locator);
 endElement(endEvent.namespaceURI, endEvent.localName, endEvent.qName);
}

代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand

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();
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * @deprecated replaced by {@link #getInterpretationContext()}
 */
public InterpretationContext getExecutionContext() {
 return getInterpretationContext();
}

代码示例来源:origin: caskdata/cdap

@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>());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@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);
}

代码示例来源:origin: tony19/logback-android

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);
  }
 }
}

相关文章