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


Java StringUtils.substringBefore方法代码示例

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


在下文中一共展示了StringUtils.substringBefore方法的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: getColumnLengthAndPrecision

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static int[] getColumnLengthAndPrecision(Column column){
	int[] ret = new int[2];
	String data = StringUtils.substringBetween(column.getMysqlType(), "(",")");
	String length = StringUtils.substringBefore(data, ",");
	String precision = StringUtils.substringAfter(data, ",");
	String type = getColumnType(column).toUpperCase();
	if("SET".equals(type) || "ENUM".equals(type)){
		ret[0] = 0;
		ret[1] = 0;
	}else{
		if(StringUtils.isEmpty(length)){
			ret[0] = 0;
		}else{
			ret[0] = Integer.parseInt(length);
		}
		if(StringUtils.isEmpty(precision)){
			ret[1] = 0;
		}else{
			ret[1] = Integer.parseInt(precision);
		}
	}
	return ret;
}
 
开发者ID:BriData,项目名称:DBus,代码行数:24,代码来源:Support.java

示例3: makeSQLPattern

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static String makeSQLPattern(ModeValue mode, String rawValue) {
    Assert.notNull(mode);
    Assert.notNull(rawValue);
    if (mode.getMode().isSingle()) {
        return rawValue;
    } else if (mode.getMode().isMulti()) {
        return StringUtils.substringBefore(rawValue, "[") + "%";
    } else if (mode.getMode().isWildCard()) {
        StringBuilder sb = new StringBuilder(rawValue.length());
        FOR_LOOP: for (int i = 0; i < rawValue.length(); i++) {
            String charString = String.valueOf(rawValue.charAt(i));
            if (isWildCard(charString)) {
                break FOR_LOOP;
            } else {
                sb.append(rawValue.charAt(i));
            }
        }
        return sb.toString() + "%";
    } else {
        throw new UnsupportedOperationException("unsupport mode:" + mode.getMode());
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:23,代码来源:ConfigHelper.java

示例4: getDevelopmentVersion

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public VersionPolicyResult getDevelopmentVersion(final VersionPolicyRequest versionPolicyRequest)
        throws PolicyException, VersionParseException {
    final VersionPolicyResult result = new VersionPolicyResult();
    final String version = versionPolicyRequest.getVersion();

    if (version.endsWith(snapshotPostfix)) {
        result.setVersion(version);
    } else {
        final String majorVersionComponent = StringUtils.substringBefore(version, ".");

        if (matchesYear(majorVersionComponent, currentYear)) {
            result.setVersion(incrementVersionWithinYear(version) + snapshotPostfix);
        } else {
            result.setVersion(firstOfYear() + snapshotPostfix);
        }
    }

    return result;
}
 
开发者ID:ncredinburgh,项目名称:maven-release-yearly-policy,代码行数:23,代码来源:YearlyVersionPolicy.java

示例5: render

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * 直接输出内容的简便函数.

 * eg.
 * render("text/plain", "hello", "encoding:GBK");
 * render("text/plain", "hello", "no-cache:false");
 * render("text/plain", "hello", "encoding:GBK", "no-cache:false");
 * 
 * @param headers 可变的header数组,目前接受的值为"encoding:"或"no-cache:",默认值分别为UTF-8和true.
 */
public static void render(final HttpServletResponse response,final String contentType, final String content, final String... headers) {
	try {
		//分析headers参数
		String encoding = ENCODING_DEFAULT;
		boolean noCache = NOCACHE_DEFAULT;
		for (String header : headers) {
			String headerName = StringUtils.substringBefore(header, ":");
			String headerValue = StringUtils.substringAfter(header, ":");

			if (StringUtils.equalsIgnoreCase(headerName, ENCODING_PREFIX)) {
				encoding = headerValue;
			} else if (StringUtils.equalsIgnoreCase(headerName, NOCACHE_PREFIX)) {
				noCache = Boolean.parseBoolean(headerValue);
			} else
				throw new IllegalArgumentException(headerName + "不是一个合法的header类型");
		}

		//设置headers参数
		String fullContentType = contentType + ";charset=" + encoding;
		response.setContentType(fullContentType);
		if (noCache) {
			response.setHeader("Pragma", "No-cache");
			response.setHeader("Cache-Control", "no-cache");
			response.setDateHeader("Expires", 0);
		}

		PrintWriter writer = response.getWriter();
		writer.write(content);
		writer.flush();
		writer.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:JackChan1999,项目名称:TakeoutService,代码行数:45,代码来源:CommonUtil.java

示例6: addTableRegex

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public void addTableRegex(String tableRegex){
	String[] tableRegexs = StringUtils.split(tableRegex, ",");
	for(String regex : tableRegexs){
		String localTbl = StringUtils.substringBefore(regex.trim(), ".");
		String partitionTblRegex = StringUtils.substringAfter(regex.trim(), ".");
		map.put(localTbl, partitionTblRegex);
	}
	
}
 
开发者ID:BriData,项目名称:DBus,代码行数:10,代码来源:TableMatchContainer.java

示例7: getChild

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Override
public Resource getChild(String relPath) {
	if (StringUtils.contains(relPath, '/')) {
		String firstPart = StringUtils.substringBefore(relPath, "/");
		String rest = StringUtils.substringAfter(relPath, "/");
		if (children.containsKey(firstPart)) {
			return children.get(firstPart).getChild(rest);
		}
	} else if (children.containsKey(relPath)) {
		return children.get(relPath);
	}

	return null;
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-query,代码行数:15,代码来源:ResourceMock.java

示例8: getMethod

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Return the method to call according to the url.
 *
 * @param request the incoming http request
 * @return the method to call according to the url
 */
private String getMethod(final HttpServletRequest request) {
    String method = request.getRequestURI();
    if (method.indexOf("?") >= 0) {
        method = StringUtils.substringBefore(method, "?");
    }
    final int pos = method.lastIndexOf("/");
    if (pos >= 0) {
        method = method.substring(pos + 1);
    }
    return method;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:BaseOAuthWrapperController.java

示例9: getTagSet

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Split string to get tag set.
 * 
 * @param tags
 *            the String of tags to split.
 * @return set of tags.
 */
public static Set<String> getTagSet(String tags) {
	tags = StringUtils.substringBefore(tags, "\n");
	String[] tagArr = tags.split("[\\s,,;;]");
	Set<String> tagSet = new HashSet<String>();
	for (int i = 0; i < tagArr.length; i++) {
		String tag = tagArr[i].trim();
		if (!tag.isEmpty()) {
			tagSet.add(tag);
		}
	}
	return tagSet;
}
 
开发者ID:WinRoad-NET,项目名称:wrdocletbase,代码行数:20,代码来源:WRTagTaglet.java

示例10: getMQConsumerTopic

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
protected String getMQConsumerTopic(ClassDoc classDoc) {
	Tag[] tags = classDoc.tags(WRMqConsumerTaglet.NAME);
	if (tags.length == 0) {
		return "";
	}
	return StringUtils.substringBefore(tags[0].text(), "\n");
}
 
开发者ID:WinRoad-NET,项目名称:wrdocletbase,代码行数:8,代码来源:AbstractDocBuilder.java

示例11: getMQProducerTopic

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
protected String getMQProducerTopic(ClassDoc classDoc) {
	Tag[] tags = classDoc.tags(WRMqProducerTaglet.NAME);
	if (tags.length == 0) {
		return "";
	}
	return StringUtils.substringBefore(tags[0].text(), "\n");
}
 
开发者ID:WinRoad-NET,项目名称:wrdocletbase,代码行数:8,代码来源:AbstractDocBuilder.java

示例12: initResponseHeader

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * 分析并设置contentType与headers.
 */
private static HttpServletResponse initResponseHeader(final String contentType, final String... headers) {
    //分析headers参数
    String encoding = DEFAULT_ENCODING;
    boolean noCache = DEFAULT_NOCACHE;
    for (String header : headers) {
        String headerName = StringUtils.substringBefore(header, ":");
        String headerValue = StringUtils.substringAfter(header, ":");

        if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) {
            encoding = headerValue;
        } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) {
            noCache = Boolean.parseBoolean(headerValue);
        } else {
            throw new IllegalArgumentException(headerName + "不是一个合法的header类型");
        }
    }

    HttpServletResponse response = ServletActionContext.getResponse();

    //设置headers参数
    String fullContentType = contentType + ";charset=" + encoding;
    response.setContentType(fullContentType);
    if (noCache) {
        ServletUtils.setDisableCacheHeader(response);
    }

    return response;
}
 
开发者ID:dragon-yuan,项目名称:Ins_fb_pictureSpider_WEB,代码行数:32,代码来源:BaseUtils.java

示例13: compactDescription

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private String compactDescription(String sentence) {
    if (StringUtils.isNotEmpty(sentence)) {
        if (StringUtils.contains(sentence, ".")) {
            return StringUtils.substringBefore(sentence, ".") + ".";
        } else {
            return sentence;
        }
    }
    return sentence;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:ApplicationArchive.java

示例14: getReleaseVersion

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public VersionPolicyResult getReleaseVersion(final VersionPolicyRequest versionPolicyRequest)
        throws PolicyException, VersionParseException {
    final String version = versionPolicyRequest.getVersion();
    final String cleanedVersion = StringUtils.removeEnd(version, snapshotPostfix);
    final String majorVersionComponent = StringUtils.substringBefore(cleanedVersion, ".");

    final String releaseVersion = matchesYear(majorVersionComponent, currentYear) ? cleanedVersion : firstOfYear();

    return new VersionPolicyResult()
            .setVersion(releaseVersion);
}
 
开发者ID:ncredinburgh,项目名称:maven-release-yearly-policy,代码行数:15,代码来源:YearlyVersionPolicy.java

示例15: isSupported

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static boolean isSupported(Column column){
	String type = StringUtils.substringBefore(column.getMysqlType(), "(");
	return SupportedMysqlDataType.isSupported(type);
}
 
开发者ID:BriData,项目名称:DBus,代码行数:5,代码来源:Support.java


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