本文整理汇总了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();
}
示例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();
}
}
示例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;
}
示例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, "/");
}
示例5: unqualified
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String unqualified(String methodName) {
return StringUtils.stripStart(methodName, "[0123456789] ");
}
示例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);
}