本文整理了Java中hudson.Util.fixNull()
方法的一些代码示例,展示了Util.fixNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.fixNull()
方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:fixNull
暂无
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets the upstream projects.
*
* @return Upstream projects or empty("") if upstream projects is null.
*/
public String getUpstreamProjects() {
return Util.fixNull(upstreamProjects);
}
代码示例来源:origin: jenkinsci/jenkins
public String getLabelString() {
return fixNull(label).trim();
}
代码示例来源:origin: jenkinsci/jenkins
public String getLabelString() {
return Util.fixNull(label).trim();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Convert null to "".
*/
@Nonnull
public static String fixNull(@CheckForNull String s) {
return fixNull(s, "");
}
代码示例来源:origin: jenkinsci/jenkins
/**
*
* @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());
}
代码示例来源:origin: jenkinsci/jenkins
/**
*
* @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());
}
代码示例来源:origin: jenkinsci/jenkins
/**
*
* @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());
}
代码示例来源:origin: jenkinsci/jenkins
/**
*
* @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());
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets the parameter as a file.
*/
protected final File getFileParameter(String paramName) {
return new File(Util.fixNull(request.getParameter(paramName)));
}
代码示例来源:origin: jenkinsci/jenkins
public String getValue() {
return Util.fixNull(current().node.value);
}
代码示例来源:origin: jenkinsci/jenkins
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;
}
代码示例来源:origin: jenkinsci/jenkins
@Override
@DataBoundSetter
public void setLabelString(String labelString) throws IOException {
this.label = Util.fixNull(labelString).trim();
// Compute labels now.
getAssignedLabels();
}
代码示例来源:origin: jenkinsci/jenkins
/**
*
* @return original or trimmed defaultValue (depending on trim)
*/
@Restricted(DoNotUse.class) // Jelly
public String getDefaultValue4Build() {
if (isTrim()) {
return Util.fixNull(defaultValue).trim();
}
return defaultValue;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* 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;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* 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());
}
}
}
代码示例来源:origin: jenkinsci/jenkins
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();
}
}
代码示例来源:origin: jenkinsci/jenkins
@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();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* 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());
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* 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;
}
代码示例来源:origin: jenkinsci/jenkins
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();
}
内容来源于网络,如有侵权,请联系作者删除!