当前位置: 首页>>代码示例>>Java>>正文


Java InterpretationContext.addError方法代码示例

本文整理汇总了Java中ch.qos.logback.core.joran.spi.InterpretationContext.addError方法的典型用法代码示例。如果您正苦于以下问题:Java InterpretationContext.addError方法的具体用法?Java InterpretationContext.addError怎么用?Java InterpretationContext.addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.core.joran.spi.InterpretationContext的用法示例。


在下文中一共展示了InterpretationContext.addError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: begin

import ch.qos.logback.core.joran.spi.InterpretationContext; //导入方法依赖的package包/类
public void begin(InterpretationContext ic, String name, Attributes attributes) {
  String valueStr = attributes.getValue(VALUE_ATR);

  if (OptionHelper.isEmpty(valueStr)) {
    ic.addError("The literal action requires a value attribute");
    return;
  }

  try {
    Integer i = Integer.valueOf(valueStr);
    ic.pushObject(i);
  } catch (NumberFormatException nfe) {
    ic.addError("The value [" + valueStr
        + "] could not be converted to an Integer", nfe);
    throw nfe;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:LiteralAction.java

示例2: fetchInteger

import ch.qos.logback.core.joran.spi.InterpretationContext; //导入方法依赖的package包/类
/**
 * Pop the Integer object at the top of the stack. This code illustrates usage
 * of Joran's error handling paradigm.
 */
int fetchInteger(InterpretationContext ic) {
  int result = 0;

  try {
    Object o1 = ic.popObject();

    if (o1 instanceof Integer) {
      result = ((Integer) o1).intValue();
    } else {
      String errMsg = "Object [" + o1
          + "] currently at the top of the stack is not an integer.";
      ic.addError(errMsg);
      throw new IllegalArgumentException(errMsg);
    }
  } catch (EmptyStackException ese) {
    ic.addError("Expecting an integer on the execution stack.");
    throw ese;
  }
  return result;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:25,代码来源:MultiplyAction.java

示例3: fetchInteger

import ch.qos.logback.core.joran.spi.InterpretationContext; //导入方法依赖的package包/类
/**
 * Pop the Integer object at the top of the stack.
 * This code also  illustrates usage of Joran's error handling paradigm. 
 */
int fetchInteger(InterpretationContext ic) {
  int result = 0;

  try {
    // Pop the object at the top of the interpretation context's stack.
    Object o1 = ic.popObject();

    if (o1 instanceof Integer) {
      result = ((Integer) o1).intValue();
    } else {
      String errMsg =
        "Object [" + o1
        + "] currently at the top of the stack is not an integer.";
      ic.addError(errMsg);
      throw new IllegalArgumentException(errMsg);
    }
  } catch (EmptyStackException ese) {
    ic.addError(("Expecting an integer on the execution stack."));
    throw ese;
  }
  return result;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:27,代码来源:AddAction.java

示例4: begin

import ch.qos.logback.core.joran.spi.InterpretationContext; //导入方法依赖的package包/类
/**
 * Instantiates an layout of the given class and sets its name.
 *
 */
@SuppressWarnings("unchecked")
public void begin(InterpretationContext ec, String localName, Attributes attributes) {
  // Let us forget about previous errors (in this object)
  inError = false;

  String errorMsg;
  String conversionWord =
    attributes.getValue(ActionConst.CONVERSION_WORD_ATTRIBUTE);
  String converterClass =
    attributes.getValue(ActionConst.CONVERTER_CLASS_ATTRIBUTE);

  if (OptionHelper.isEmpty(conversionWord)) {
    inError = true;
    errorMsg = "No 'conversionWord' attribute in <conversionRule>";
    addError(errorMsg);

    return;
  }

  if (OptionHelper.isEmpty(converterClass)) {
    inError = true;
    errorMsg = "No 'converterClass' attribute in <conversionRule>";
    ec.addError(errorMsg);

    return;
  }

  try {
    Map<String, String> ruleRegistry = (Map) context.getObject(CoreConstants.PATTERN_RULE_REGISTRY);
    if(ruleRegistry == null) {
      ruleRegistry = new HashMap<String, String>();
      context.putObject(CoreConstants.PATTERN_RULE_REGISTRY, ruleRegistry);
    }
    // put the new rule into the rule registry
    addInfo("registering conversion word "+conversionWord+" with class ["+converterClass+"]");
    ruleRegistry.put(conversionWord, converterClass);
  } catch (Exception oops) {
    inError = true;
    errorMsg = "Could not add conversion rule to PatternLayout.";
    addError(errorMsg);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:47,代码来源:ConversionRuleAction.java

示例5: begin

import ch.qos.logback.core.joran.spi.InterpretationContext; //导入方法依赖的package包/类
/**
 * Instantiates an a data source and bind it to JNDI
 * Most of the required parameters are placed in the ec.substitutionProperties
 */
public void begin(
    InterpretationContext ec, String localName, Attributes attributes) {
  String dsClassName = ec.getProperty(DATA_SOURCE_CLASS);

  if (OptionHelper.isEmpty(dsClassName)) {
    addWarn("dsClassName is a required parameter");
    ec.addError("dsClassName is a required parameter");

    return;
  }

  String urlStr = ec.getProperty(URL);
  String userStr = ec.getProperty(USER);
  String passwordStr = ec.getProperty(PASSWORD);

  try {
    DataSource ds =
      (DataSource) OptionHelper.instantiateByClassName(dsClassName, DataSource.class, context);

    PropertySetter setter = new PropertySetter(ds);
    setter.setContext(context);

    if (!OptionHelper.isEmpty(urlStr)) {
      setter.setProperty("url", urlStr);
    }

    if (!OptionHelper.isEmpty(userStr)) {
      setter.setProperty("user", userStr);
    }

    if (!OptionHelper.isEmpty(passwordStr)) {
      setter.setProperty("password", passwordStr);
    }

    Context ctx = new InitialContext();
    ctx.rebind("dataSource", ds);
  } catch (Exception oops) {
    addError(
      "Could not bind  datasource. Reported error follows.", oops);
    ec.addError("Could not not bind  datasource of type [" + dsClassName + "].");
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:47,代码来源:BindDataSourceToJNDIAction.java


注:本文中的ch.qos.logback.core.joran.spi.InterpretationContext.addError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。