本文整理汇总了Java中org.apache.logging.log4j.util.Strings.trimToNull方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.trimToNull方法的具体用法?Java Strings.trimToNull怎么用?Java Strings.trimToNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.util.Strings
的用法示例。
在下文中一共展示了Strings.trimToNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAppenderRef
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private AppenderRefComponentBuilder createAppenderRef(final String key, final Properties properties) {
final String ref = (String) properties.remove("ref");
if (Strings.isEmpty(ref)) {
throw new ConfigurationException("No ref attribute provided for AppenderRef " + key);
}
final AppenderRefComponentBuilder appenderRefBuilder = builder.newAppenderRef(ref);
final String level = Strings.trimToNull((String) properties.remove("level"));
if (!Strings.isEmpty(level)) {
appenderRefBuilder.addAttribute("level", level);
}
return addFiltersToComponent(appenderRefBuilder, properties);
}
示例2: createLogger
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private LoggerComponentBuilder createLogger(final String key, final Properties properties) {
final String name = (String) properties.remove(CONFIG_NAME);
final String location = (String) properties.remove("includeLocation");
if (Strings.isEmpty(name)) {
throw new ConfigurationException("No name attribute provided for Logger " + key);
}
final String level = Strings.trimToNull((String) properties.remove("level"));
final String type = (String) properties.remove(CONFIG_TYPE);
final LoggerComponentBuilder loggerBuilder;
boolean includeLocation;
if (type != null) {
if (type.equalsIgnoreCase("asyncLogger")) {
if (location != null) {
includeLocation = Boolean.parseBoolean(location);
loggerBuilder = builder.newAsyncLogger(name, level, includeLocation);
} else {
loggerBuilder = builder.newAsyncLogger(name, level);
}
} else {
throw new ConfigurationException("Unknown Logger type " + type + " for Logger " + name);
}
} else {
if (location != null) {
includeLocation = Boolean.parseBoolean(location);
loggerBuilder = builder.newLogger(name, level, includeLocation);
} else {
loggerBuilder = builder.newLogger(name, level);
}
}
addLoggersToComponent(loggerBuilder, properties);
addFiltersToComponent(loggerBuilder, properties);
final String additivity = (String) properties.remove("additivity");
if (!Strings.isEmpty(additivity)) {
loggerBuilder.addAttribute("additivity", additivity);
}
return loggerBuilder;
}
示例3: createRootLogger
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private RootLoggerComponentBuilder createRootLogger(final Properties properties) {
final String level = Strings.trimToNull((String) properties.remove("level"));
final String type = (String) properties.remove(CONFIG_TYPE);
final String location = (String) properties.remove("includeLocation");
final boolean includeLocation;
final RootLoggerComponentBuilder loggerBuilder;
if (type != null) {
if (type.equalsIgnoreCase("asyncRoot")) {
if (location != null) {
includeLocation = Boolean.parseBoolean(location);
loggerBuilder = builder.newAsyncRootLogger(level, includeLocation);
} else {
loggerBuilder = builder.newAsyncRootLogger(level);
}
} else {
throw new ConfigurationException("Unknown Logger type for root logger" + type);
}
} else {
if (location != null) {
includeLocation = Boolean.parseBoolean(location);
loggerBuilder = builder.newRootLogger(level, includeLocation);
} else {
loggerBuilder = builder.newRootLogger(level);
}
}
addLoggersToComponent(loggerBuilder, properties);
return addFiltersToComponent(loggerBuilder, properties);
}