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


Java StringUtils.stripStart方法代码示例

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


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

示例1: getProject

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Sessional
protected ProjectFacade getProject(HttpServletRequest request, HttpServletResponse response, String projectInfo) 
		throws IOException {
	projectInfo = StringUtils.stripStart(StringUtils.stripEnd(projectInfo, "/"), "/");

	if (StringUtils.isBlank(projectInfo) || !projectInfo.startsWith("projects/")) {
		String url = request.getRequestURL().toString();
		String urlRoot = url.substring(0, url.length()-getPathInfo(request).length());
		throw new GitException(String.format("Expecting url of format %sprojects/<project name>", urlRoot));
	} 
	
	String projectName = StringUtils.substringAfter(projectInfo, "/");
	
	if (projectName.endsWith(".git"))
		projectName = projectName.substring(0, projectName.length()-".git".length());
	
	Project project = projectManager.find(projectName);
	if (project == null) {
		throw new GitException(String.format("Unable to find project %s", projectName));
	}
	
	return project.getFacade();
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:24,代码来源:GitFilter.java

示例2: processRefs

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
protected void processRefs(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	String pathInfo = request.getRequestURI().substring(request.getContextPath().length());
	pathInfo = StringUtils.stripStart(pathInfo, "/");

	String projectInfo = pathInfo.substring(0, pathInfo.length() - INFO_REFS.length());
	ProjectFacade project = getProject(request, response, projectInfo);
	String service = request.getParameter("service");
	
	File gitDir = storageManager.getProjectGitDir(project.getId());

	if (service.contains("upload")) {
		if (!SecurityUtils.canRead(project)) 
			throw new UnauthorizedException("You do not have permission to pull from this project.");
		writeInitial(response, service);
		new AdvertiseUploadRefsCommand(gitDir).output(response.getOutputStream()).call();
	} else {
		if (!SecurityUtils.canWrite(project)) {
			throw new UnauthorizedException("You do not have permission to push to this project.");
		}
		writeInitial(response, service);
		new AdvertiseReceiveRefsCommand(gitDir).output(response.getOutputStream()).call();
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:24,代码来源:GitFilter.java

示例3: getResource

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public final Resource getResource(String pathInContext) {
	ServletContextHandler.Context context = (ServletContextHandler.Context) getServletContext();
	ServletContextHandler contextHandler = (ServletContextHandler) context.getContextHandler();
	
	for (ServletMapping mapping: contextHandler.getServletHandler().getServletMappings()) {
		if (mapping.getServletName().equals(getServletName())) {
			for (String pathSpec: mapping.getPathSpecs()) {
				String relativePath = null;
				if (pathSpec.endsWith("/*")) {
					pathSpec = StringUtils.substringBeforeLast(pathSpec, "/*");
					if (pathInContext.startsWith(pathSpec + "/")) 
						relativePath = pathInContext.substring(pathSpec.length());
				} else if (pathSpec.startsWith("*.")) {
					pathSpec = StringUtils.stripStart(pathSpec, "*");
					if (pathInContext.endsWith(pathSpec))
						relativePath = pathInContext;
				} else if (pathSpec.equals(pathInContext)) {
					relativePath = pathInContext;
				}
				if (relativePath != null) {
					relativePath = StringUtils.stripStart(relativePath, "/");
					Resource resource = Resource.newResource(loadResource(relativePath));
					if (resource != null && resource.exists())
						return resource;
				}
			}
		}
	}
	
	return null;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:33,代码来源:AssetServlet.java

示例4: getPathInfo

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getPathInfo(HttpServletRequest request) {
	String pathInfo = request.getRequestURI().substring(request.getContextPath().length());
	return StringUtils.stripStart(pathInfo, "/");
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:5,代码来源:GitFilter.java

示例5: unqualified

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String unqualified(String methodName) {
    return StringUtils.stripStart(methodName, "[0123456789] ");
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:4,代码来源:SatisfyAnnotatedStepDescription.java

示例6: sanitizePath

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String sanitizePath(final String path){
    // prevent double slashes, because that causes errors in pushState()
    return SEPARATOR + StringUtils.stripStart(path, SEPARATOR);
}
 
开发者ID:apm78,项目名称:history-api-navigation,代码行数:5,代码来源:HistoryApiNavigationStateManager.java


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