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


Java StringUtils.trimToEmpty方法代码示例

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


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

示例1: Version

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private Version(String version) {
  this.name = StringUtils.trimToEmpty(version);
  this.qualifier = StringUtils.substringAfter(this.name, "-");
  String numbers = StringUtils.substringBefore(this.name, "-");
  String[] split = StringUtils.split(numbers, '.');
  if (split.length >= 1) {
    major = split[0];
    normalizedMajor = normalizePart(major);
  }
  if (split.length >= 2) {
    minor = split[1];
    normalizedMinor = normalizePart(minor);
  }
  if (split.length >= 3) {
    patch = split[2];
    normalizedPatch = normalizePart(patch);
  }
  if (split.length >= 4) {
    patch2 = split[3];
    normalizedPatch2 = normalizePart(patch2);
  }
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:23,代码来源:Version.java

示例2: findFirst

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static String findFirst(String originalStr, String regex) {
    if (StringUtils.isBlank(originalStr) || StringUtils.isBlank(regex)) {
        return StringUtils.EMPTY;
    }

    PatternMatcher matcher = new Perl5Matcher();
    if (matcher.contains(originalStr, patterns.get(regex))) {
        return StringUtils.trimToEmpty(matcher.getMatch().group(0));
    }
    return StringUtils.EMPTY;
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:12,代码来源:RegexUtils.java

示例3: DefaultModuleCfg

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public DefaultModuleCfg(YMP owner) {
    Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(IOAuth.MODULE_NAME);
    //
    __accessTokenExpireIn = BlurObject.bind(_moduleCfgs.get("access_token_expire_in")).toIntValue();
    if (__accessTokenExpireIn <= 0) {
        __accessTokenExpireIn = 7200;
    }
    //
    __cacheNamePrefix = StringUtils.trimToEmpty(_moduleCfgs.get("cache_name_prefix"));
    //
    __snsEnabled = BlurObject.bind(_moduleCfgs.get("sns_enabled")).toBooleanValue();
    if (__snsEnabled) {
        __authorizationView = StringUtils.defaultIfBlank(_moduleCfgs.get("authorization_view"), "_views/oauth2/sns-authorization");
        __userInfoAdaptor = ClassUtils.impl(_moduleCfgs.get("userinfo_adapter_class"), IOAuthUserInfoAdapter.class, getClass());
    }
    //
    __tokenGenerator = ClassUtils.impl(_moduleCfgs.get("token_generator_class"), IOAuthTokenGenerator.class, getClass());
    if (__tokenGenerator == null) {
        __tokenGenerator = new DefaultTokenGenerator();
    }
    //
    __storageAdapter = ClassUtils.impl(_moduleCfgs.get("storage_adapter_class"), IOAuthStorageAdapter.class, getClass());
}
 
开发者ID:suninformation,项目名称:ymate-module-oauth,代码行数:24,代码来源:DefaultModuleCfg.java

示例4: doCheckCredentialsId

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Validator for the 'Login credentials' field.
 * 
 * @param credentialsId
 *            login credentials passed from the config.jelly "credentialsId" field
 * 
 * @return validation message
 */
public FormValidation doCheckCredentialsId(@QueryParameter String credentialsId)
{
	String tempValue = StringUtils.trimToEmpty(credentialsId);
	if (tempValue.isEmpty())
	{
		return FormValidation.error(Messages.checkLoginCredentialsError());
	}

	return FormValidation.ok();
}
 
开发者ID:Compuware-Corp,项目名称:CPWR-CodeCoverage,代码行数:19,代码来源:CodeCoverageBuilder.java

示例5: groupSessionPath

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * <pre>
 * key=sessionId
 * value=pathList
 * </pre>
 */
private Map<String, List<String>> groupSessionPath(String cmdresult) {
    String[] result = cmdresult.split(WRAP);

    Map<String, List<String>> pathMap = new HashMap<String, List<String>>();
    String sessionId = StringUtils.EMPTY;
    for (String line : result) {
        line = StringUtils.trimToEmpty(line);
        if (StringUtils.isBlank(line)) {
            continue;
        }
        if (line.startsWith("0x")) {
            sessionId = line.replace(COLON, StringUtils.EMPTY);
            pathMap.put(sessionId, new ArrayList<String>());
        } else if (line.startsWith("/")) {
            List<String> paths = pathMap.get(sessionId);
            paths.add(line);
        }
    }
    return pathMap;
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:27,代码来源:AutoKeeperCollector.java

示例6: DefaultModuleCfg

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public DefaultModuleCfg(YMP owner) {
    __moduleCfgs = owner.getConfig().getModuleConfigs(IOAuthConnector.MODULE_NAME);
    //
    __cacheNamePrefix = StringUtils.trimToEmpty(__moduleCfgs.get("cache_name_prefix"));
    //
    __callbackHandler = ClassUtils.impl(__moduleCfgs.get("callback_handler_class"), IOAuthConnectCallbackHandler.class, this.getClass());
    if (__callbackHandler == null) {
        __callbackHandler = new DefaultConnectCallbackHandler();
    }
    //
    __isPasswordEncrypted = BlurObject.bind(__moduleCfgs.get("password_encrypted")).toBooleanValue();
    //
    try {
        __password = ClassUtils.impl(__moduleCfgs.get("password_class"), IPasswordProcessor.class, this.getClass());
    } catch (Exception ignored) {
    }
}
 
开发者ID:suninformation,项目名称:ymate-module-oauth-connector,代码行数:18,代码来源:DefaultModuleCfg.java

示例7: DefaultModuleCfg

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public DefaultModuleCfg(YMP owner) {
    Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(ISSO.MODULE_NAME);
    //
    __tokenCookieName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_cookie_name"), ISSO.MODULE_NAME + "_token");
    //
    __tokenHeaderName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_header_name"), "X-ModuleSSO-Token");
    //
    __tokenParamName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_param_name"), "token");
    //
    __tokenMaxage = BlurObject.bind(_moduleCfgs.get("token_maxage")).toIntValue();
    //
    __tokenValidateTimeInterval = BlurObject.bind(_moduleCfgs.get("token_validate_time_interval")).toIntValue();
    //
    __cacheNamePrefix = StringUtils.trimToEmpty(_moduleCfgs.get("cache_name_prefix"));
    //
    __multiSessionEnabled = BlurObject.bind(_moduleCfgs.get("multi_session_enabled")).toBooleanValue();
    //
    __ipCheckEnabled = BlurObject.bind(_moduleCfgs.get("ip_check_enabled")).toBooleanValue();
    //
    __isClientMode = BlurObject.bind(_moduleCfgs.get("client_mode")).toBooleanValue();
    //
    __serviceAuthKey = StringUtils.trimToEmpty(_moduleCfgs.get("service_auth_key"));
    //
    if (__isClientMode) {
        __serviceBaseUrl = StringUtils.trimToNull(_moduleCfgs.get("service_base_url"));
        if (__serviceBaseUrl != null) {
            if (!StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "http://") &&
                    !StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "https://")) {
                throw new IllegalArgumentException("The parameter service_base_url is invalid");
            } else if (!StringUtils.endsWith(__serviceBaseUrl, "/")) {
                __serviceBaseUrl = __serviceBaseUrl + "/";
            }
        }
    }
    //
    __tokenApater = ClassUtils.impl(_moduleCfgs.get("token_adapter_class"), ISSOTokenAdapter.class, getClass());
    if (__tokenApater == null) {
        __tokenApater = new DefaultSSOTokenAdapter();
    }
    //
    __tokenStorageAdapter = ClassUtils.impl(_moduleCfgs.get("storage_adapter_class"), ISSOTokenStorageAdapter.class, getClass());
    if (!__isClientMode && __tokenStorageAdapter == null) {
        throw new IllegalArgumentException("The parameter storage_adapter_class is invalid");
    }
    //
    if (!__isClientMode) {
        __tokenAttributeAdapter = ClassUtils.impl(_moduleCfgs.get("attribute_adapter_class"), ISSOTokenAttributeAdapter.class, getClass());
    }
}
 
开发者ID:suninformation,项目名称:ymate-module-sso,代码行数:50,代码来源:DefaultModuleCfg.java

示例8: sort

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Sorts the playlist according to the given sort order.
 */
public synchronized void sort(final SortOrder sortOrder) {
    makeBackup();
    MediaFile currentFile = getCurrentFile();

    Comparator<MediaFile> comparator = new Comparator<MediaFile>() {
        public int compare(MediaFile a, MediaFile b) {
            switch (sortOrder) {
                case TRACK:
                    Integer trackA = a.getTrackNumber();
                    Integer trackB = b.getTrackNumber();
                    if (trackA == null) {
                        trackA = 0;
                    }
                    if (trackB == null) {
                        trackB = 0;
                    }
                    return trackA.compareTo(trackB);

                case ARTIST:
                    String artistA = StringUtils.trimToEmpty(a.getArtist());
                    String artistB = StringUtils.trimToEmpty(b.getArtist());
                    return artistA.compareTo(artistB);

                case ALBUM:
                    String albumA = StringUtils.trimToEmpty(a.getAlbumName());
                    String albumB = StringUtils.trimToEmpty(b.getAlbumName());
                    return albumA.compareTo(albumB);
                default:
                    return 0;
            }
        }
    };

    Collections.sort(files, comparator);
    if (currentFile != null) {
        index = files.indexOf(currentFile);
    }
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:42,代码来源:PlayQueue.java

示例9: DLockConfig

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Constructor with lockType & lockTarget & leaseTime & leaseTimeUnit
 */
public DLockConfig(String lockType, String lockTarget, int lease, TimeUnit leaseTimeUnit) {
    this.lockType = lockType;
    this.lockTarget = lockTarget;
    this.lockUniqueKey = UK_PRE + UK_SP + lockType + UK_SP + StringUtils.trimToEmpty(lockTarget);
    this.lease = lease;
    this.leaseTimeUnit = leaseTimeUnit;
}
 
开发者ID:baidu,项目名称:dlock,代码行数:11,代码来源:DLockConfig.java

示例10: GfshMethodTarget

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Constructor that allows all fields to be set
 * 
 * @param method the method to invoke (required)
 * @param target the object on which the method is to be invoked (required)
 * @param remainingBuffer can be blank
 * @param key can be blank
 */
public GfshMethodTarget(final Method method, final Object target, final String remainingBuffer,
    final String key) {
  Assert.notNull(method, "Method is required");
  Assert.notNull(target, "Target is required");
  this.key = StringUtils.trimToEmpty(key);
  this.method = method;
  this.remainingBuffer = remainingBuffer;
  this.target = target;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:GfshMethodTarget.java

示例11: doCheckConnectionId

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Validator for the 'Host connection' field.
 * 
 * @param connectionId
 *            unique identifier for the host connection passed from the config.jelly "connectionId" field
 * 
 * @return validation message
 */
public FormValidation doCheckConnectionId(@QueryParameter String connectionId)
{
	String tempValue = StringUtils.trimToEmpty(connectionId);
	if (tempValue.isEmpty())
	{
		return FormValidation.error(Messages.checkHostConnectionError());
	}

	return FormValidation.ok();
}
 
开发者ID:Compuware-Corp,项目名称:CPWR-CodeCoverage,代码行数:19,代码来源:CodeCoverageBuilder.java

示例12: collectorConnectionStat

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public void collectorConnectionStat(String address) {
    List<String> netAddress = splitAddress(address);
    if (netAddress.isEmpty()) {
        return;
    }
    String ip = netAddress.get(0);
    String port = netAddress.get(1);
    String[] cmd = { "/bin/bash", "-c", String.format(CMD_CONS, ip, port) };
    String cmdresult = collector(cmd);
    String[] result = cmdresult.split(WRAP);
    List<AutoKeeperConnectionStat> summary = new ArrayList<AutoKeeperConnectionStat>();

    for (String line : result) {

        if (StringUtils.isBlank(line)) {
            continue;
        }

        String[] lineArray = line.split(":");
        if (2 != lineArray.length) {
            continue;
        }

        AutoKeeperConnectionStat autoKeeperConnectionStat = new AutoKeeperConnectionStat();
        autoKeeperConnectionStat.setOriginalContent(line);
        String clientIp = StringUtils.trimToEmpty(line.split(":")[0].replace("/", ""));
        String sessionId = StringUtils.trimToEmpty(RegexUtils.findFirst(line.split(":")[1], "sid=(?s).*?[,)]")).replace("sid=",
                                                                                                                        StringUtils.EMPTY).replace(COMMA,
                                                                                                                                                   StringUtils.EMPTY).replace(BRACKETS,
                                                                                                                                                                              StringUtils.EMPTY);
        String queued = StringUtils.trimToEmpty(RegexUtils.findFirst(line.split(":")[1], "queued=(?s).*?[,)]")).replace("queued=",
                                                                                                                        StringUtils.EMPTY).replace(COMMA,
                                                                                                                                                   StringUtils.EMPTY).replace(BRACKETS,
                                                                                                                                                                              StringUtils.EMPTY);
        String receive = StringUtils.trimToEmpty(RegexUtils.findFirst(line.split(":")[1], "recved=(?s).*?[,)]")).replace("recved=",
                                                                                                                         StringUtils.EMPTY).replace(COMMA,
                                                                                                                                                    StringUtils.EMPTY).replace(BRACKETS,
                                                                                                                                                                               StringUtils.EMPTY);
        String sent = StringUtils.trimToEmpty(RegexUtils.findFirst(line.split(":")[1], "sent=(?s).*?[,)]")).replace("sent=",
                                                                                                                    StringUtils.EMPTY).replace(COMMA,
                                                                                                                                               StringUtils.EMPTY).replace(BRACKETS,
                                                                                                                                                                          StringUtils.EMPTY);
        String minlat = StringUtils.trimToEmpty(RegexUtils.findFirst(line.split(":")[1], "minlat=(?s).*?[,)]")).replace("minlat=",
                                                                                                                        StringUtils.EMPTY).replace(COMMA,
                                                                                                                                                   StringUtils.EMPTY).replace(BRACKETS,
                                                                                                                                                                              StringUtils.EMPTY);
        String avglat = StringUtils.trimToEmpty(RegexUtils.findFirst(line.split(":")[1], "avglat=(?s).*?[,)]")).replace("avglat=",
                                                                                                                        StringUtils.EMPTY).replace(COMMA,
                                                                                                                                                   StringUtils.EMPTY).replace(BRACKETS,
                                                                                                                                                                              StringUtils.EMPTY);
        String maxlat = StringUtils.trimToEmpty(RegexUtils.findFirst(line.split(":")[1], "maxlat=(?s).*?[,)]")).replace("maxlat=",
                                                                                                                        StringUtils.EMPTY).replace(COMMA,
                                                                                                                                                   StringUtils.EMPTY).replace(BRACKETS,
                                                                                                                                                                              StringUtils.EMPTY);
        autoKeeperConnectionStat.setServerAddress(ip);
        autoKeeperConnectionStat.setClientAddress(clientIp);
        autoKeeperConnectionStat.setSessionId(sessionId);
        if (StringUtils.isNotEmpty(queued)) {
            autoKeeperConnectionStat.setQueued(Long.parseLong(queued));
        }
        if (StringUtils.isNotEmpty(receive)) {
            autoKeeperConnectionStat.setRecved(Long.parseLong(receive));
        }
        if (StringUtils.isNotEmpty(sent)) {
            autoKeeperConnectionStat.setSent(Long.parseLong(sent));
        }
        if (StringUtils.isNotEmpty(minlat)) {
            autoKeeperConnectionStat.setMinLatency(Long.parseLong(minlat));
        }
        if (StringUtils.isNotEmpty(avglat)) {
            autoKeeperConnectionStat.setAvgLatency(Long.parseLong(avglat));
        }
        if (StringUtils.isNotEmpty(maxlat)) {
            autoKeeperConnectionStat.setMaxLatency(Long.parseLong(maxlat));
        }

        summary.add(autoKeeperConnectionStat);
    }
    autoKeeperData.joinConnection(address, summary);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:81,代码来源:AutoKeeperCollector.java

示例13: generateKey

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
protected static String generateKey(String dataId, String groupId) {
    return StringUtils.trimToEmpty(dataId) + "_" + StringUtils.trimToEmpty(groupId);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:4,代码来源:AbstractSubscribeManager.java

示例14: formatPlain

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
protected String formatPlain(String content) {
    // TODO do a proper algorithm

    try {
        int maxLine = 0;


        List<String> linesIn = IOUtils.readLines(new StringReader(content));
        for (int i = 0; i < linesIn.size(); i++) {
            if (linesIn.get(i).startsWith(">")) {
                maxLine = i - (StringUtils.isBlank(linesIn.get(i - 1)) ? 2 : 1);
                break;
            }
        }

        List<String> linesOut = new ArrayList<>();
        boolean prevLineBlank = false;
        for (int i = 0; i < maxLine; i++) {
            String line = StringUtils.trimToEmpty(linesIn.get(i));
            if (StringUtils.isBlank(line)) {
                if (prevLineBlank) {
                    continue;
                }

                prevLineBlank = true;
            } else {
                prevLineBlank = false;
            }
            linesOut.add(line);
        }

        if (prevLineBlank) {
            linesOut.remove(linesOut.size() - 1);
        }

        return StringUtils.join(linesOut, System.lineSeparator());
    } catch (IOException e) {
        // This should never happen, we can't deal with it here
        throw new RuntimeException(e);
    }
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:42,代码来源:AEmailClientFormatter.java

示例15: CodeCoverageBuilder

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param connectionId
			  a unique host connection identifier
 * @param credentialsId
 *            unique id of the selected credential
 * @param analysisPropertiesPath
 *            the path of Code Coverage analysis properties file
 * @param analysisProperties
 *            the Code Coverage analysis properties
 */
@DataBoundConstructor
public CodeCoverageBuilder(String connectionId, String credentialsId, String analysisPropertiesPath,
		String analysisProperties)
{
	m_connectionId = StringUtils.trimToEmpty(connectionId);
	m_credentialsId = StringUtils.trimToEmpty(credentialsId);
	m_analysisPropertiesPath = StringUtils.trimToEmpty(analysisPropertiesPath);
	m_analysisProperties = StringUtils.trimToEmpty(analysisProperties);
}
 
开发者ID:Compuware-Corp,项目名称:CPWR-CodeCoverage,代码行数:22,代码来源:CodeCoverageBuilder.java


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