當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。