List of usage examples for org.apache.commons.lang3 StringUtils defaultString
public static String defaultString(final String str, final String defaultStr)
Returns either the passed in String, or if the String is null , the value of defaultStr .
StringUtils.defaultString(null, "NULL") = "NULL" StringUtils.defaultString("", "NULL") = "" StringUtils.defaultString("bat", "NULL") = "bat"
From source file:gobblin.source.extractor.utils.Utils.java
/** * Convert timestamp in a string format to joda time * @param input timestamp/* w ww . ja v a 2 s . c om*/ * @param format timestamp format * @param timezone time zone of timestamp * @return joda time */ public static DateTime toDateTime(String input, String format, String timezone) { String tz = StringUtils.defaultString(timezone, ConfigurationKeys.DEFAULT_SOURCE_TIMEZONE); DateTimeZone dateTimeZone = getTimeZone(tz); DateTimeFormatter inputDtFormat = DateTimeFormat.forPattern(format).withZone(dateTimeZone); DateTime outputDateTime = inputDtFormat.parseDateTime(input).withZone(dateTimeZone); return outputDateTime; }
From source file:architecture.ee.web.community.spring.controller.DisplayController.java
protected String getFreemarkerView(String view, String defaultView) { String viewToUse = StringUtils.defaultString(view, defaultView); if (StringUtils.endsWithAny(viewToUse, "ftl")) { viewToUse = StringUtils.removeEndIgnoreCase(viewToUse, ".ftl"); }//from w ww . j ava2s . c om return viewToUse; }
From source file:architecture.ee.web.community.spring.controller.DisplayController.java
private void setContentType(String contentType, HttpServletResponse response) { String contentTypeToUse = StringUtils.defaultString(contentType, DEFAULT_CONTENT_TYPE); response.setContentType(contentTypeToUse); }
From source file:com.xpn.xwiki.tool.backup.ImportMojo.java
private String getPropertyString(Model model, String propertyName, String def) { return StringUtils.defaultString(getProperty(model, propertyName), def); }
From source file:com.navercorp.pinpoint.web.service.map.FilteredMapBuilder.java
private void addNode(SpanBo span, Map<Long, SpanBo> transactionSpanMap, Application srcApplication, LinkDataMap sourceLinkDataMap, SpanEventBo spanEvent) { ServiceType destServiceType = registry.findServiceType(spanEvent.getServiceType()); if (destServiceType.isAlias()) { final Application destApplication = this.applicationFactory .createApplication(spanEvent.getDestinationId(), destServiceType); applicationHashMap.putIfAbsent(spanEvent.getEndPoint(), destApplication); }/* w w w . java2 s.co m*/ if (!destServiceType.isRecordStatistics()) { // internal method return; } String dest = StringUtils.defaultString(spanEvent.getDestinationId(), "Unknown"); // convert to Unknown if destServiceType is a rpc client and there is no acceptor. // acceptor exists if there is a span with spanId identical to the current spanEvent's next spanId. // logic for checking acceptor if (destServiceType.isRpcClient()) { if (!transactionSpanMap.containsKey(spanEvent.getNextSpanId())) { Application replacedApplication = applicationHashMap.get(spanEvent.getDestinationId()); if (replacedApplication == null) { destServiceType = ServiceType.UNKNOWN; } else { //replace with alias instead of Unkown when exists logger.debug("replace with alias {}", replacedApplication.getServiceType()); destServiceType = replacedApplication.getServiceType(); dest = replacedApplication.getName(); } } } final Application destApplication = this.applicationFactory.createApplication(dest, destServiceType); final short slotTime = getHistogramSlotTime(spanEvent, destServiceType); // FIXME final long spanEventTimeStamp = timeWindow .refineTimestamp(span.getStartTime() + spanEvent.getStartElapsed()); if (logger.isTraceEnabled()) { logger.trace("spanEvent src:{} {} -> dest:{} {}", srcApplication, span.getAgentId(), destApplication, spanEvent.getEndPoint()); } // endPoint may be null final String destinationAgentId = StringUtils.defaultString(spanEvent.getEndPoint()); sourceLinkDataMap.addLinkData(srcApplication, span.getAgentId(), destApplication, destinationAgentId, spanEventTimeStamp, slotTime, 1); }
From source file:de.blizzy.documentr.markdown.MarkdownProcessor.java
private String cleanupHtml(String html, List<MacroInvocation> macroInvocations, boolean cacheable) { for (;;) {//from w w w . j a v a2 s .c o m String newHtml = html; for (Replacement replacement : CLEANUP) { newHtml = replacement.replaceAll(newHtml); } for (MacroInvocation macroInvocation : macroInvocations) { IMacro macro = macroFactory.get(macroInvocation.getMacroName()); if (macro != null) { IMacroDescriptor macroDescriptor = macro.getDescriptor(); if (macroDescriptor.isCacheable() == cacheable) { IMacroRunnable macroRunnable = macro.createRunnable(); newHtml = StringUtils.defaultString(macroRunnable.cleanupHtml(newHtml), newHtml); } } } if (newHtml.equals(html)) { break; } html = newHtml; } return html; }
From source file:de.micromata.genome.gwiki.controls.GWikiWeditServiceActionBean.java
public Object onSetDefaultEditorType() { String editorType = wikiContext.getRequestParameter("editorType"); editorType = StringUtils.defaultString(editorType, "wiki"); wikiContext.getWikiWeb().getAuthorization().setUserProp(wikiContext, GWIKI_DEFAULT_EDITOR, editorType, UserPropStorage.Client);/*from www .j a v a 2s . c o m*/ return noForward(); }
From source file:ca.simplegames.micro.Micro.java
private String maybeAppendHtmlToPath(MicroContext context) { final Context rackInput = context.getRackInput(); String path = (String) rackInput.get(JRack.PATH_INFO); if (StringUtils.isBlank(path)) { path = (String) rackInput.get(Rack.SCRIPT_NAME); }//w w w. j a v a 2 s . c o m if (welcomeFile.isEmpty() || path.contains(HTML)) { return path; } if (path.lastIndexOf(DOT) == -1) { if (!path.endsWith(SLASH)) { path = path + SLASH; } String welcomeFile = StringUtils.defaultString(site.getWelcomeFile(), INDEX + DOT + HTML); path = path + welcomeFile; } context.with(Globals.PATH_INFO, path); return path; }
From source file:de.micromata.genome.gwiki.controls.GWikiPageInfoActionBean.java
protected String loadVersionInfos() { List<GWikiElementInfo> versionInfos = wikiContext.getWikiWeb().getVersions(elementInfo); Collections.sort(versionInfos, new Comparator<GWikiElementInfo>() { @Override// w ww .j ava 2s .c o m public int compare(GWikiElementInfo o1, GWikiElementInfo o2) { return o2.getId().compareTo(o1.getId()); } }); versionInfos.add(0, elementInfo); // versionInfos.add(0, elementInfo); XmlElement cmd = element("input", attrs("type", "submit", "class", "gwikiButton main", "name", "method_onCompare", // "value", translate("gwiki.page.edit.PageInfo.version.button.compare"))); XmlElement ta = getStandardTable(); ta.nest(// tr(// th(code(" ")), // th(code(" ")), // th(text(translate("gwiki.page.edit.PageInfo.version.label.author"))), // th(text(translate("gwiki.page.edit.PageInfo.version.label.time"))), // th(text(translate("gwiki.page.edit.PageInfo.version.label.action"))) // )// ); boolean editAble = wikiContext.getWikiWeb().getAuthorization().isAllowToCreate(wikiContext, elementInfo); for (GWikiElementInfo ei : versionInfos) { ta.nest(// tr(// td(code("<input type=\"checkbox\" name=\"compareVersions\" value=\"" + ei.getId() + "\"")), // td(text(Integer.toString(ei.getProps().getIntValue(GWikiPropKeys.VERSION, 0)))), // td(text(StringUtils.defaultString(ei.getProps().getStringValue(MODIFIEDBY), "Unknown"))), // td(text(getDisplayDate(ei.getProps().getDateValue(MODIFIEDAT)))), // td(// a(attrs("class", "gwikiButton", "href", wikiContext.localUrl(ei.getId())), text(translate("gwiki.page.edit.PageInfo.version.button.view"))), // ei == elementInfo ? nbsp() : Logic.If(editAble, a( attrs("class", "gwikiButton gwikiButtonMain", "href", wikiContext.localUrl("edit/PageInfo") + "?restoreId=" + ei.getId() + "&pageId=" + pageId + "&method_onRestore=true"), // text(translate( "gwiki.page.edit.PageInfo.version.button.restore"))// ))) // )); } XmlElement np = Html.p(cmd, Html.br(), ta); return getBoxFrame(translate("gwiki.page.edit.PageInfo.version.title"), np).toString(); }
From source file:de.micromata.genome.gwiki.page.GWikiContext.java
/** * Gets the user string prop.// w w w . j a v a 2 s. c o m * * @param key the key * @param defaultValue the default value * @return the user string prop */ public String getUserStringProp(String key, String defaultValue) { return StringUtils.defaultString(getWikiWeb().getAuthorization().getUserProp(this, key), defaultValue); }