本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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 + "].");
}
}