本文整理匯總了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);
}