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


Java Strings.trimToNull方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:13,代码来源:PropertiesConfigurationBuilder.java

示例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;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:38,代码来源:PropertiesConfigurationBuilder.java

示例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);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:29,代码来源:PropertiesConfigurationBuilder.java


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