/** * Gets the upstream projects. * * @return Upstream projects or empty("") if upstream projects is null. */ public String getUpstreamProjects() { return Util.fixNull(upstreamProjects); }
public String getLabelString() { return fixNull(label).trim(); }
public String getLabelString() { return Util.fixNull(label).trim(); }
/** * Convert null to "". */ @Nonnull public static String fixNull(@CheckForNull String s) { return fixNull(s, ""); }
/** * * @param l collection to check. * @param <T> * Type of the collection. * @return * {@code l} if l is not {@code null}. * An empty <b>immutable set</b> if l is {@code null}. */ @Nonnull public static <T> Collection<T> fixNull(@CheckForNull Collection<T> l) { return fixNull(l, Collections.<T>emptySet()); }
/** * * @param l iterable to check. * @param <T> * Type of the iterable. * @return * {@code l} if l is not {@code null}. * An empty <b>immutable set</b> if l is {@code null}. */ @Nonnull public static <T> Iterable<T> fixNull(@CheckForNull Iterable<T> l) { return fixNull(l, Collections.<T>emptySet()); }
/** * * @param l list to check. * @param <T> * Type of the list. * @return * {@code l} if l is not {@code null}. * An empty <b>immutable list</b> if l is {@code null}. */ @Nonnull public static <T> List<T> fixNull(@CheckForNull List<T> l) { return fixNull(l, Collections.<T>emptyList()); }
/** * * @param l set to check. * @param <T> * Type of the set. * @return * {@code l} if l is not {@code null}. * An empty <b>immutable set</b> if l is {@code null}. */ @Nonnull public static <T> Set<T> fixNull(@CheckForNull Set<T> l) { return fixNull(l, Collections.<T>emptySet()); }
/** * Gets the parameter as a file. */ protected final File getFileParameter(String paramName) { return new File(Util.fixNull(request.getParameter(paramName))); }
public String getValue() { return Util.fixNull(current().node.value); }
protected List<Action> createTransientActions() { Vector<Action> ta = new Vector<Action>(); for (JobProperty<? super P> p : Util.fixNull(properties)) ta.addAll(p.getJobActions((P)this)); for (TransientProjectActionFactory tpaf : TransientProjectActionFactory.all()) { try { ta.addAll(Util.fixNull(tpaf.createFor(this))); // be defensive against null } catch (Exception e) { LOGGER.log(Level.SEVERE, "Could not load actions from " + tpaf + " for " + this, e); } } return ta; }
@Override @DataBoundSetter public void setLabelString(String labelString) throws IOException { this.label = Util.fixNull(labelString).trim(); // Compute labels now. getAssignedLabels(); }
/** * * @return original or trimmed defaultValue (depending on trim) */ @Restricted(DoNotUse.class) // Jelly public String getDefaultValue4Build() { if (isTrim()) { return Util.fixNull(defaultValue).trim(); } return defaultValue; }
/** * Attempts to treat the given string first as a cipher text, and if it doesn't work, * treat the given string as the unencrypted secret value. * * <p> * Useful for recovering a value from a form field. */ @Nonnull public static Secret fromString(@CheckForNull String data) { data = Util.fixNull(data); Secret s = decrypt(data); if(s==null) s=new Secret(data); return s; }
/** * Performs syntax check. */ public FormValidation doCheck(@QueryParameter String value) { try { String msg = CronTabList.create(fixNull(value)).checkSanity(); if (msg != null) return FormValidation.warning(msg); return FormValidation.ok(); } catch (ANTLRException e) { return FormValidation.error(e.getMessage()); } } }
public RenderOnDemandClosure(JellyContext context, String attributesToCapture) { List<Script> bodyStack = new ArrayList<Script>(); for (JellyContext c = context; c!=null; c=c.getParent()) { Script script = (Script) c.getVariables().get("org.apache.commons.jelly.body"); if(script!=null) bodyStack.add(script); } this.bodyStack = bodyStack.toArray(new Script[bodyStack.size()]); assert !bodyStack.isEmpty(); // there must be at least one, which is the direct child of <l:renderOnDemand> Map<String,Object> variables = new HashMap<String, Object>(); for (String v : Util.fixNull(attributesToCapture).split(",")) variables.put(v.intern(),context.getVariable(v)); // capture the current base of context for descriptors currentDescriptorByNameUrl = Descriptor.getCurrentDescriptorByNameUrl(); this.variables = PackedMap.of(variables); Set<String> _adjuncts = AdjunctsInPage.get().getIncluded(); this.adjuncts = new String[_adjuncts.size()]; int i = 0; for (String adjunct : _adjuncts) { this.adjuncts[i++] = adjunct.intern(); } }
@RequirePOST public HttpResponse doSubmit(StaplerRequest req) throws IOException { String whitelist = Util.fixNull(req.getParameter("whitelist")); if (!whitelist.endsWith("\n")) whitelist+="\n"; Enumeration e = req.getParameterNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); if (name.startsWith("class:")) { whitelist += name.substring(6)+"\n"; } } whitelisted.set(whitelist); String newRules = Util.fixNull(req.getParameter("filePathRules")); filePathRules.parseTest(newRules); // test first before writing a potentially broken rules filePathRules.set(newRules); return HttpResponses.redirectToDot(); }
/** * Performs syntax check. */ public FormValidation doCheckSpec(@QueryParameter String value, @AncestorInPath Item item) { try { CronTabList ctl = CronTabList.create(fixNull(value), item != null ? Hash.from(item.getFullName()) : null); Collection<FormValidation> validations = new ArrayList<>(); updateValidationsForSanity(validations, ctl); updateValidationsForNextRun(validations, ctl); return FormValidation.aggregate(validations); } catch (ANTLRException e) { if (value.trim().indexOf('\n')==-1 && value.contains("**")) return FormValidation.error(Messages.TimerTrigger_MissingWhitespace()); return FormValidation.error(e.getMessage()); } }
/** * Convert a whitespace-separate list of tokens into a set of {@link Label}s. * * @param labels * Strings like "abc def ghi". Can be empty or null. * @return * Can be empty but never null. A new writable set is always returned, * so that the caller can add more to the set. * @since 1.308 */ public static Set<LabelAtom> parse(String labels) { final Set<LabelAtom> r = new TreeSet<>(); labels = fixNull(labels); if(labels.length()>0) { final QuotedStringTokenizer tokenizer = new QuotedStringTokenizer(labels); while (tokenizer.hasMoreTokens()) r.add(Jenkins.getInstance().getLabelAtom(tokenizer.nextToken())); } return r; }
public void marshal(Object source, HierarchicalStreamWriter w, MarshallingContext context) { XStreamDOM dom = (XStreamDOM)source; w.startNode(unescape(dom.tagName)); for (int i=0; i<dom.attributes.length; i+=2) w.addAttribute(unescape(dom.attributes[i]),dom.attributes[i+1]); if (dom.value!=null) w.setValue(dom.value); else { for (XStreamDOM c : Util.fixNull(dom.children)) { marshal(c, w, context); } } w.endNode(); }