hudson.Util.rawEncode()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(218)

本文整理了Java中hudson.Util.rawEncode()方法的一些代码示例,展示了Util.rawEncode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.rawEncode()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:rawEncode

Util.rawEncode介绍

[英]Encode a single path component for use in an HTTP URL. Escapes all non-ASCII, general unsafe (space and "#%<>[]^{|}~}) and HTTP special characters ( /;:?) as specified in RFC1738. (so alphanumeric and !@$&*()-_=+',. are not encoded) Note that slash ( /) is encoded, so the given string should be a single path component used in constructing a URL. Method name inspired by PHP's rawurlencode. [中]对单个路径组件进行编码,以便在HTTP URL中使用。转义所有非ASCII、一般不安全(空格和“#%<>[\]^{124;}})和HTTP特殊字符(/;:?)按照RFC1738的规定。(所以字母数字和!@$&*()-=+',),。请注意,斜杠(/)是经过编码的,因此给定的字符串应该是用于构建URL的单个路径组件。方法名的灵感来源于PHP的rawurlencode。

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. public String getSearchUrl() {
  2. return Util.rawEncode(name);
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. public String getUrl() {
  2. return "computer/" + Util.rawEncode(getName()) + "/";
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. public @Nonnull
  2. String getUrl() {
  3. return "user/" + Util.rawEncode(idStrategy().keyFor(id));
  4. }

代码示例来源:origin: jenkinsci/jenkins

  1. public @Nonnull
  2. String getSearchUrl() {
  3. return "/user/" + Util.rawEncode(idStrategy().keyFor(id));
  4. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Same as {@link #getUrl()} except this returns a view/{name} path
  3. * even for the default view.
  4. */
  5. public String getViewUrl() {
  6. return (owner!=null ? owner.getUrl() : "") + "view/" + Util.rawEncode(getViewName()) + '/';
  7. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * When there are multiple suggested items, this method can narrow down the resultset
  3. * to the SuggestedItem that has a url that contains the query. This is useful is one
  4. * job has a display name that matches another job's project name.
  5. * @param r A list of Suggested items. It is assumed that there is at least one
  6. * SuggestedItem in r.
  7. * @param query A query string
  8. * @return Returns the SuggestedItem which has a search url that contains the query.
  9. * If no SuggestedItems have a search url which contains the query, then the first
  10. * SuggestedItem in the List is returned.
  11. */
  12. static SuggestedItem findClosestSuggestedItem(List<SuggestedItem> r, String query) {
  13. for(SuggestedItem curItem : r) {
  14. if(LOGGER.isLoggable(Level.FINE)) {
  15. LOGGER.fine(String.format("item's searchUrl:%s;query=%s", curItem.item.getSearchUrl(), query));
  16. }
  17. if(curItem.item.getSearchUrl().contains(Util.rawEncode(query))) {
  18. return curItem;
  19. }
  20. }
  21. // couldn't find an item with the query in the url so just
  22. // return the first one
  23. return r.get(0);
  24. }

代码示例来源:origin: jenkinsci/jenkins

  1. public String getShortUrl() {
  2. String prefix = getParent().getUrlChildPrefix();
  3. String subdir = Util.rawEncode(getName());
  4. return prefix.equals(".") ? subdir + '/' : prefix + '/' + subdir + '/';
  5. }

代码示例来源:origin: jenkinsci/jenkins

  1. public String getSearchUrl() {
  2. Computer c = toComputer();
  3. if (c != null) {
  4. return c.getUrl();
  5. }
  6. return "computer/" + Util.rawEncode(getNodeName());
  7. }

代码示例来源:origin: jenkinsci/gitlab-plugin

  1. private StringBuilder retrieveProjectUrl(Job<?, ?> project) {
  2. return new StringBuilder()
  3. .append(Jenkins.getInstance().getRootUrl())
  4. .append(GitLabWebHook.WEBHOOK_URL)
  5. .append(retrieveParentUrl(project))
  6. .append('/').append(Util.rawEncode(project.getName()));
  7. }

代码示例来源:origin: jenkinsci/jenkins

  1. public HttpResponse doIndex() {
  2. return new HttpRedirect("view/" + Util.rawEncode(getPrimaryView().getViewName()) + "/");
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. public HttpResponse doTest() {
  2. String referer = Stapler.getCurrentRequest().getReferer();
  3. Jenkins j = Jenkins.getInstance();
  4. // May need to send an absolute URL, since handling of HttpRedirect with a relative URL does not currently honor X-Forwarded-Proto/Port at all.
  5. String redirect = j.getRootUrl() + "administrativeMonitor/" + id + "/testForReverseProxySetup/" + (referer != null ? Util.rawEncode(referer) : "NO-REFERER") + "/";
  6. LOGGER.log(Level.FINE, "coming from {0} and redirecting to {1}", new Object[] {referer, redirect});
  7. return new HttpRedirect(redirect);
  8. }

代码示例来源:origin: jenkinsci/gitlab-plugin

  1. private StringBuilder retrieveParentUrl(Item item) {
  2. if (item.getParent() instanceof Item) {
  3. Item parent = (Item) item.getParent();
  4. return retrieveParentUrl(parent).append('/').append(Util.rawEncode(parent.getName()));
  5. } else {
  6. return new StringBuilder();
  7. }
  8. }

代码示例来源:origin: jenkinsci/jenkins

  1. Path p = new Path(Util.rawEncode(f.getName()), f.getName(), f.isDirectory(), f.length(), f.canRead(), f.lastModified());
  2. if(!f.isDirectory()) {
  3. r.add(Collections.singletonList(p));
  4. String relPath = Util.rawEncode(f.getName());
  5. while(true) {
  6. break;
  7. f = sub.get(0);
  8. relPath += '/'+Util.rawEncode(f.getName());
  9. l.add(new Path(relPath,f.getName(),true, f.length(), f.canRead(), f.lastModified()));

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Builds the path list and href recursively top-down.
  3. */
  4. private static void buildPathList(VirtualFile baseDir, VirtualFile filePath, List<Path> pathList, StringBuilder href) throws IOException {
  5. VirtualFile parent = filePath.getParent();
  6. if (!baseDir.equals(parent)) {
  7. buildPathList(baseDir, parent, pathList, href);
  8. }
  9. href.append(Util.rawEncode(filePath.getName()));
  10. if (filePath.isDirectory()) {
  11. href.append("/");
  12. }
  13. Path path = new Path(href.toString(), filePath.getName(), filePath.isDirectory(), filePath.length(), filePath.canRead(), filePath.lastModified());
  14. pathList.add(path);
  15. }

代码示例来源:origin: jenkinsci/jenkins

  1. String child = sub.getName();
  2. String childPath = path + child;
  3. String childHref = pathHref + Util.rawEncode(child);
  4. String length = sub.isFile() ? String.valueOf(sub.length()) : "";
  5. boolean collapsed = (kids.length==1 && parent!=null);

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Accepts submission from the configuration page.
  3. */
  4. @RequirePOST
  5. public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
  6. JSONObject src = req.getSubmittedForm();
  7. String newName = src.getString("name"), redirect = ".";
  8. XmlFile oldFile = null;
  9. if(!name.equals(newName)) {
  10. Jenkins.checkGoodName(newName);
  11. oldFile = getConfigFile();
  12. // rename
  13. getParent().logRecorders.remove(name);
  14. this.name = newName;
  15. getParent().logRecorders.put(name,this);
  16. redirect = "../" + Util.rawEncode(newName) + '/';
  17. }
  18. List<Target> newTargets = req.bindJSONToList(Target.class, src.get("targets"));
  19. for (Target t : newTargets)
  20. t.enable();
  21. targets.replaceBy(newTargets);
  22. save();
  23. if (oldFile!=null) oldFile.delete();
  24. rsp.sendRedirect2(redirect);
  25. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Accepts submission from the configuration page.
  3. *
  4. * Subtypes should override the {@link #submit(StaplerRequest)} method.
  5. */
  6. @RequirePOST
  7. public final synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
  8. checkPermission(CONFIGURE);
  9. submit(req);
  10. description = Util.nullify(req.getParameter("description"));
  11. filterExecutors = req.getParameter("filterExecutors") != null;
  12. filterQueue = req.getParameter("filterQueue") != null;
  13. rename(req.getParameter("name"));
  14. getProperties().rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors());
  15. save();
  16. FormApply.success("../" + Util.rawEncode(name)).generateResponse(req,rsp,this);
  17. }

代码示例来源:origin: org.jenkins-ci.plugins/credentials

  1. /**
  2. * Return the store relative URL of this domain.
  3. *
  4. * @return the store relative URL of this domain.
  5. */
  6. @SuppressFBWarnings(value = "NP_NULL_PARAM_DEREF",
  7. justification = "isGlobal() check implies that domain.getName() is null")
  8. public String getUrl() {
  9. return isGlobal() ? "domain/_/" : "domain/" + Util.rawEncode(name) + "/";
  10. }

代码示例来源:origin: org.jenkins-ci.plugins/credentials

  1. /**
  2. * Return the URL name.
  3. *
  4. * @return the URL name.
  5. */
  6. @Exported
  7. @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
  8. justification = "isGlobal() check implies that domain.getName() is null")
  9. public String getUrlName() {
  10. return isGlobal() ? "_" : Util.rawEncode(domain.getName());
  11. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. public HttpResponse doTest() {
  2. String referer = Stapler.getCurrentRequest().getReferer();
  3. Jenkins j = Jenkins.getInstance();
  4. // May need to send an absolute URL, since handling of HttpRedirect with a relative URL does not currently honor X-Forwarded-Proto/Port at all.
  5. String redirect = j.getRootUrl() + "administrativeMonitor/" + id + "/testForReverseProxySetup/" + (referer != null ? Util.rawEncode(referer) : "NO-REFERER") + "/";
  6. LOGGER.log(Level.FINE, "coming from {0} and redirecting to {1}", new Object[] {referer, redirect});
  7. return new HttpRedirect(redirect);
  8. }

相关文章