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

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

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

Util.fixNull介绍

暂无

代码示例

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

  1. /**
  2. * Gets the upstream projects.
  3. *
  4. * @return Upstream projects or empty("") if upstream projects is null.
  5. */
  6. public String getUpstreamProjects() {
  7. return Util.fixNull(upstreamProjects);
  8. }

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

  1. public String getLabelString() {
  2. return fixNull(label).trim();
  3. }

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

  1. public String getLabelString() {
  2. return Util.fixNull(label).trim();
  3. }

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

  1. /**
  2. * Convert null to "".
  3. */
  4. @Nonnull
  5. public static String fixNull(@CheckForNull String s) {
  6. return fixNull(s, "");
  7. }

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

  1. /**
  2. *
  3. * @param l collection to check.
  4. * @param <T>
  5. * Type of the collection.
  6. * @return
  7. * {@code l} if l is not {@code null}.
  8. * An empty <b>immutable set</b> if l is {@code null}.
  9. */
  10. @Nonnull
  11. public static <T> Collection<T> fixNull(@CheckForNull Collection<T> l) {
  12. return fixNull(l, Collections.<T>emptySet());
  13. }

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

  1. /**
  2. *
  3. * @param l iterable to check.
  4. * @param <T>
  5. * Type of the iterable.
  6. * @return
  7. * {@code l} if l is not {@code null}.
  8. * An empty <b>immutable set</b> if l is {@code null}.
  9. */
  10. @Nonnull
  11. public static <T> Iterable<T> fixNull(@CheckForNull Iterable<T> l) {
  12. return fixNull(l, Collections.<T>emptySet());
  13. }

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

  1. /**
  2. *
  3. * @param l list to check.
  4. * @param <T>
  5. * Type of the list.
  6. * @return
  7. * {@code l} if l is not {@code null}.
  8. * An empty <b>immutable list</b> if l is {@code null}.
  9. */
  10. @Nonnull
  11. public static <T> List<T> fixNull(@CheckForNull List<T> l) {
  12. return fixNull(l, Collections.<T>emptyList());
  13. }

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

  1. /**
  2. *
  3. * @param l set to check.
  4. * @param <T>
  5. * Type of the set.
  6. * @return
  7. * {@code l} if l is not {@code null}.
  8. * An empty <b>immutable set</b> if l is {@code null}.
  9. */
  10. @Nonnull
  11. public static <T> Set<T> fixNull(@CheckForNull Set<T> l) {
  12. return fixNull(l, Collections.<T>emptySet());
  13. }

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

  1. /**
  2. * Gets the parameter as a file.
  3. */
  4. protected final File getFileParameter(String paramName) {
  5. return new File(Util.fixNull(request.getParameter(paramName)));
  6. }

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

  1. public String getValue() {
  2. return Util.fixNull(current().node.value);
  3. }

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

  1. protected List<Action> createTransientActions() {
  2. Vector<Action> ta = new Vector<Action>();
  3. for (JobProperty<? super P> p : Util.fixNull(properties))
  4. ta.addAll(p.getJobActions((P)this));
  5. for (TransientProjectActionFactory tpaf : TransientProjectActionFactory.all()) {
  6. try {
  7. ta.addAll(Util.fixNull(tpaf.createFor(this))); // be defensive against null
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "Could not load actions from " + tpaf + " for " + this, e);
  10. }
  11. }
  12. return ta;
  13. }

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

  1. @Override
  2. @DataBoundSetter
  3. public void setLabelString(String labelString) throws IOException {
  4. this.label = Util.fixNull(labelString).trim();
  5. // Compute labels now.
  6. getAssignedLabels();
  7. }

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

  1. /**
  2. *
  3. * @return original or trimmed defaultValue (depending on trim)
  4. */
  5. @Restricted(DoNotUse.class) // Jelly
  6. public String getDefaultValue4Build() {
  7. if (isTrim()) {
  8. return Util.fixNull(defaultValue).trim();
  9. }
  10. return defaultValue;
  11. }

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

  1. /**
  2. * Attempts to treat the given string first as a cipher text, and if it doesn't work,
  3. * treat the given string as the unencrypted secret value.
  4. *
  5. * <p>
  6. * Useful for recovering a value from a form field.
  7. */
  8. @Nonnull
  9. public static Secret fromString(@CheckForNull String data) {
  10. data = Util.fixNull(data);
  11. Secret s = decrypt(data);
  12. if(s==null) s=new Secret(data);
  13. return s;
  14. }

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

  1. /**
  2. * Performs syntax check.
  3. */
  4. public FormValidation doCheck(@QueryParameter String value) {
  5. try {
  6. String msg = CronTabList.create(fixNull(value)).checkSanity();
  7. if (msg != null)
  8. return FormValidation.warning(msg);
  9. return FormValidation.ok();
  10. } catch (ANTLRException e) {
  11. return FormValidation.error(e.getMessage());
  12. }
  13. }
  14. }

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

  1. public RenderOnDemandClosure(JellyContext context, String attributesToCapture) {
  2. List<Script> bodyStack = new ArrayList<Script>();
  3. for (JellyContext c = context; c!=null; c=c.getParent()) {
  4. Script script = (Script) c.getVariables().get("org.apache.commons.jelly.body");
  5. if(script!=null) bodyStack.add(script);
  6. }
  7. this.bodyStack = bodyStack.toArray(new Script[bodyStack.size()]);
  8. assert !bodyStack.isEmpty(); // there must be at least one, which is the direct child of <l:renderOnDemand>
  9. Map<String,Object> variables = new HashMap<String, Object>();
  10. for (String v : Util.fixNull(attributesToCapture).split(","))
  11. variables.put(v.intern(),context.getVariable(v));
  12. // capture the current base of context for descriptors
  13. currentDescriptorByNameUrl = Descriptor.getCurrentDescriptorByNameUrl();
  14. this.variables = PackedMap.of(variables);
  15. Set<String> _adjuncts = AdjunctsInPage.get().getIncluded();
  16. this.adjuncts = new String[_adjuncts.size()];
  17. int i = 0;
  18. for (String adjunct : _adjuncts) {
  19. this.adjuncts[i++] = adjunct.intern();
  20. }
  21. }

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

  1. @RequirePOST
  2. public HttpResponse doSubmit(StaplerRequest req) throws IOException {
  3. String whitelist = Util.fixNull(req.getParameter("whitelist"));
  4. if (!whitelist.endsWith("\n"))
  5. whitelist+="\n";
  6. Enumeration e = req.getParameterNames();
  7. while (e.hasMoreElements()) {
  8. String name = (String) e.nextElement();
  9. if (name.startsWith("class:")) {
  10. whitelist += name.substring(6)+"\n";
  11. }
  12. }
  13. whitelisted.set(whitelist);
  14. String newRules = Util.fixNull(req.getParameter("filePathRules"));
  15. filePathRules.parseTest(newRules); // test first before writing a potentially broken rules
  16. filePathRules.set(newRules);
  17. return HttpResponses.redirectToDot();
  18. }

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

  1. /**
  2. * Performs syntax check.
  3. */
  4. public FormValidation doCheckSpec(@QueryParameter String value, @AncestorInPath Item item) {
  5. try {
  6. CronTabList ctl = CronTabList.create(fixNull(value), item != null ? Hash.from(item.getFullName()) : null);
  7. Collection<FormValidation> validations = new ArrayList<>();
  8. updateValidationsForSanity(validations, ctl);
  9. updateValidationsForNextRun(validations, ctl);
  10. return FormValidation.aggregate(validations);
  11. } catch (ANTLRException e) {
  12. if (value.trim().indexOf('\n')==-1 && value.contains("**"))
  13. return FormValidation.error(Messages.TimerTrigger_MissingWhitespace());
  14. return FormValidation.error(e.getMessage());
  15. }
  16. }

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

  1. /**
  2. * Convert a whitespace-separate list of tokens into a set of {@link Label}s.
  3. *
  4. * @param labels
  5. * Strings like "abc def ghi". Can be empty or null.
  6. * @return
  7. * Can be empty but never null. A new writable set is always returned,
  8. * so that the caller can add more to the set.
  9. * @since 1.308
  10. */
  11. public static Set<LabelAtom> parse(String labels) {
  12. final Set<LabelAtom> r = new TreeSet<>();
  13. labels = fixNull(labels);
  14. if(labels.length()>0) {
  15. final QuotedStringTokenizer tokenizer = new QuotedStringTokenizer(labels);
  16. while (tokenizer.hasMoreTokens())
  17. r.add(Jenkins.getInstance().getLabelAtom(tokenizer.nextToken()));
  18. }
  19. return r;
  20. }

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

  1. public void marshal(Object source, HierarchicalStreamWriter w, MarshallingContext context) {
  2. XStreamDOM dom = (XStreamDOM)source;
  3. w.startNode(unescape(dom.tagName));
  4. for (int i=0; i<dom.attributes.length; i+=2)
  5. w.addAttribute(unescape(dom.attributes[i]),dom.attributes[i+1]);
  6. if (dom.value!=null)
  7. w.setValue(dom.value);
  8. else {
  9. for (XStreamDOM c : Util.fixNull(dom.children)) {
  10. marshal(c, w, context);
  11. }
  12. }
  13. w.endNode();
  14. }

相关文章