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


Java Strings.isEmpty方法代码示例

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


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

示例1: findClientImpl

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
public static Client findClientImpl(final String httpClientImpl) {
       Client client = null;
if (Strings.isEmpty(httpClientImpl)) {
    for (String s : Arrays.asList("be.olsson.slackappender.client.OkHttp2Client", "be.olsson.slackappender.client.OkHttp3Client")) {
	client = getClientImpl(s);
	if (client != null) {
	    break;
	}
    }
    if (client == null) {
	throw new IllegalArgumentException("Didn't find any working " + Client.class.getName() + " implementation called " + httpClientImpl);
    }
} else {
    client = getClientImpl(httpClientImpl);
    if (client == null) {
	throw new IllegalArgumentException("Didn't find any working " + Client.class.getName() + " implementation called " + httpClientImpl);
    }
}
return client;
   }
 
开发者ID:tobias-,项目名称:slack-appender,代码行数:21,代码来源:SlackAppender.java

示例2: build

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public Serializer build() {
    if (Strings.isEmpty(pattern) && Strings.isEmpty(defaultPattern)) {
        return null;
    }
    if (patternSelector == null) {
        try {
            final PatternParser parser = createPatternParser(configuration);
            final List<PatternFormatter> list = parser.parse(pattern == null ? defaultPattern : pattern,
                    alwaysWriteExceptions, disableAnsi, noConsoleNoAnsi);
            final PatternFormatter[] formatters = list.toArray(new PatternFormatter[0]);
            return new PatternSerializer(formatters, replace);
        } catch (final RuntimeException ex) {
            throw new IllegalArgumentException("Cannot parse pattern '" + pattern + "'", ex);
        }
    }
    return new PatternSelectorSerializer(patternSelector, replace);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:19,代码来源:PatternLayout.java

示例3: build

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public PosixViewAttributeAction build() {
    if (Strings.isEmpty(basePath)) {
        LOGGER.error("Posix file attribute view action not valid because base path is empty.");
        return null;
    }

    if (filePermissions == null && Strings.isEmpty(filePermissionsString)
                && Strings.isEmpty(fileOwner) && Strings.isEmpty(fileGroup)) {
        LOGGER.error("Posix file attribute view not valid because nor permissions, user or group defined.");
        return null;
    }

    if (!FileUtils.isFilePosixAttributeViewSupported()) {
        LOGGER.warn("Posix file attribute view defined but it is not supported by this files system.");
        return null;
    }

    return new PosixViewAttributeAction(basePath, followLinks, maxDepth, pathConditions,
            subst != null ? subst : configuration.getStrSubstitutor(),
            filePermissions != null ? filePermissions :
                        filePermissionsString != null ? PosixFilePermissions.fromString(filePermissionsString) : null,
            fileOwner,
            fileGroup);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:26,代码来源:PosixViewAttributeAction.java

示例4: convertToEntityAttribute

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public ThreadContext.ContextStack convertToEntityAttribute(final String s) {
    if (Strings.isEmpty(s)) {
        return null;
    }

    List<String> list;
    try {
        list = ContextMapJsonAttributeConverter.OBJECT_MAPPER.readValue(s, new TypeReference<List<String>>() { });
    } catch (final IOException e) {
        throw new PersistenceException("Failed to convert JSON string to list for stack.", e);
    }

    final DefaultThreadContextStack result = new DefaultThreadContextStack(true);
    result.addAll(list);
    return result;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:18,代码来源:ContextStackJsonAttributeConverter.java

示例5: getSocketManager

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
public static SslSocketManager getSocketManager(final SslConfiguration sslConfig, final String host, int port,
        final int connectTimeoutMillis, int reconnectDelayMillis, final boolean immediateFail,
        final Layout<? extends Serializable> layout, final int bufferSize, final SocketOptions socketOptions) {
    if (Strings.isEmpty(host)) {
        throw new IllegalArgumentException("A host name is required");
    }
    if (port <= 0) {
        port = DEFAULT_PORT;
    }
    if (reconnectDelayMillis == 0) {
        reconnectDelayMillis = DEFAULT_RECONNECTION_DELAY_MILLIS;
    }
    final String name = "TLS:" + host + ':' + port;
    return (SslSocketManager) getManager(name, new SslFactoryData(sslConfig, host, port, connectTimeoutMillis,
            reconnectDelayMillis, immediateFail, layout, bufferSize, socketOptions), FACTORY);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:SslSocketManager.java

示例6: createAppender

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private AppenderComponentBuilder createAppender(final String key, final Properties properties) {
    final String name = (String) properties.remove(CONFIG_NAME);
    if (Strings.isEmpty(name)) {
        throw new ConfigurationException("No name attribute provided for Appender " + key);
    }
    final String type = (String) properties.remove(CONFIG_TYPE);
    if (Strings.isEmpty(type)) {
        throw new ConfigurationException("No type attribute provided for Appender " + key);
    }
    final AppenderComponentBuilder appenderBuilder = builder.newAppender(name, type);
    addFiltersToComponent(appenderBuilder, properties);
    final Properties layoutProps = PropertiesUtil.extractSubset(properties, "layout");
    if (layoutProps.size() > 0) {
        appenderBuilder.add(createLayout(name, layoutProps));
    }

    return processRemainingProperties(appenderBuilder, properties);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:19,代码来源:PropertiesConfigurationBuilder.java

示例7: createColumnConfig

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
/**
 * Factory method for creating a column config within the plugin manager.
 *
 * @see Builder
 * @deprecated use {@link #newBuilder()}
 */
@Deprecated
public static ColumnConfig createColumnConfig(final Configuration config, final String name, final String pattern,
                                              final String literalValue, final String eventTimestamp,
                                              final String unicode, final String clob) {
    if (Strings.isEmpty(name)) {
        LOGGER.error("The column config is not valid because it does not contain a column name.");
        return null;
    }

    final boolean isEventTimestamp = Boolean.parseBoolean(eventTimestamp);
    final boolean isUnicode = Booleans.parseBoolean(unicode, true);
    final boolean isClob = Boolean.parseBoolean(clob);

    return newBuilder()
        .setConfiguration(config)
        .setName(name)
        .setPattern(pattern)
        .setLiteral(literalValue)
        .setEventTimestamp(isEventTimestamp)
        .setUnicode(isUnicode)
        .setClob(isClob)
        .build();
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:30,代码来源:ColumnConfig.java

示例8: addPortToEndpoints

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
/**
 * Adds information about a {@link Port} to the provided {@code endpointsByName}. Information
 * will be added for any VIPs listed against the {@link Port}'s labels, or if no VIPs are found,
 * the information will be added against the task type.
 *
 * @param endpointsByName the map to write to
 * @param serviceName the name of the parent service
 * @param taskName the name of the task which has the port in question
 * @param taskInfoPort the port being added (from the task's DiscoveryInfo)
 * @param autoipHostPort the host:port value to advertise for connecting to the task over DNS
 * @param ipHostPort the host:port value to advertise for connecting to the task's IP
 * @throws TaskException if no VIPs were found and the task type couldn't be extracted
 */
private static void addPortToEndpoints(
        Map<String, JSONObject> endpointsByName,
        String serviceName,
        String taskName,
        Port taskInfoPort,
        String autoipHostPort,
        String ipHostPort) throws TaskException {
    if (Strings.isEmpty(taskInfoPort.getName())) {
        // Older tasks may omit the port name in their DiscoveryInfo. In practice this shouldn't happen because
        // tasks that old should have been long updated/relaunched by the time this is invoked, but just in case...
        LOGGER.warn("Missing port name. Old task?: {}", TextFormat.shortDebugString(taskInfoPort));
        return;
    }

    // Search for any VIPs to list the port against:
    Collection<EndpointUtils.VipInfo> vips = AuxLabelAccess.getVIPsFromLabels(taskName, taskInfoPort);

    for (EndpointUtils.VipInfo vip : vips) {
        // VIP found. file host:port against the PORT name.
        addPortAndVipToEndpoints(
                endpointsByName,
                taskInfoPort.getName(),
                autoipHostPort,
                ipHostPort,
                EndpointUtils.toVipEndpoint(serviceName, vip));
    }

    // If no VIPs were found, list the port against the port name:
    if (vips.isEmpty() && !Strings.isEmpty(taskInfoPort.getName())) {
        addPortToEndpoints(endpointsByName, taskInfoPort.getName(), autoipHostPort, ipHostPort);
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:46,代码来源:EndpointsResource.java

示例9: TaskPortLookup

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
TaskPortLookup(Protos.TaskInfo currentTask) {
    this.lastTaskPorts = new HashMap<>();
    for (Protos.Port port : currentTask.getDiscovery().getPorts().getPortsList()) {
        if (!Strings.isEmpty(port.getName())) {
            this.lastTaskPorts.put(port.getName(), (long) port.getNumber());
        }
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:9,代码来源:TaskPortLookup.java

示例10: getHickwallAddress

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@RequestMapping(value = "/redis/health/hickwall/" + CLUSTER_NAME_PATH_VARIABLE + "/" + SHARD_NAME_PATH_VARIABLE + "/{redisIp}/{redisPort}", method = RequestMethod.GET)
public Map<String, String> getHickwallAddress(@PathVariable String clusterName, @PathVariable String shardName, @PathVariable String redisIp, @PathVariable int redisPort) {
    String addr = config.getHickwallAddress();
    if (Strings.isEmpty(addr)) {
        return ImmutableMap.of("addr", "");
    }
    return ImmutableMap.of("addr", String.format("%s.%s.%s.%s.%s*", addr, clusterName, shardName, redisIp, redisPort));
}
 
开发者ID:ctripcorp,项目名称:x-pipe,代码行数:9,代码来源:HealthCheckController.java

示例11: executeSqlScript

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
protected void executeSqlScript(String prepareSql) throws ComponentLookupException, SQLException {

        DataSourceManager dsManager = ContainerLoader.getDefaultContainer().lookup(DataSourceManager.class);

        Connection conn = null;
        PreparedStatement stmt = null;
        try {
            conn = dsManager.getDataSource(DATA_SOURCE).getConnection();
            conn.setAutoCommit(false);
            if (!Strings.isEmpty(prepareSql)) {
                for (String sql : prepareSql.split(";")) {
                    logger.debug("[setup][data]{}", sql.trim());
                    stmt = conn.prepareStatement(sql);
                    stmt.executeUpdate();
                }
            }
            conn.commit();

        } catch (Exception ex) {
            logger.error("[SetUpTestDataSource][fail]:", ex);
            if (null != conn) {
                conn.rollback();
            }
        } finally {
            if (null != stmt) {
                stmt.close();
            }
            if (null != conn) {
                conn.setAutoCommit(true);
                conn.close();
            }
        }
    }
 
开发者ID:ctripcorp,项目名称:x-pipe,代码行数:34,代码来源:AbstractConsoleH2DbTest.java

示例12: getConnectedClient

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private MongoClient getConnectedClient() {
  if (Strings.isEmpty(username)) {
    return new MongoClient(host, port);
  } else {
    MongoCredential credential =
        MongoCredential.createCredential(username, databaseName, password.toCharArray());
    return new MongoClient(new ServerAddress(host, port), Lists.newArrayList(credential));
  }
}
 
开发者ID:fengyouchao,项目名称:sockslib,代码行数:10,代码来源:MongoDBUtil.java

示例13: setLocaleCode

import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
public void setLocaleCode(String localeCode) {
    Iterator<Locale> locales = FacesContext.getCurrentInstance().getApplication().getSupportedLocales();
    while (locales.hasNext()) {
        Locale locale = locales.next();
        if (!Strings.isEmpty(locale.getLanguage()) && locale.getLanguage().equals(localeCode)) {
            this.localeCode = localeCode;
            FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(localeCode));
            setCookieValue(localeCode);
        }
    }
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:12,代码来源:LanguageBean.java

示例14: createField

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

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

    return new GelfDynamicMdcLogFields(regex);
}
 
开发者ID:mp911de,项目名称:logstash-gelf,代码行数:12,代码来源:GelfDynamicMdcLogFields.java

示例15: 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


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