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


Java Strings.isNotEmpty方法代码示例

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


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

示例1: toWriteConcern

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private static WriteConcern toWriteConcern(final String writeConcernConstant,
        final String writeConcernConstantClassName) {
    WriteConcern writeConcern;
    if (Strings.isNotEmpty(writeConcernConstant)) {
        if (Strings.isNotEmpty(writeConcernConstantClassName)) {
            try {
                final Class<?> writeConcernConstantClass = LoaderUtil.loadClass(writeConcernConstantClassName);
                final Field field = writeConcernConstantClass.getField(writeConcernConstant);
                writeConcern = (WriteConcern) field.get(null);
            } catch (final Exception e) {
                LOGGER.error("Write concern constant [{}.{}] not found, using default.",
                        writeConcernConstantClassName, writeConcernConstant);
                writeConcern = DEFAULT_WRITE_CONCERN;
            }
        } else {
            writeConcern = WriteConcern.valueOf(writeConcernConstant);
            if (writeConcern == null) {
                LOGGER.warn("Write concern constant [{}] not found, using default.", writeConcernConstant);
                writeConcern = DEFAULT_WRITE_CONCERN;
            }
        }
    } else {
        writeConcern = DEFAULT_WRITE_CONCERN;
    }
    return writeConcern;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:27,代码来源:MongoDbProvider.java

示例2: toWriteConcern

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private static WriteConcern toWriteConcern(final String writeConcernConstant,
                                           final String writeConcernConstantClassName) {
    WriteConcern writeConcern;
    if (Strings.isNotEmpty(writeConcernConstant)) {
        if (Strings.isNotEmpty(writeConcernConstantClassName)) {
            try {
                final Class<?> writeConcernConstantClass = LoaderUtil.loadClass(writeConcernConstantClassName);
                final Field field = writeConcernConstantClass.getField(writeConcernConstant);
                writeConcern = (WriteConcern) field.get(null);
            } catch (final Exception e) {
                LOGGER.error("Write concern constant [{}.{}] not found, using default.",
                        writeConcernConstantClassName, writeConcernConstant);
                writeConcern = DEFAULT_WRITE_CONCERN;
            }
        } else {
            writeConcern = WriteConcern.valueOf(writeConcernConstant);
            if (writeConcern == null) {
                LOGGER.warn("Write concern constant [{}] not found, using default.", writeConcernConstant);
                writeConcern = DEFAULT_WRITE_CONCERN;
            }
        }
    } else {
        writeConcern = DEFAULT_WRITE_CONCERN;
    }

    return writeConcern;
}
 
开发者ID:toeasy,项目名称:spring-boot-boilerplate,代码行数:28,代码来源:MongoDbProvider.java

示例3: getTitle

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public ContextObject<String> getTitle() {
    AttributeValue metaTitle = getAttribute("meta_title");
    ContextObject<String> title = getLabel();

    if (metaTitle != null && Strings.isNotEmpty(ContextObjects.findCurrentLanguageOrGlobal(metaTitle.getValue()))) {
        return metaTitle.getValue();
    } else if (title != null && Strings.isNotEmpty(ContextObjects.findCurrentLanguageOrGlobal(title))) {
        return title;
    } else {
        return null;
    }
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:14,代码来源:DefaultProductList.java

示例4: getMetaDescription

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public ContextObject<String> getMetaDescription() {
    AttributeValue metaDescription = getAttribute("meta_description");
    AttributeValue description = getAttribute("description");

    if (metaDescription != null
        && Strings.isNotEmpty(ContextObjects.findCurrentLanguageOrGlobal(metaDescription.getValue()))) {
        return metaDescription.getValue();
    } else if (description != null
        && Strings.isNotEmpty(ContextObjects.findCurrentLanguageOrGlobal(description.getValue()))) {
        return description.getValue();
    } else {
        return null;
    }
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:16,代码来源:DefaultProductList.java

示例5: startServerLogger

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
/**
 * Setup log4j & Start server log
 */
private void startServerLogger() {
    String loggerConfig = ServerConstants.LOGGER_CONFIG_FILE;
    if (Strings.isNotEmpty(loggerConfig)) {
        System.setProperty(ServerConstants.LOGGER_SYSTEM_PROPERTY,
                loggerConfig);
    }
}
 
开发者ID:victor-guoyu,项目名称:Review-It,代码行数:11,代码来源:App.java

示例6: createField

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@PluginFactory
public static GelfLogField createField(@PluginConfiguration final Configuration config,
        @PluginAttribute("name") String name, @PluginAttribute("literal") String literalValue,
        @PluginAttribute("mdc") String mdc, @PluginAttribute("pattern") String pattern) {

    final boolean isPattern = Strings.isNotEmpty(pattern);
    final boolean isLiteralValue = Strings.isNotEmpty(literalValue);
    final boolean isMDC = Strings.isNotEmpty(mdc);

    if (Strings.isEmpty(name)) {
        LOGGER.error("The name is empty");
        return null;
    }

    if ((isPattern && isLiteralValue) || (isPattern && isMDC) || (isLiteralValue && isMDC)) {
        LOGGER.error("The pattern, literal, and mdc attributes are mutually exclusive.");
        return null;
    }

    if (isPattern) {

        PatternLayout patternLayout = newBuilder().withPattern(pattern).withConfiguration(config)
                .withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build();

        return new GelfLogField(name, null, null, patternLayout);
    }

    return new GelfLogField(name, literalValue, mdc, null);
}
 
开发者ID:mp911de,项目名称:logstash-gelf,代码行数:30,代码来源:GelfLogField.java

示例7: configureFields

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
/**
 * Configure fields (literals, MDC, layout).
 *
 * @param mdcGelfMessageAssembler the assembler
 * @param fields static field array
 * @param dynamicFieldArray dynamic field array
 */
private static void configureFields(MdcGelfMessageAssembler mdcGelfMessageAssembler, GelfLogField[] fields,
        GelfDynamicMdcLogFields[] dynamicFieldArray) {

	if (fields == null || fields.length == 0) {
        mdcGelfMessageAssembler.addFields(LogMessageField.getDefaultMapping(Time, Severity, ThreadName, SourceClassName,
                SourceMethodName, SourceLineNumber, SourceSimpleClassName, LoggerName, Marker));
        return;
    }

    for (GelfLogField field : fields) {

        if (Strings.isNotEmpty(field.getMdc())) {
            mdcGelfMessageAssembler.addField(new MdcMessageField(field.getName(), field.getMdc()));
        }

        if (Strings.isNotEmpty(field.getLiteral())) {
            mdcGelfMessageAssembler.addField(new StaticMessageField(field.getName(), field.getLiteral()));
        }

        if (field.getPatternLayout() != null) {
            mdcGelfMessageAssembler.addField(new PatternLogMessageField(field.getName(), null, field.getPatternLayout()));
        }
    }

    if (dynamicFieldArray != null) {
        for (GelfDynamicMdcLogFields gelfDynamicMdcLogFields : dynamicFieldArray) {
            mdcGelfMessageAssembler.addField(new DynamicMdcMessageField(gelfDynamicMdcLogFields.getRegex()));
        }
    }
}
 
开发者ID:mp911de,项目名称:logstash-gelf,代码行数:38,代码来源:GelfLogAppender.java

示例8: insertObject

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public void insertObject(final NoSqlObject<Map<String, Object>> object) {
    try {
        final Response response = this.client.save(object.unwrap());
        if (Strings.isNotEmpty(response.getError())) {
            throw new AppenderLoggingException(
                    "Failed to write log event to CouchDB due to error: " + response.getError() + '.');
        }
    } catch (final Exception e) {
        throw new AppenderLoggingException("Failed to write log event to CouchDB due to error: " + e.getMessage(),
                e);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:14,代码来源:CouchDbConnection.java

示例9: getConfiguration

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private Configuration getConfiguration(final LoggerContext loggerContext, final boolean isTest, final String name) {
    final boolean named = Strings.isNotEmpty(name);
    final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
    for (final ConfigurationFactory factory : getFactories()) {
        String configName;
        final String prefix = isTest ? TEST_PREFIX : DEFAULT_PREFIX;
        final String [] types = factory.getSupportedTypes();
        if (types == null) {
            continue;
        }

        for (final String suffix : types) {
            if (suffix.equals(ALL_TYPES)) {
                continue;
            }
            configName = named ? prefix + name + suffix : prefix + suffix;

            final ConfigurationSource source = ConfigurationSource.fromResource(configName, loader);
            if (source != null) {
                if (!factory.isActive()) {
                    LOGGER.warn("Found configuration file {} for inactive ConfigurationFactory {}", configName, factory.getClass().getName());
                }
                return factory.getConfiguration(loggerContext, source);
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:29,代码来源:ConfigurationFactory.java

示例10: discard

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
boolean discard() {
    if (discardIfEmpty == false) {
        return false;
    }
    boolean foundNotEmptyValue = false;
    for (final Map.Entry<String, String> entry : fields.entrySet()) {
        if (Strings.isNotEmpty(entry.getValue())) {
            foundNotEmptyValue = true;
            break;
        }
    }
    return !foundNotEmptyValue;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:14,代码来源:Rfc5424Layout.java

示例11: build

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public ColumnConfig build() {
    if (Strings.isEmpty(name)) {
        LOGGER.error("The column config is not valid because it does not contain a column name.");
        return null;
    }

    final boolean isPattern = Strings.isNotEmpty(pattern);
    final boolean isLiteralValue = Strings.isNotEmpty(literal);

    if ((isPattern && isLiteralValue) || (isPattern && isEventTimestamp) || (isLiteralValue && isEventTimestamp)) {
        LOGGER.error("The pattern, literal, and isEventTimestamp attributes are mutually exclusive.");
        return null;
    }

    if (isEventTimestamp) {
        return new ColumnConfig(name, null, null, true, false, false);
    }

    if (isLiteralValue) {
        return new ColumnConfig(name, null, literal, false, false, false);
    }

    if (isPattern) {
        final PatternLayout layout =
            PatternLayout.newBuilder()
                .withPattern(pattern)
                .withConfiguration(configuration)
                .withAlwaysWriteExceptions(false)
                .build();
        return new ColumnConfig(name, layout, null, false, isUnicode, isClob);
    }

    LOGGER.error("To configure a column you must specify a pattern or literal or set isEventDate to true.");
    return null;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:37,代码来源:ColumnConfig.java

示例12: logMessage

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public void logMessage(final String fqcn, final Level mgsLevel, final Marker marker, final Message msg,
        final Throwable throwable) {
    final StringBuilder sb = new StringBuilder();
    // Append date-time if so configured
    if (showDateTime) {
        final Date now = new Date();
        String dateText;
        synchronized (dateFormatter) {
            dateText = dateFormatter.format(now);
        }
        sb.append(dateText);
        sb.append(SPACE);
    }

    sb.append(mgsLevel.toString());
    sb.append(SPACE);
    if (Strings.isNotEmpty(logName)) {
        sb.append(logName);
        sb.append(SPACE);
    }
    sb.append(msg.getFormattedMessage());
    if (showContextMap) {
        final Map<String, String> mdc = ThreadContext.getImmutableContext();
        if (mdc.size() > 0) {
            sb.append(SPACE);
            sb.append(mdc.toString());
            sb.append(SPACE);
        }
    }
    final Object[] params = msg.getParameters();
    Throwable t;
    if (throwable == null && params != null && params.length > 0
            && params[params.length - 1] instanceof Throwable) {
        t = (Throwable) params[params.length - 1];
    } else {
        t = throwable;
    }
    stream.println(sb.toString());
    if (t != null) {
        stream.print(SPACE);
        t.printStackTrace(stream);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:45,代码来源:SimpleLogger.java


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